Compare commits

..

1 Commits

39 changed files with 29 additions and 266 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ on:
push:
branches:
- main
# pull_request:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
-81
View File
@@ -1,81 +0,0 @@
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-appimage:
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: XTL_CONFIG=debug make linux-dist
- name: Upload AppImage
uses: actions/upload-artifact@v4
with:
name: xtool-linux-aarch64
path: Linux/packages/xtool-aarch64.AppImage
compression-level: 0
build-mac:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Build
run: |
brew install xcodegen
make mac DEVELOPMENT_TEAM='""'
(cd macOS/Build/XcodeInstall && zip -yqr xtool.app.zip xtool.app)
- name: Upload app
uses: actions/upload-artifact@v4
with:
name: xtool-mac
path: macOS/Build/XcodeInstall/xtool.app.zip
compression-level: 0
test:
needs: [build-appimage, build-mac]
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: xtool-*
merge-multiple: true
path: stage
- name: Process artifacts
run: |
chmod +x stage/xtool-aarch64.AppImage
unzip -q stage/xtool.app.zip -d stage
ln -fs "$PWD/stage/xtool.app/Contents/Resources/bin/xtool" /usr/local/bin/xtool
# https://github.com/abiosoft/colima/issues/970#issuecomment-2224011277
- name: Setup Docker
run: |
brew install --formula docker colima qemu
LIMACTL_PATH=$(brew --prefix)/bin/limactl
sudo curl -fL -o $LIMACTL_PATH https://github.com/mikekazakov/lima-nohvf/raw/acd34e689a7186d8317116165101b1fa56083542/limactl
sudo chmod +x $LIMACTL_PATH
colima start --disk 20 --vm-type qemu --arch arm64
- name: Build SDK
run: |
xtool sdk build /Applications/Xcode_16.3.app stage
- name: Run test
run: |
docker run --rm -i \
-v ./stage:/stage \
swift:6.1.1 \
bash << EOF
mkdir -p ~/.swiftpm/swift-sdks
ln -fs /stage/darwin.artifactbundle ~/.swiftpm/swift-sdks/
export APPIMAGE_EXTRACT_AND_RUN=1
ln -fs /stage/xtool-aarch64.AppImage /usr/local/bin/xtool
xtool new Hello --skip-setup
cd Hello
xtool dev build
EOF
-19
View File
@@ -1,19 +0,0 @@
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'
jobs:
swiftlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint
run: |
make lint SWIFTLINT_FLAGS='--reporter=github-actions-logging' | tee swiftlint.log
# fail if there are any errors or warnings
! grep -Eq '^::(error|warning)' swiftlint.log
-1
View File
@@ -12,4 +12,3 @@ DerivedData/
.docc-build
/openapi
/.tmp
-73
View File
@@ -1,73 +0,0 @@
swiftlint_version: 0.59.1
disabled_rules:
- trailing_comma
- nesting
- fallthrough
- shorthand_operator
- todo
- large_tuple
- identifier_name
- type_name
- unneeded_override
- optional_data_string_conversion
- for_where
- blanket_disable_command
opt_in_rules:
- closure_end_indentation
- closure_spacing
- empty_count
- explicit_init
- fatal_error_message
- first_where
- implicit_return
- joined_default_parameter
- literal_expression_end_indentation
- overridden_super_call
- prohibited_super_call
- sorted_first_last
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment_on_call
- yoda_condition
- nslocalizedstring_key
- unused_setter_value
- optional_enum_case_matching
- prefer_self_type_over_type_of_self
- contains_over_range_nil_comparison
- flatmap_over_map_reduce
- empty_collection_literal
- contains_over_first_not_nil
- contains_over_filter_count
- contains_over_filter_is_empty
- reduce_into
analyzer_rules:
- unused_import
custom_rules:
spaces_not_tabs:
name: "Spaces not Tabs"
regex: ^\t
message: "Use four spaces, not tabs"
point_zero:
name: "Point Zero"
regex: '(?<!iOS\s)(?<!macOS\s)(?<!\.)\b[\d_]+\.0\b'
match_kinds:
- number
- attribute.builtin
message: "Don't add a .0 to the end of floating point literals"
force_try: warning
force_cast: warning
function_body_length: 100
line_length: 135
file_length: 1000
type_body_length: 500
cyclomatic_complexity: 12
function_parameter_count: 7
implicit_return:
included:
- closure
included:
- Package.swift
- Sources
- Tests
- macOS/XToolMac
excluded:
- Sources/DeveloperAPI/Generated
-1
View File
@@ -1 +0,0 @@
/launch.json
-6
View File
@@ -1,6 +0,0 @@
{
"recommendations": [
"swiftlang.swift-vscode",
"vknabel.vscode-swiftlint",
]
}
-3
View File
@@ -1,3 +0,0 @@
{
"swiftlint.path": "./.tmp/swiftlint/swiftlint",
}
+2 -4
View File
@@ -13,10 +13,8 @@ fi
rm -rf staging/tmp
mkdir -p staging/tmp staging/linuxdeploy
RESOLVED_CONFIG="${XTL_CONFIG:-release}"
swift build --package-path .. -c "${RESOLVED_CONFIG}" --product xtool --static-swift-stdlib
bin="$(swift build --package-path .. -c "${RESOLVED_CONFIG}" --show-bin-path)"
swift build --package-path .. -c release --product xtool --static-swift-stdlib
bin="$(swift build --package-path .. -c release --show-bin-path)"
strip "${bin}/xtool"
curr_git_info="$(curl -fsSL https://api.github.com/repos/linuxdeploy/linuxdeploy/git/refs/tags/continuous)"
+1 -18
View File
@@ -54,7 +54,7 @@ linux-clean:
.PHONY: linux-dist
# dist build for Linux
linux-dist:
docker compose run --build -e XTL_CONFIG --rm xtool Linux/build.sh
docker compose run --build --rm xtool Linux/build.sh
.PHONY: mac
# dev build for macOS
@@ -126,23 +126,6 @@ docs:
docs-preview:
./Documentation/build.sh preview
SWIFTLINT_VERSION = $(shell head -1 .swiftlint.yml | cut -d' ' -f2)
SWIFTLINT_BIN = .tmp/swiftlint/swiftlint-$(SWIFTLINT_VERSION)
SWIFTLINT_URL = https://github.com/realm/SwiftLint/releases/download/$(SWIFTLINT_VERSION)/$(if $(IS_MAC),portable_swiftlint,swiftlint_linux).zip
.PHONY: lint
lint: $(SWIFTLINT_BIN)
$(SWIFTLINT_BIN) $(SWIFTLINT_FLAGS)
$(SWIFTLINT_BIN):
@rm -rf .tmp/swiftlint
@mkdir -p .tmp/swiftlint
curl -fSL $(SWIFTLINT_URL) -o .tmp/swiftlint/swiftlint.zip
unzip -q .tmp/swiftlint/swiftlint.zip swiftlint -d .tmp/swiftlint
@rm -f .tmp/swiftlint/swiftlint.zip
@mv .tmp/swiftlint/swiftlint $@
@ln -s swiftlint-$(SWIFTLINT_VERSION) .tmp/swiftlint/swiftlint
SPEC_URL = https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip
.PHONY: api
-1
View File
@@ -60,7 +60,6 @@ public struct PackSchema: Sendable {
}
}
// swiftlint:disable:next force_try
public static let `default` = try! PackSchema(validating: .init(
version: .v1,
orgID: "com.example"
-1
View File
@@ -104,7 +104,6 @@ public struct Packer: Sendable {
let bytes = try FileHandle(forReadingFrom: src).read(upToCount: magic.count)
// if the magic matches one of these it's a static archive; don't embed it.
// https://github.com/apple/llvm-project/blob/e716ff14c46490d2da6b240806c04e2beef01f40/llvm/include/llvm/Object/Archive.h#L33
// swiftlint:disable:previous line_length
if bytes != magic && bytes != thinMagic {
try await packFile(srcName: "\(name).framework", dstName: "Frameworks/\(name).framework", sign: true)
}
-1
View File
@@ -18,7 +18,6 @@ public struct Planner: Sendable {
return decoder
}()
// swiftlint:disable:next function_body_length cyclomatic_complexity
public func createPlan() async throws -> Plan {
// TODO: cache plan using (Package.swift+Package.resolved) as the key?
-1
View File
@@ -13,7 +13,6 @@ public struct XcodePacker {
self.plan = plan
}
// swiftlint:disable:next function_body_length
public func createProject() async throws -> URL {
let targetName = "\(plan.product)-App"
@@ -13,7 +13,6 @@ extension DeveloperAPIClient {
) {
@Dependency(\.httpClient) var httpClient
self.init(
// swiftlint:disable:next force_try
serverURL: try! Servers.Server1.url(),
configuration: .init(
dateTranscoder: .iso8601WithFractionalSeconds
@@ -225,11 +225,7 @@ public struct ADIDataProvider: AnisetteDataProvider {
) async throws -> AnisetteData {
let requestTime = Date()
var routingInfo = routingInfo
let (mid, otp) = try await rawProvider.requestOTP(
userID: localUserUID,
routingInfo: &routingInfo,
provisioningInfo: provisioningInfo
)
let (mid, otp) = try await rawProvider.requestOTP(userID: localUserUID, routingInfo: &routingInfo, provisioningInfo: provisioningInfo)
return AnisetteData(
clientTime: requestTime,
routingInfo: routingInfo,
@@ -153,7 +153,7 @@ public actor XADIProvider: RawADIProvider {
var midLen: UInt32 = 0
var otpBytes: UnsafeMutableRawPointer?
var otpLen: UInt32 = 0
let adiDirectory = directory.appending(path: "adi")
try? FileManager.default.createDirectory(at: adiDirectory, withIntermediateDirectories: true)
let adiFile = adiDirectory.appending(path: "adi.pb")
@@ -111,7 +111,7 @@ struct SRPClient {
let hashedPassword = Data(SHA256.hash(data: Data(password.utf8)))
let pbkdfInput = if isLegacyProtocol {
Data(hashedPassword.map { String(format: "%02hhx", $0) }.joined().utf8)
Data(hashedPassword.map { String(format: "%02hhx", $0) }.joined(separator: "").utf8)
} else {
hashedPassword
}
@@ -15,7 +15,7 @@ struct GrandSlamLoginData: Decodable {
let cookie: Data
var identityToken: String {
Data("\(adsid):\(idmsToken)".utf8).base64EncodedString()
"\(adsid):\(idmsToken)".data(using: .utf8)!.base64EncodedString()
}
private enum CodingKeys: String, CodingKey {
@@ -46,3 +46,4 @@ struct GrandSlamValidateSMSRequest: GrandSlamTwoFactorRequest {
])
}
}
@@ -24,11 +24,10 @@ extension HTTPClientDependencyKey: DependencyKey {
let appleRootCA = try! NIOSSLCertificate(bytes: Array(appleRootPEM.utf8), format: .pem)
var tlsConfiguration: TLSConfiguration = .makeClientConfiguration()
tlsConfiguration.additionalTrustRoots = [.certificates([appleRootCA])]
var config = HTTPClient.Configuration(
let config = HTTPClient.Configuration(
tlsConfiguration: tlsConfiguration,
decompression: .enabled(limit: .none)
)
config.timeout.connect = .seconds(60)
return HTTPClient(configuration: config)
}()
}
@@ -10,7 +10,7 @@ import Foundation
import SwiftyMobileDevice
import ConcurrencyExtras
public actor HeartbeatHandler {
public actor HeartbeatHandler: Sendable {
private struct Error: Swift.Error {}
private struct ReceivedPacket: Decodable {
+1
View File
@@ -130,6 +130,7 @@ public actor Signer {
privBase, lengthOverride ?? priv.count,
entsArray, entsArray.count,
{
// swiftlint:disable:previous opening_brace
(Unmanaged<AnyObject>
.fromOpaque($0)
.takeUnretainedValue()
+1 -1
View File
@@ -47,7 +47,7 @@ private struct UnimplementedSigningInfoManager: SigningInfoManager {
func info(forIdentityID identityID: String) throws -> SigningInfo? {
unimplemented(placeholder: nil)
}
func setInfo(_ info: SigningInfo?, forIdentityID identityID: String) throws {
unimplemented()
}
+1 -1
View File
@@ -21,7 +21,7 @@ struct AuthOperation {
var password: String?
var logoutFromExisting: Bool
var mode: AuthMode?
var mode: AuthMode? = nil
var quiet = false
func run() async throws {
@@ -20,7 +20,6 @@ struct DSCertificatesListCommand: AsyncParsableCommand {
abstract: "List certificates"
)
// swiftlint:disable:next cyclomatic_complexity
func run() async throws {
let client = DeveloperAPIClient(auth: try AuthToken.saved().authData())
@@ -22,7 +22,6 @@ struct DSProfilesListCommand: AsyncParsableCommand {
private static let encoder = JSONEncoder()
// swiftlint:disable:next cyclomatic_complexity
func run() async throws {
let client = DeveloperAPIClient(auth: try AuthToken.saved().authData())
+1
View File
@@ -93,6 +93,7 @@ struct DevXcodeCommand: AsyncParsableCommand {
}
}
struct DevBuildCommand: AsyncParsableCommand {
static let configuration = CommandConfiguration(
commandName: "build",
+1 -1
View File
@@ -8,7 +8,7 @@ struct LaunchCommand: AsyncParsableCommand {
commandName: "launch",
abstract: "Launch an installed app"
)
@OptionGroup var connectionOptions: ConnectionOptions
@Argument(
+3 -4
View File
@@ -21,7 +21,6 @@ struct NewCommand: AsyncParsableCommand {
)
) var skipSetup = false
// swiftlint:disable:next function_body_length
func run() async throws {
if !skipSetup {
// perform any remaining setup steps first
@@ -115,7 +114,7 @@ struct NewCommand: AsyncParsableCommand {
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
/xtool
"""
),
@@ -135,7 +134,7 @@ struct NewCommand: AsyncParsableCommand {
"Sources/\(moduleName)/\(moduleName)App.swift",
"""
import SwiftUI
@main
struct \(moduleName)App: App {
var body: some Scene {
@@ -151,7 +150,7 @@ struct NewCommand: AsyncParsableCommand {
"Sources/\(moduleName)/ContentView.swift",
"""
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
-1
View File
@@ -219,7 +219,6 @@ struct SDKBuilder {
try await tarExit
}
// swiftlint:disable:next cyclomatic_complexity
private func installDeveloper(in output: URL) async throws -> URL {
let dev = output.appendingPathComponent("Developer")
-1
View File
@@ -172,7 +172,6 @@ struct DarwinSDK {
// should be something like
// swiftResourcesPath: /home/user/.swiftpm/swift-sdks/darwin.artifactbundle/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift
// swiftlint:disable:previous line_length
let resourcesPathPrefix = "swiftResourcesPath: "
let outputString = String(decoding: try await outputData, as: UTF8.self)
+3 -3
View File
@@ -42,11 +42,11 @@ struct SetupOperation {
case nil:
let path = try await Console.prompt("""
Now generating the Darwin SDK.
Please download Xcode from http://developer.apple.com/download/all/?q=Xcode
and enter the path to the downloaded Xcode.xip.
Path to Xcode.xip: \("" /* pacify swiftlint trailing_whitespace */)
Path to Xcode.xip:
""")
let expanded = (path as NSString).expandingTildeInPath
+1 -1
View File
@@ -8,7 +8,7 @@ struct UninstallCommand: AsyncParsableCommand {
commandName: "uninstall",
abstract: "Uninstall an installed app"
)
@OptionGroup var connectionOptions: ConnectionOptions
@Argument(
+1 -1
View File
@@ -7,7 +7,7 @@ import Dependencies
@main
enum XToolMain {
static func main() async throws {
prepareDependencies { _ in
prepareDependencies { dependencies in
#warning("Improve persistence mechanism")
// for Windows, we could use dpapi.h or wincred.h.
// for Linux, maybe use libsecret?
@@ -5,10 +5,12 @@ let addMockSigner: () = {
add_signer(
"MockSigner",
{ _, _, _, _, _, _, _, _, _, exception in
// swiftlint:disable:previous opening_brace
exception.initialize(to: strdup("Mock signer not implemented"))
return 1
},
{ _, _, exception in
// swiftlint:disable:previous opening_brace
exception.initialize(to: strdup("Mock analyzer not implemented"))
return nil
}
+1 -17
View File
@@ -1,4 +1,5 @@
GENERATE_INFOPLIST_FILE = YES
CODE_SIGN_ENTITLEMENTS = Support/XToolMac.entitlements
CODE_SIGN_STYLE = Automatic
ENABLE_HARDENED_RUNTIME = YES
@@ -9,20 +10,3 @@ INFOPLIST_KEY_LSApplicationCategoryType = public.app-category.developer-tools
#include? "Private-Team.xcconfig"
#include? "Private.xcconfig"
XTL_IS_EMPTY_ = YES
XTL_COERCE_TO_BOOL_YES = YES
XTL_COERCE_TO_BOOL_ = NO
XTL_INVERT_YES = NO
XTL_INVERT_NO = YES
XTL_HAS_TEAM = $(XTL_INVERT_$(XTL_COERCE_TO_BOOL_$(XTL_IS_EMPTY_$(DEVELOPMENT_TEAM))))
XTL_CODE_SIGN_ENTITLEMENTS_NO = Support/XToolMac-NoTeam.entitlements
XTL_CODE_SIGN_ENTITLEMENTS_YES = Support/XToolMac.entitlements
CODE_SIGN_ENTITLEMENTS = $(XTL_CODE_SIGN_ENTITLEMENTS_$(XTL_HAS_TEAM))
ENABLE_HARDENED_RUNTIME = $(XTL_HAS_TEAM)
XTL_TEAM_DEFINE_YES = -DHAS_TEAM
OTHER_SWIFT_FLAGS = $(inherited) $(XTL_TEAM_DEFINE_$(XTL_HAS_TEAM))
@@ -1,6 +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>
</dict>
</plist>
+2 -4
View File
@@ -15,10 +15,8 @@ import XKit
}
private static func runXTool() async throws {
try await withDependencies { d in
#if HAS_TEAM
d.keyValueStorage = KeychainStorage(service: "sh.xtool.keychain.credentials")
#endif
try await withDependencies {
$0.keyValueStorage = KeychainStorage(service: "sh.xtool.keychain.credentials")
} operation: {
try await XTool.run()
}