mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-21 02:41:46 +03:00
Compare commits
1 Commits
@@ -1,8 +0,0 @@
|
||||
*
|
||||
!/Package.swift
|
||||
!/Package.resolved
|
||||
!/Sources
|
||||
!/Tests
|
||||
!/Linux
|
||||
/Linux/packages
|
||||
/Linux/staging
|
||||
@@ -81,22 +81,3 @@ jobs:
|
||||
TAG="${{ github.ref_name }}"
|
||||
gh release create "$TAG" --draft --title "v$TAG"
|
||||
gh release upload "$TAG" output/**/*.{AppImage,AppImage.zsync,app.zip,app.dSYM.zip}
|
||||
docker:
|
||||
uses: docker/github-builder/.github/workflows/build.yml@v1
|
||||
permissions:
|
||||
contents: read # to fetch the repository content
|
||||
id-token: write # for signing attestations and cache entries with GitHub OIDC
|
||||
packages: write # to push built images to GitHub Container Registry
|
||||
with:
|
||||
output: image
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
meta-images: |
|
||||
ghcr.io/xtool-org/xtool
|
||||
meta-tags: |
|
||||
type=semver,pattern={{version}}
|
||||
secrets:
|
||||
registry-auths: |
|
||||
- registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# About
|
||||
|
||||
xtool is a cross-platform replacement for Xcode (including build system, provisioning, deployment).
|
||||
|
||||
The `xtool` CLI supports macOS, Linux, WSL. The lower-level XKit (provisioning and device interaction) library additionally supports iOS.
|
||||
|
||||
## Development
|
||||
|
||||
- The majority of the code is in the Swift Package. You can use `swift build` / `swift test` / etc for iteration.
|
||||
- Caveat: on macOS, xtool is distributed as an app bundle (allows entitlements like Keychain). To build the Mac app, use `make mac`. You can then invoke the CLI at `./macOS/Build/xtool`.
|
||||
- Make sure to run `make lint` (swiftlint) when you're done
|
||||
|
||||
## Conventions
|
||||
|
||||
- Use modern Swift 6. Strict concurrency is enabled.
|
||||
- Use swift-dependencies for Dependency Injection. Passing dependencies around as arguments is an anti-pattern.
|
||||
+3
-21
@@ -79,15 +79,11 @@ RUN cd xadi \
|
||||
&& cp -r bin/libxadi.so /prefix/usr/lib/libxadi.so
|
||||
|
||||
|
||||
FROM build-base AS build-xtool-base
|
||||
FROM build-base
|
||||
|
||||
COPY --from=build-limd /prefix/usr /usr
|
||||
COPY --from=build-xadi /prefix/usr /usr
|
||||
|
||||
WORKDIR /xtool
|
||||
|
||||
FROM build-xtool-base AS dev
|
||||
|
||||
# Docker doesn't support FUSE
|
||||
ENV APPIMAGE_EXTRACT_AND_RUN=1
|
||||
|
||||
@@ -96,20 +92,6 @@ ENV APPIMAGE_EXTRACT_AND_RUN=1
|
||||
# socat -dd TCP-LISTEN:27015,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/usbmuxd
|
||||
ENV USBMUXD_SOCKET_ADDRESS=host.docker.internal:27015
|
||||
|
||||
WORKDIR /xtool
|
||||
|
||||
CMD [ "/bin/bash" ]
|
||||
|
||||
FROM build-xtool-base AS build-xtool
|
||||
|
||||
ADD Package.swift Package.resolved /xtool/
|
||||
RUN swift package resolve
|
||||
|
||||
ADD . /xtool
|
||||
RUN ./Linux/build.sh
|
||||
|
||||
FROM swift:6.3 AS xtool
|
||||
|
||||
COPY --from=build-xtool /xtool/Linux/packages/xtool-*.AppImage /xtool/xtool.AppImage
|
||||
RUN (cd /xtool && ./xtool.AppImage --appimage-extract) \
|
||||
&& mv /xtool/squashfs-root /usr/local/xtool \
|
||||
&& rm -rf /xtool \
|
||||
&& ln -s /usr/local/xtool/AppRun /usr/local/bin/xtool
|
||||
|
||||
@@ -22,5 +22,4 @@ else
|
||||
fi
|
||||
|
||||
"$docc" "$command" xtool.docc \
|
||||
--enable-experimental-code-block-annotations \
|
||||
--experimental-enable-custom-templates
|
||||
|
||||
@@ -14,12 +14,6 @@ If you're on Windows, you can use xtool via [Windows Subsystem for Linux](https:
|
||||
|
||||
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.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> If you encounter `Error: AFCClient.Error.muxError`, follow the steps described in [this issue comment](https://github.com/xtool-org/xtool/issues/19#issuecomment-2898986718) from user rena2019.
|
||||
>
|
||||
> This relays the device connection from iTunes on Windows, instead of relying on USBIPD.
|
||||
|
||||
### Swift
|
||||
|
||||
Install the Swift 6.3 toolchain for your Linux distribution from <https://swift.org/install/linux>.
|
||||
|
||||
@@ -56,10 +56,6 @@ linux-clean:
|
||||
linux-dist:
|
||||
docker compose run --build --rm xtool Linux/build.sh
|
||||
|
||||
.PHONY: docker
|
||||
docker:
|
||||
docker build . -t ghcr.io/xtool-org/xtool:latest
|
||||
|
||||
.PHONY: mac
|
||||
# dev build for macOS
|
||||
mac: project
|
||||
|
||||
@@ -146,7 +146,6 @@ let package = Package(
|
||||
.testTarget(
|
||||
name: "XToolTests",
|
||||
dependencies: [
|
||||
"XKit",
|
||||
"XToolSupport",
|
||||
]
|
||||
),
|
||||
|
||||
@@ -138,9 +138,3 @@ extension WirelessAccessoryEntitlement: EntitlementWithCapability {
|
||||
DeveloperServicesCapability(.wirelessAccessoryConfiguration, isFree: true)
|
||||
}
|
||||
}
|
||||
|
||||
extension WiFiAwareEntitlement: EntitlementWithCapability {
|
||||
var capability: DeveloperServicesCapability {
|
||||
DeveloperServicesCapability(rawName: "WIFI_AWARE", isFree: false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,10 +140,12 @@ public struct DeveloperAPIXcodeAuthMiddleware: ClientMiddleware {
|
||||
|
||||
// Xcode-specific
|
||||
request.headerFields[.userAgent] = "Xcode"
|
||||
request.headerFields[.init(DeviceInfo.xcodeVersionKey)!] = DeviceInfo.xcodeVersion
|
||||
request.headerFields[.init(DeviceInfo.xcodeVersionKey)!] = "16.2 (16C5031c)"
|
||||
|
||||
// MobileMe identity
|
||||
request.headerFields[.init(DeviceInfo.clientInfoKey)!] = deviceInfo.clientInfo.clientString
|
||||
request.headerFields[.init(DeviceInfo.clientInfoKey)!] = """
|
||||
<VirtualMac2,1> <macOS;15.1.1;24B91> <com.apple.AuthKit/1 (com.apple.dt.Xcode/23505)>
|
||||
""" // deviceInfo.clientInfo.clientString
|
||||
request.headerFields[.init(DeviceInfo.deviceIDKey)!] = deviceInfo.deviceID
|
||||
|
||||
// GrandSlam authentication
|
||||
|
||||
@@ -14,19 +14,29 @@ public struct DeviceInfo: Codable, Sendable {
|
||||
/// `X-Xcode-Version`
|
||||
static let xcodeVersionKey = "X-Xcode-Version"
|
||||
/// Not included in `dictionary`
|
||||
public static let xcodeVersion = "26.5 (17F42)"
|
||||
public static let xcodeVersion = "14.2 (14C18)"
|
||||
|
||||
public struct ClientInfo: Codable {
|
||||
public static let macOSVersion = "14.3.1"
|
||||
public static let macOSBuild = "23D60"
|
||||
|
||||
public static let authKitVersion = "1"
|
||||
public static let akdVersion = "1.0"
|
||||
public static let cfNetworkVersion = "978.0.7"
|
||||
public static let darwinVersion = "18.7.0"
|
||||
|
||||
public let modelID: String // e.g. MacBookPro11,5
|
||||
|
||||
// TODO: Do we need to replace com.apple.akd with com.apple.dt.Xcode? See AltStore
|
||||
var clientString: String {
|
||||
"""
|
||||
<\(modelID)> <macOS;26.6;25G72> <com.apple.AuthKit/1 (com.apple.dt.Xcode/26.0)>
|
||||
<\(modelID)> <Mac OS X;\(Self.macOSVersion);\(Self.macOSBuild)> \
|
||||
<com.apple.AuthKit/\(Self.authKitVersion) (com.apple.akd/\(Self.akdVersion))>
|
||||
"""
|
||||
}
|
||||
|
||||
var userAgent: String {
|
||||
"AuthKit/1 (Macintosh; OS X 26.6) (com.apple.dt.Xcode/26.0)"
|
||||
"akd/\(Self.akdVersion) CFNetwork/\(Self.cfNetworkVersion) Darwin/\(Self.darwinVersion)"
|
||||
}
|
||||
|
||||
public init(modelID: String) {
|
||||
|
||||
@@ -26,7 +26,6 @@ extension EntitlementContainer {
|
||||
SiriKitEntitlement.self,
|
||||
InterAppAudioEntitlement.self,
|
||||
WirelessAccessoryEntitlement.self,
|
||||
WiFiAwareEntitlement.self,
|
||||
HomeKitEntitlement.self,
|
||||
HealthKitEntitlement.self,
|
||||
]
|
||||
@@ -156,21 +155,6 @@ public struct WirelessAccessoryEntitlement: Entitlement, RawRepresentable {
|
||||
public init(rawValue: Bool) { self.rawValue = rawValue }
|
||||
}
|
||||
|
||||
public struct WiFiAwareEntitlement: Entitlement, RawRepresentable {
|
||||
public static let identifier = "com.apple.developer.wifi-aware"
|
||||
|
||||
public var rawValue: [String]
|
||||
public init(rawValue: [String]) { self.rawValue = rawValue }
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
rawValue = try decoder.singleValueContainer().decode([String].self)
|
||||
}
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.singleValueContainer()
|
||||
try container.encode(rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
public struct HomeKitEntitlement: Entitlement, RawRepresentable {
|
||||
public static let identifier = "com.apple.developer.homekit"
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import XKit
|
||||
|
||||
@Test func wifiAwareEntitlementMapsToDeveloperCapability() throws {
|
||||
let plist = """
|
||||
<?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>com.apple.developer.wifi-aware</key>
|
||||
<array>
|
||||
<string>Publish</string>
|
||||
<string>Subscribe</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
"""
|
||||
|
||||
let entitlements = try PropertyListDecoder().decode(
|
||||
Entitlements.self,
|
||||
from: Data(plist.utf8)
|
||||
)
|
||||
let wifiAware = try #require(
|
||||
entitlements.entitlements().compactMap { $0 as? WiFiAwareEntitlement }.first
|
||||
)
|
||||
|
||||
#expect(wifiAware.rawValue == ["Publish", "Subscribe"])
|
||||
#expect(wifiAware.capability.capabilityType.value1 == nil)
|
||||
#expect(wifiAware.capability.capabilityType.value2 == "WIFI_AWARE")
|
||||
#expect(wifiAware.capability.settings == nil)
|
||||
#expect(!wifiAware.capability.isFree)
|
||||
|
||||
let encoded = try PropertyListEncoder().encode(entitlements)
|
||||
let dictionary = try #require(
|
||||
PropertyListSerialization.propertyList(from: encoded, format: nil) as? [String: Any]
|
||||
)
|
||||
#expect(dictionary[WiFiAwareEntitlement.identifier] as? [String] == ["Publish", "Subscribe"])
|
||||
}
|
||||
+2
-2
@@ -2,10 +2,8 @@ services:
|
||||
xtool:
|
||||
build:
|
||||
context: .
|
||||
target: dev
|
||||
volumes:
|
||||
- .:/xtool
|
||||
- .build/linux:/xtool/.build
|
||||
container_name: xtool
|
||||
stdin_open: true
|
||||
tty: true
|
||||
@@ -15,4 +13,6 @@ services:
|
||||
- seccomp:unconfined
|
||||
extra_hosts:
|
||||
# host.docker.internal doesn't exist by default on Linux hosts
|
||||
# TODO: Does this conflict with the default host on macOS?
|
||||
# we could rename this
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
Reference in New Issue
Block a user