mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-21 18:55:56 +03:00
Compare commits
22 Commits
@@ -1,8 +1,9 @@
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build-linux:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -21,13 +22,41 @@ jobs:
|
||||
run: |
|
||||
docker compose run --build --rm xtool -c "Linux/build.sh && mv Linux/packages/xtool{,-${{ matrix.host.arch }}}.AppImage"
|
||||
- name: Upload artifact
|
||||
id: upload_artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: xtool-${{ matrix.host.arch }}
|
||||
path: Linux/packages/xtool-${{ matrix.host.arch }}.AppImage
|
||||
build-mac:
|
||||
runs-on: macos-15
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
working-directory: macOS
|
||||
bundler-cache: true
|
||||
- name: Build
|
||||
env:
|
||||
APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY_ID }}
|
||||
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
|
||||
APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY }}
|
||||
IDENTITY_P12: ${{ secrets.IDENTITY_P12 }}
|
||||
DEVELOPMENT_TEAM: ${{ secrets.DEVELOPMENT_TEAM }}
|
||||
run: |
|
||||
cd macOS
|
||||
bundle exec fastlane package
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: xtool-mac
|
||||
path: |
|
||||
macOS/Build/Output/xtool.app.zip
|
||||
macOS/Build/Output/xtool.app.dSYM.zip
|
||||
release:
|
||||
needs: build
|
||||
needs: [build-linux, build-mac]
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -36,14 +65,12 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download artifact
|
||||
id: download_artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: xtool-*
|
||||
path: output
|
||||
- name: Create and publish release
|
||||
id: publish_release
|
||||
run: |
|
||||
TAG="${GITHUB_REF##*/}-${GITHUB_SHA:0:7}"
|
||||
gh release create "$TAG" --draft --title "Draft Release"
|
||||
gh release upload "$TAG" output/**/*.AppImage
|
||||
gh release upload "$TAG" output/**/*.{AppImage,app.zip,app.dSYM.zip}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
# Note: We use 20.04 since AppImage recommends building on the
|
||||
# Note: We use 22.04 since AppImage recommends building on the
|
||||
# oldest configuration that you support
|
||||
|
||||
FROM swift:6.1-focal AS build-base
|
||||
FROM swift:6.1-jammy 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 and macOS.
|
||||
Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, 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)](https://swiftpackageindex.com/xtool-org/xtool/documentation/xtool/installation-linux)
|
||||
- [Installation (Linux/Windows)](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)!
|
||||
|
||||
|
||||
@@ -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,8 +101,12 @@ 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)
|
||||
}
|
||||
@@ -122,7 +126,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
|
||||
|
||||
@@ -79,7 +79,7 @@ struct NewCommand: AsyncParsableCommand {
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
// An xtool project should contain exactly one library target,
|
||||
// An xtool project should contain exactly one library product,
|
||||
// representing the main app.
|
||||
.library(
|
||||
name: "\(moduleName)",
|
||||
@@ -116,7 +116,6 @@ struct NewCommand: AsyncParsableCommand {
|
||||
.netrc
|
||||
|
||||
/xtool
|
||||
/.sourcekit-lsp
|
||||
"""
|
||||
),
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ 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,7 +25,9 @@ struct SetupOperation {
|
||||
try await AuthOperation(logoutFromExisting: false, quiet: quiet).run()
|
||||
|
||||
#if os(macOS)
|
||||
print("Skipping Darwin SDK setup since we're on macOS.")
|
||||
if !quiet {
|
||||
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") {
|
||||
Once you've completed <doc:Installation-Linux>, use xtool to build and deploy an iOS app from your Linux machine.
|
||||
@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.
|
||||
}
|
||||
|
||||
@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).
|
||||
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).
|
||||
|
||||
@Image(source: "SwiftExtension", alt: "Swift extension for VSCode")
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
# Installation (Linux)
|
||||
# Installation (Linux/Windows)
|
||||
|
||||
Set up xtool for iOS app development on Linux.
|
||||
Set up xtool for iOS app development on Linux or Windows.
|
||||
|
||||
## Overview
|
||||
|
||||
This article outlines the steps to install `xtool` and begin developing iOS apps on Linux.
|
||||
This article outlines the steps to install `xtool` and begin developing iOS apps on Linux (or Windows via WSL).
|
||||
|
||||
## 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,13 +9,9 @@ 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()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/XToolMac.xcodeproj
|
||||
Private*.xcconfig
|
||||
|
||||
/fastlane/README.md
|
||||
/fastlane/report.xml
|
||||
/Build
|
||||
/Private
|
||||
@@ -0,0 +1 @@
|
||||
3.4.3
|
||||
@@ -0,0 +1,9 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'fastlane'
|
||||
gem 'fastlane-plugin-xcodegen'
|
||||
|
||||
# https://github.com/fastlane/fastlane/issues/29183#issuecomment-2567093826
|
||||
gem "abbrev"
|
||||
gem "mutex_m"
|
||||
gem "ostruct"
|
||||
@@ -0,0 +1,236 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (3.0.7)
|
||||
base64
|
||||
nkf
|
||||
rexml
|
||||
abbrev (0.1.2)
|
||||
addressable (2.8.7)
|
||||
public_suffix (>= 2.0.2, < 7.0)
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.3.2)
|
||||
aws-partitions (1.1102.0)
|
||||
aws-sdk-core (3.223.0)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
base64
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
logger
|
||||
aws-sdk-kms (1.100.0)
|
||||
aws-sdk-core (~> 3, >= 3.216.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.185.0)
|
||||
aws-sdk-core (~> 3, >= 3.216.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.11.0)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
base64 (0.2.0)
|
||||
claide (1.1.0)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander (4.6.0)
|
||||
highline (~> 2.0.0)
|
||||
declarative (0.0.20)
|
||||
digest-crc (0.7.0)
|
||||
rake (>= 12.0.0, < 14.0.0)
|
||||
domain_name (0.6.20240107)
|
||||
dotenv (2.8.1)
|
||||
emoji_regex (3.2.3)
|
||||
excon (0.112.0)
|
||||
faraday (1.10.4)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.0)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
faraday-retry (~> 1.0)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-cookie_jar (0.0.7)
|
||||
faraday (>= 0.8.0)
|
||||
http-cookie (~> 1.0.0)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.1.0)
|
||||
multipart-post (~> 2.0)
|
||||
faraday-net_http (1.0.2)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.3)
|
||||
faraday_middleware (1.2.1)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.4.0)
|
||||
fastlane (2.227.2)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
aws-sdk-s3 (~> 1.0)
|
||||
babosa (>= 1.0.3, < 2.0.0)
|
||||
bundler (>= 1.12.0, < 3.0.0)
|
||||
colored (~> 1.2)
|
||||
commander (~> 4.6)
|
||||
dotenv (>= 2.1.1, < 3.0.0)
|
||||
emoji_regex (>= 0.1, < 4.0)
|
||||
excon (>= 0.71.0, < 1.0.0)
|
||||
faraday (~> 1.0)
|
||||
faraday-cookie_jar (~> 0.0.6)
|
||||
faraday_middleware (~> 1.0)
|
||||
fastimage (>= 2.1.0, < 3.0.0)
|
||||
fastlane-sirp (>= 1.0.0)
|
||||
gh_inspector (>= 1.1.2, < 2.0.0)
|
||||
google-apis-androidpublisher_v3 (~> 0.3)
|
||||
google-apis-playcustomapp_v1 (~> 0.1)
|
||||
google-cloud-env (>= 1.6.0, < 2.0.0)
|
||||
google-cloud-storage (~> 1.31)
|
||||
highline (~> 2.0)
|
||||
http-cookie (~> 1.0.5)
|
||||
json (< 3.0.0)
|
||||
jwt (>= 2.1.0, < 3)
|
||||
mini_magick (>= 4.9.4, < 5.0.0)
|
||||
multipart-post (>= 2.0.0, < 3.0.0)
|
||||
naturally (~> 2.2)
|
||||
optparse (>= 0.1.1, < 1.0.0)
|
||||
plist (>= 3.1.0, < 4.0.0)
|
||||
rubyzip (>= 2.0.0, < 3.0.0)
|
||||
security (= 0.1.5)
|
||||
simctl (~> 1.6.3)
|
||||
terminal-notifier (>= 2.0.0, < 3.0.0)
|
||||
terminal-table (~> 3)
|
||||
tty-screen (>= 0.6.3, < 1.0.0)
|
||||
tty-spinner (>= 0.8.0, < 1.0.0)
|
||||
word_wrap (~> 1.0.0)
|
||||
xcodeproj (>= 1.13.0, < 2.0.0)
|
||||
xcpretty (~> 0.4.1)
|
||||
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
|
||||
fastlane-plugin-brew (0.1.1)
|
||||
fastlane-plugin-xcodegen (1.1.0)
|
||||
fastlane-plugin-brew (~> 0.1.1)
|
||||
fastlane-sirp (1.0.0)
|
||||
sysrandom (~> 1.0)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.54.0)
|
||||
google-apis-core (>= 0.11.0, < 2.a)
|
||||
google-apis-core (0.11.3)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
googleauth (>= 0.16.2, < 2.a)
|
||||
httpclient (>= 2.8.1, < 3.a)
|
||||
mini_mime (~> 1.0)
|
||||
representable (~> 3.0)
|
||||
retriable (>= 2.0, < 4.a)
|
||||
rexml
|
||||
google-apis-iamcredentials_v1 (0.17.0)
|
||||
google-apis-core (>= 0.11.0, < 2.a)
|
||||
google-apis-playcustomapp_v1 (0.13.0)
|
||||
google-apis-core (>= 0.11.0, < 2.a)
|
||||
google-apis-storage_v1 (0.31.0)
|
||||
google-apis-core (>= 0.11.0, < 2.a)
|
||||
google-cloud-core (1.8.0)
|
||||
google-cloud-env (>= 1.0, < 3.a)
|
||||
google-cloud-errors (~> 1.0)
|
||||
google-cloud-env (1.6.0)
|
||||
faraday (>= 0.17.3, < 3.0)
|
||||
google-cloud-errors (1.5.0)
|
||||
google-cloud-storage (1.47.0)
|
||||
addressable (~> 2.8)
|
||||
digest-crc (~> 0.4)
|
||||
google-apis-iamcredentials_v1 (~> 0.1)
|
||||
google-apis-storage_v1 (~> 0.31.0)
|
||||
google-cloud-core (~> 1.6)
|
||||
googleauth (>= 0.16.2, < 2.a)
|
||||
mini_mime (~> 1.0)
|
||||
googleauth (1.8.1)
|
||||
faraday (>= 0.17.3, < 3.a)
|
||||
jwt (>= 1.4, < 3.0)
|
||||
multi_json (~> 1.11)
|
||||
os (>= 0.9, < 2.0)
|
||||
signet (>= 0.16, < 2.a)
|
||||
highline (2.0.3)
|
||||
http-cookie (1.0.8)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
jmespath (1.6.2)
|
||||
json (2.11.3)
|
||||
jwt (2.10.1)
|
||||
base64
|
||||
logger (1.7.0)
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.15.0)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
naturally (2.2.1)
|
||||
nkf (0.2.0)
|
||||
optparse (0.6.0)
|
||||
os (1.1.4)
|
||||
ostruct (0.6.1)
|
||||
plist (3.7.2)
|
||||
public_suffix (6.0.2)
|
||||
rake (13.2.1)
|
||||
representable (3.2.0)
|
||||
declarative (< 0.1.0)
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
uber (< 0.2.0)
|
||||
retriable (3.1.2)
|
||||
rexml (3.4.1)
|
||||
rouge (3.28.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.4.1)
|
||||
security (0.1.5)
|
||||
signet (0.20.0)
|
||||
addressable (~> 2.8)
|
||||
faraday (>= 0.17.5, < 3.a)
|
||||
jwt (>= 1.5, < 3.0)
|
||||
multi_json (~> 1.10)
|
||||
simctl (1.6.10)
|
||||
CFPropertyList
|
||||
naturally
|
||||
sysrandom (1.0.5)
|
||||
terminal-notifier (2.0.0)
|
||||
terminal-table (3.0.2)
|
||||
unicode-display_width (>= 1.1.1, < 3)
|
||||
trailblazer-option (0.1.2)
|
||||
tty-cursor (0.7.1)
|
||||
tty-screen (0.8.2)
|
||||
tty-spinner (0.9.3)
|
||||
tty-cursor (~> 0.7)
|
||||
uber (0.1.0)
|
||||
unicode-display_width (2.6.0)
|
||||
word_wrap (1.0.0)
|
||||
xcodeproj (1.27.0)
|
||||
CFPropertyList (>= 2.3.3, < 4.0)
|
||||
atomos (~> 0.1.3)
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
nanaimo (~> 0.4.0)
|
||||
rexml (>= 3.3.6, < 4.0)
|
||||
xcpretty (0.4.1)
|
||||
rouge (~> 3.28.0)
|
||||
xcpretty-travis-formatter (1.0.1)
|
||||
xcpretty (~> 0.2, >= 0.0.7)
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin-24
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
abbrev
|
||||
fastlane
|
||||
fastlane-plugin-xcodegen
|
||||
mutex_m
|
||||
ostruct
|
||||
|
||||
BUNDLED WITH
|
||||
2.6.7
|
||||
@@ -0,0 +1,11 @@
|
||||
# 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
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/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" "$@"
|
||||
@@ -0,0 +1,9 @@
|
||||
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"
|
||||
@@ -0,0 +1 @@
|
||||
#include "Base.xcconfig"
|
||||
@@ -0,0 +1 @@
|
||||
#include "Base.xcconfig"
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,24 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
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()
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
app_identifier("sh.xtool.XToolMac")
|
||||
@@ -0,0 +1,66 @@
|
||||
default_platform(:mac)
|
||||
|
||||
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "120"
|
||||
|
||||
lane :package do
|
||||
xcodegen
|
||||
|
||||
# Config is controlled via env vars
|
||||
app_store_connect_api_key(
|
||||
is_key_content_base64: true,
|
||||
)
|
||||
|
||||
create_keychain(
|
||||
name: "xtool.keychain",
|
||||
password: "",
|
||||
unlock: true,
|
||||
)
|
||||
|
||||
unlock_keychain(
|
||||
path: "xtool.keychain",
|
||||
password: "",
|
||||
)
|
||||
|
||||
Tempfile.create(["Identity", ".p12"]) do |file|
|
||||
file.write(Base64.decode64(ENV["IDENTITY_P12"]))
|
||||
file.close
|
||||
import_certificate(
|
||||
certificate_path: file.path,
|
||||
keychain_name: "xtool.keychain",
|
||||
keychain_password: "",
|
||||
)
|
||||
end
|
||||
|
||||
sigh(
|
||||
platform: "macos",
|
||||
output_path: "./Build/Signing",
|
||||
force: true,
|
||||
developer_id: true,
|
||||
)
|
||||
|
||||
update_code_signing_settings(
|
||||
use_automatic_signing: false,
|
||||
team_id: ENV["DEVELOPMENT_TEAM"],
|
||||
code_sign_identity: "Developer ID Application",
|
||||
profile_name: lane_context[SharedValues::SIGH_NAME],
|
||||
)
|
||||
|
||||
gym(
|
||||
export_method: "developer-id",
|
||||
output_directory: "./Build/Output",
|
||||
)
|
||||
|
||||
notarize(
|
||||
package: "./Build/Output/xtool.app",
|
||||
)
|
||||
|
||||
# we need to re-package after notarization and stapling.
|
||||
# we have to use `ditto --sequesterRsrc` rather than zip
|
||||
# because the default strategy stores resource forks as
|
||||
# ._Foo but codesigning doesn't like that, and instead
|
||||
# wants them in __MACOSX.
|
||||
sh(
|
||||
"ditto", "-c", "-k", "--keepParent", "--sequesterRsrc",
|
||||
"../Build/Output/xtool.app", "../Build/Output/xtool.app.zip",
|
||||
)
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
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