mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-21 10:45:53 +03:00
Compare commits
1 Commits
+2
-2
@@ -1,7 +1,7 @@
|
||||
# Note: We use 22.04 since AppImage recommends building on the
|
||||
# Note: We use 20.04 since AppImage recommends building on the
|
||||
# oldest configuration that you support
|
||||
|
||||
FROM swift:6.1-jammy AS build-base
|
||||
FROM swift:6.1-focal AS build-base
|
||||
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# xtool
|
||||
|
||||
Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, and macOS.
|
||||
Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux and macOS.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -15,7 +15,7 @@ xtool is a cross-platform (Linux/WSL/macOS) tool that replicates Xcode functiona
|
||||
## Getting Started
|
||||
|
||||
1. Follow the guide to install `xtool`
|
||||
- [Installation (Linux/Windows)](https://swiftpackageindex.com/xtool-org/xtool/documentation/xtool/installation-linux)
|
||||
- [Installation (Linux)](https://swiftpackageindex.com/xtool-org/xtool/documentation/xtool/installation-linux)
|
||||
- [Installation (macOS)](https://swiftpackageindex.com/xtool-org/xtool/documentation/xtool/installation-macos)
|
||||
2. Create and run your first xtool-powered app by following the [tutorial](https://swiftpackageindex.com/xtool-org/xtool/tutorials/xtool/first-app)!
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public struct DeveloperServicesLoginManager: Sendable {
|
||||
private func logIn(
|
||||
withLoginData loginData: GrandSlamLoginData
|
||||
) async throws -> DeveloperServicesLoginToken {
|
||||
print("Fetching tokens")
|
||||
let tokens = try await GrandSlamFetchAppTokensOperation(
|
||||
client: client,
|
||||
apps: [.xcode],
|
||||
@@ -49,6 +50,7 @@ public struct DeveloperServicesLoginManager: Sendable {
|
||||
password: String,
|
||||
twoFactorDelegate: TwoFactorAuthDelegate
|
||||
) async throws -> DeveloperServicesLoginToken {
|
||||
print("Starting login")
|
||||
let loginData = try await GrandSlamAuthenticateOperation(
|
||||
client: client,
|
||||
// GSA requires Apple IDs in lowercase for SRP
|
||||
|
||||
@@ -65,6 +65,8 @@ struct GrandSlamAuthenticateOperation {
|
||||
}
|
||||
|
||||
private func authenticate(isRetry: Bool) async throws -> GrandSlamLoginData {
|
||||
print("Doing SRP stuff")
|
||||
|
||||
var srpClient = SRPClient()
|
||||
|
||||
srpClient.add(string: GrandSlamAuthInitRequest.protocols.joined(separator: ","))
|
||||
@@ -116,6 +118,8 @@ struct GrandSlamAuthenticateOperation {
|
||||
)
|
||||
}
|
||||
|
||||
print("Got loginData")
|
||||
|
||||
return loginData
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ struct GrandSlamFetchAppTokensOperation {
|
||||
|
||||
func perform() async throws -> [AppTokenKey: Token] {
|
||||
let checksum = AppTokens.checksum(withSK: loginData.sk, adsid: loginData.adsid, apps: apps.map { $0.rawValue })
|
||||
print("Got checksum")
|
||||
let appTokensRequest = GrandSlamAppTokensRequest(
|
||||
username: loginData.adsid,
|
||||
apps: apps,
|
||||
@@ -71,7 +72,9 @@ struct GrandSlamFetchAppTokensOperation {
|
||||
idmsToken: loginData.idmsToken,
|
||||
checksum: checksum
|
||||
)
|
||||
print("Sending tokens req")
|
||||
let response = try await client.send(appTokensRequest)
|
||||
print("Handling tokens resp")
|
||||
return try await self.handle(response: response)
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public actor Connection {
|
||||
private static let pool = WeakPool<ConnectionDescriptor, Connection, Error>()
|
||||
|
||||
private var handle: AnyObject?
|
||||
private let heartbeatHandler: HeartbeatHandler?
|
||||
private let heartbeatHandler: HeartbeatHandler
|
||||
private let udid: String
|
||||
public let device: Device
|
||||
public let client: LockdownClient
|
||||
@@ -101,12 +101,8 @@ public actor Connection {
|
||||
|
||||
client = try LockdownClient(device: device, label: Self.label, performHandshake: true)
|
||||
|
||||
#if os(iOS)
|
||||
progress(3/4)
|
||||
heartbeatHandler = try await HeartbeatHandler(device: device, client: client)
|
||||
#else
|
||||
heartbeatHandler = nil
|
||||
#endif
|
||||
|
||||
progress(4/4)
|
||||
}
|
||||
@@ -126,7 +122,7 @@ public actor Connection {
|
||||
}
|
||||
|
||||
deinit {
|
||||
heartbeatHandler?.stop()
|
||||
heartbeatHandler.stop()
|
||||
// we could nil out connections[udid] here but that might lead to
|
||||
// weird race conditions against Connection.connection that seem
|
||||
// like a nightmare to diagnose, and storing an empty box for a
|
||||
|
||||
@@ -98,8 +98,13 @@ struct AuthOperation {
|
||||
twoFactorDelegate: authDelegate
|
||||
)
|
||||
|
||||
print("Got full login token")
|
||||
|
||||
let client = DeveloperServicesClient(loginToken: token)
|
||||
let teams = try await client.send(DeveloperServicesListTeamsRequest())
|
||||
|
||||
print("Got teams")
|
||||
|
||||
let team = try await Console.choose(
|
||||
from: teams,
|
||||
onNoElement: {
|
||||
|
||||
@@ -79,7 +79,7 @@ struct NewCommand: AsyncParsableCommand {
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
// An xtool project should contain exactly one library product,
|
||||
// An xtool project should contain exactly one library target,
|
||||
// representing the main app.
|
||||
.library(
|
||||
name: "\(moduleName)",
|
||||
@@ -116,6 +116,7 @@ struct NewCommand: AsyncParsableCommand {
|
||||
.netrc
|
||||
|
||||
/xtool
|
||||
/.sourcekit-lsp
|
||||
"""
|
||||
),
|
||||
|
||||
|
||||
@@ -134,7 +134,6 @@ struct DarwinSDK {
|
||||
if targetURL.exists {
|
||||
throw Console.Error("Darwin SDK is already installed at '\(targetURL.path)'. Please remove it first.")
|
||||
}
|
||||
try? FileManager.default.createDirectory(at: sdksDir, withIntermediateDirectories: true)
|
||||
try FileManager.default.moveItem(at: url, to: targetURL)
|
||||
guard let sdk = DarwinSDK(bundle: targetURL) else {
|
||||
throw Console.Error("Darwin SDK failed to install")
|
||||
|
||||
@@ -25,9 +25,7 @@ struct SetupOperation {
|
||||
try await AuthOperation(logoutFromExisting: false, quiet: quiet).run()
|
||||
|
||||
#if os(macOS)
|
||||
if !quiet {
|
||||
print("Skipping Darwin SDK setup since we're on macOS.")
|
||||
}
|
||||
print("Skipping Darwin SDK setup since we're on macOS.")
|
||||
#else
|
||||
switch try DarwinSDK.current()?.isUpToDate() {
|
||||
case true?:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@Tutorial(time: 30) {
|
||||
@Intro(title: "Build your first iOS app on Linux / Windows") {
|
||||
Once you've completed <doc:Installation-Linux>, use xtool to build and deploy an iOS app from your Linux/Windows machine.
|
||||
@Intro(title: "Build your first iOS app on Linux") {
|
||||
Once you've completed <doc:Installation-Linux>, use xtool to build and deploy an iOS app from your Linux machine.
|
||||
}
|
||||
|
||||
@Section(title: "Create an xtool project") {
|
||||
@@ -118,7 +118,7 @@
|
||||
@Step {
|
||||
Follow the instructions to configure [SourceKit-LSP](https://github.com/swiftlang/sourcekit-lsp/blob/242609dcad55824d9eb23269c0aeead187fd0faa/Documentation/Editor%20Integration.md) for your IDE.
|
||||
|
||||
For example, if you're using Visual Studio Code, this means you need to install the [Swift extension](https://marketplace.visualstudio.com/items?itemName=swiftlang.swift-vscode). If you're on Windows, make sure you're [connected to the WSL remote](https://code.visualstudio.com/docs/remote/wsl).
|
||||
For example, if you're using Visual Studio Code, this means you need to install the [Swift extension](https://marketplace.visualstudio.com/items?itemName=swiftlang.swift-vscode).
|
||||
|
||||
@Image(source: "SwiftExtension", alt: "Swift extension for VSCode")
|
||||
}
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
# Installation (Linux/Windows)
|
||||
# Installation (Linux)
|
||||
|
||||
Set up xtool for iOS app development on Linux or Windows.
|
||||
Set up xtool for iOS app development on Linux.
|
||||
|
||||
## Overview
|
||||
|
||||
This article outlines the steps to install `xtool` and begin developing iOS apps on Linux (or Windows via WSL).
|
||||
This article outlines the steps to install `xtool` and begin developing iOS apps on Linux.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### WSL (for Windows users)
|
||||
|
||||
If you're on Windows, you can use xtool via [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/install) (WSL).
|
||||
|
||||
Once you install WSL, you'll also need to set up USB passthrough. See Microsoft's instructions on [installing USBIPD](https://learn.microsoft.com/en-us/windows/wsl/connect-usb). Make sure you're able to bind your iOS device to WSL via USB.
|
||||
|
||||
### Swift
|
||||
|
||||
Install the Swift 6.1 toolchain for your Linux distribution from <https://swift.org/install/linux>.
|
||||
|
||||
@@ -9,9 +9,13 @@ enum XToolMain {
|
||||
static func main() async throws {
|
||||
prepareDependencies { dependencies in
|
||||
#warning("Improve persistence mechanism")
|
||||
// for macOS, we can use KeychainStorage but we need to sign with entitlements.
|
||||
// for Windows, we could use dpapi.h or wincred.h.
|
||||
// for Linux, maybe use libsecret?
|
||||
// see https://github.com/atom/node-keytar
|
||||
// #if os(macOS)
|
||||
// dependencies.keyValueStorage = KeychainStorage(service: "com.kabiroberai.xtool-keychain.credentials")
|
||||
// #endif
|
||||
}
|
||||
try await XTool.run()
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
/XToolMac.xcodeproj
|
||||
Private*.xcconfig
|
||||
@@ -1,11 +0,0 @@
|
||||
# macOS Packaging
|
||||
|
||||
xtool is packaged as a .app bundle on macOS, so that we can add entitlements and use the keychain.
|
||||
|
||||
Ideally we'd dogfood xtool to package xtool, but it only supports iOS apps right now. Someday, hopefully.
|
||||
|
||||
## Building
|
||||
|
||||
1. Install [XcodeGen](https://github.com/yonaskolb/XcodeGen)
|
||||
2. Run `xcodegen` inside this (`./macOS`) directory
|
||||
3. Open the Xcode project and build the `XToolMac` scheme
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# https://github.com/microsoft/vscode/blob/509cc674f24d87a298d56518c318de67bda357cb/resources/darwin/bin/code.sh
|
||||
|
||||
function app_realpath() {
|
||||
SOURCE="$1"
|
||||
while [ -h "$SOURCE" ]; do
|
||||
DIR=$(/usr/bin/dirname "$SOURCE")
|
||||
SOURCE=$(/usr/bin/readlink "$SOURCE")
|
||||
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE"
|
||||
done
|
||||
SOURCE_DIR="$( cd -P "$( /usr/bin/dirname "$SOURCE" )" >/dev/null 2>&1 && echo "$PWD" )"
|
||||
echo "${SOURCE_DIR%%${SOURCE_DIR#*.app}}"
|
||||
}
|
||||
|
||||
APP_PATH="$(app_realpath "${BASH_SOURCE[0]}")"
|
||||
if [ -z "$APP_PATH" ]; then
|
||||
echo "Unable to determine app path from symlink : ${BASH_SOURCE[0]}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
XTL_CLI=1 "$APP_PATH/Contents/MacOS/xtool" "$@"
|
||||
@@ -1,9 +0,0 @@
|
||||
GENERATE_INFOPLIST_FILE = YES
|
||||
CODE_SIGN_ENTITLEMENTS = Support/XToolMac.entitlements
|
||||
CODE_SIGN_STYLE = Automatic
|
||||
ENABLE_HARDENED_RUNTIME = YES
|
||||
|
||||
PRODUCT_NAME = xtool
|
||||
PRODUCT_MODULE_NAME = XToolMac
|
||||
|
||||
#include? "Private.xcconfig"
|
||||
@@ -1 +0,0 @@
|
||||
#include "Base.xcconfig"
|
||||
@@ -1 +0,0 @@
|
||||
#include "Base.xcconfig"
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)sh.xtool.keychain</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,24 +0,0 @@
|
||||
import Foundation
|
||||
import Dependencies
|
||||
import XToolSupport
|
||||
import XKit
|
||||
|
||||
@main enum XToolMacMain {
|
||||
static func main() async throws {
|
||||
// the bin/xtool script invokes us with this env var, allowing us to
|
||||
// detect command-line invocations vs a UI app launch
|
||||
if ProcessInfo.processInfo.environment["XTL_CLI"] == "1" {
|
||||
try await runXTool()
|
||||
} else {
|
||||
XToolMacUI.main()
|
||||
}
|
||||
}
|
||||
|
||||
private static func runXTool() async throws {
|
||||
try await withDependencies {
|
||||
$0.keyValueStorage = KeychainStorage(service: "sh.xtool.keychain.credentials")
|
||||
} operation: {
|
||||
try await XTool.run()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct XToolMacUI: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
}
|
||||
.disableWindowResizingIfPossible()
|
||||
}
|
||||
}
|
||||
|
||||
private struct ContentView: View {
|
||||
private static let command = """
|
||||
sudo ln -fs /Applications/xtool.app/Contents/Resources/bin/xtool /usr/local/bin/xtool
|
||||
"""
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
StepView(1) {
|
||||
Text("Move this app into your `/Applications` folder.")
|
||||
}
|
||||
|
||||
StepView(2) {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
Text("Symlink xtool into a location on your `PATH`.")
|
||||
|
||||
Text(Self.command)
|
||||
.font(.body.monospaced())
|
||||
.textSelection(.enabled)
|
||||
|
||||
Button("Copy Command") {
|
||||
NSPasteboard.general.clearContents()
|
||||
NSPasteboard.general.setString(Self.command, forType: .string)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.padding(.vertical)
|
||||
.frame(width: 500)
|
||||
.fixedSize()
|
||||
.navigationTitle("xtool")
|
||||
}
|
||||
}
|
||||
|
||||
private struct StepView<Content: View>: View {
|
||||
let number: Int
|
||||
let content: Content
|
||||
|
||||
init(_ number: Int, @ViewBuilder content: () -> Content) {
|
||||
self.number = number
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text("\(number)")
|
||||
.foregroundStyle(.background)
|
||||
.padding(8)
|
||||
.background(.secondary, in: .circle)
|
||||
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Scene {
|
||||
fileprivate func disableWindowResizingIfPossible() -> some Scene {
|
||||
if #available(macOS 13, *) {
|
||||
return self.windowResizability(.contentSize)
|
||||
} else {
|
||||
return self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
name: XToolMac
|
||||
options:
|
||||
bundleIdPrefix: sh.xtool
|
||||
packages:
|
||||
xtool:
|
||||
path: ..
|
||||
group: ""
|
||||
fileGroups:
|
||||
- Support
|
||||
targets:
|
||||
XToolMac:
|
||||
type: application
|
||||
platform: macOS
|
||||
deploymentTarget: "12.0"
|
||||
sources:
|
||||
- path: XToolMac
|
||||
- path: Resources/xtool
|
||||
buildPhase:
|
||||
copyFiles:
|
||||
destination: resources
|
||||
subpath: bin
|
||||
configFiles:
|
||||
Debug: Support/Debug.xcconfig
|
||||
Release: Support/Release.xcconfig
|
||||
dependencies:
|
||||
- package: xtool
|
||||
product: XToolSupport
|
||||
Reference in New Issue
Block a user