Compare commits

...

177 Commits

250 changed files with 16486 additions and 11948 deletions
+37
View File
@@ -0,0 +1,37 @@
---
name: Bug report
about: Report a bug
title: ''
labels: bug
assignees: ''
---
## Description
A clear and concise description of what the bug is.
## Environment
Please provide as much of the following information as is relevant.
Host OS (macOS/Linux/WSL):
Host OS version:
<!-- macOS: Apple Logo > About this Mac -->
<!-- Linux: -->
<!-- cat /etc/*-release -->
<!-- Windows: -->
<!-- Get-WinVer; wsl -l -v -->
iOS device version:
<!-- Settings > General > About > iOS Version -->
Swift version:
<!-- swift --version -->
SDK version:
<!-- macOS: -->
<!-- xcodebuild -version; xcrun -sdk iphoneos -show-sdk-version -->
<!-- Linux/WSL: -->
<!-- swift sdk configure darwin arm64-apple-ios --show-configuration | grep -o 'iPhoneOS[0-9.]*\.sdk$' -->
+10
View File
@@ -0,0 +1,10 @@
---
name: Feature request
about: Suggest an idea
title: ''
labels: enhancement
assignees: ''
---
-20
View File
@@ -1,20 +0,0 @@
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
docker compose run --build --rm supersign -c Linux/build.sh
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
files: |
Linux/packages/Supersign.AppImage
+39
View File
@@ -0,0 +1,39 @@
on:
- push
jobs:
build-linux:
strategy:
fail-fast: false
matrix:
host:
- runner: ubuntu-24.04
arch: x86_64
- runner: ubuntu-24.04-arm
arch: aarch64
runs-on: ${{ matrix.host.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
docker compose run --build --rm xtool swift build --product xtool
build-macos:
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
swift build --product xtool
build-ios:
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
set -o pipefail \
&& xcodebuild build \
-skipMacroValidation -skipPackagePluginValidation \
-scheme XKit -destination generic/platform=iOS \
| xcbeautify
+82
View File
@@ -0,0 +1,82 @@
on:
push:
tags:
- "*"
jobs:
build-linux:
strategy:
fail-fast: false
matrix:
host:
- runner: ubuntu-24.04
arch: x86_64
- runner: ubuntu-24.04-arm
arch: aarch64
runs-on: ${{ matrix.host.runner }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
docker compose run --build \
-e XTOOL_VERSION=${{ github.ref_name }} \
--rm xtool Linux/build.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: xtool-${{ matrix.host.arch }}
path: |
Linux/packages/xtool-${{ matrix.host.arch }}.AppImage
Linux/packages/xtool-${{ matrix.host.arch }}.AppImage.zsync
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 }}
XTOOL_VERSION: ${{ github.ref_name }}
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-linux, build-mac]
runs-on: ubuntu-24.04
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: xtool-*
path: output
- name: Create and publish release
run: |
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}
+4 -3
View File
@@ -1,5 +1,5 @@
/Tests/SupersignTests/config/*
!/Tests/SupersignTests/config/config-template.json
/Tests/XKitTests/config/*
!/Tests/XKitTests/config/config-template.json
*.ipa
.DS_Store
/.build
@@ -9,5 +9,6 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
.docc-build
/openapi.json
/openapi
@@ -1,67 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Supersign"
BuildableName = "Supersign"
BlueprintName = "Supersign"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Supersign"
BuildableName = "Supersign"
BlueprintName = "Supersign"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+128
View File
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
conduct@xtool.sh.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
+31
View File
@@ -0,0 +1,31 @@
# Contributing to xtool
## Bug reports and feature requests
We welcome all bug reports and feature requests! Please create a [new issue](https://github.com/xtool-org/xtool/issues/new/choose) via GitHub.
## Documentation
The xtool documentation at <https://xtool.sh> is built with [swift-docc](https://github.com/swiftlang/swift-docc) and resides at [Documentation/xtool.docc](/Documentation/xtool.docc). It's hosted on Netlify, the configuration for which is in [netlify.toml](/netlify.toml).
When editing the DocC bundle, you can preview it with `make docs-preview`.
Once you make a pull request with your changes, we'll also generate a [Netlify Deploy Preview](https://docs.netlify.com/site-deploys/deploy-previews/) under your pull request. You can open this preview to see how the changes will look in production.
## Code
When making code changes, please make sure to test them on both macOS and Linux if possible. If you can also test on Windows with WSL, that is ideal.
To build xtool for debugging, run `make` in the project directory. There are a few considerations depending on your host OS:
### macOS
On macOS, you'll firstly need to have Xcode set up.
The first time you run `make`, we'll try to detect your codesigning identity. If you have multiple, you'll see an interactive prompt to select the team you want to use. The team ID is saved to `./macOS/Support/Private-Team.xcconfig`. You can run `make team` to update it (or do so by hand).
After building, a symlink to the product will be created at `./macOS/Build/xtool`. We generate an Xcode project at `./macOS/XToolMac.xcodeproj` that you can open in order to work in Xcode.
### Linux
You need to have a few dependencies on Linux; see [Dockerfile](/Dockerfile) for specifics. It's often easiest to develop within Docker itself: see [Linux/README.md](/Linux/README.md) for details.
+44 -49
View File
@@ -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 ubuntu:focal AS limd-build
FROM swift:6.1-jammy AS build-base
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
@@ -16,78 +16,73 @@ RUN apt-get update \
pkg-config \
libxml2 \
curl libcurl4-openssl-dev \
zip unzip \
liblzma-dev zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /prefix
RUN curl -fsS https://dlang.org/install.sh | bash -s ldc
FROM build-base AS build-limd
RUN git clone https://github.com/libimobiledevice/libplist.git \
&& cd libplist \
RUN mkdir -p /prefix
ADD --keep-git-dir=true https://github.com/libimobiledevice/libplist.git#2.6.0 /libplist
RUN cd libplist \
&& ./autogen.sh --prefix /usr --without-cython \
&& make \
&& make install \
&& make install DESTDIR=/prefix \
&& cd .. \
&& rm -rf libplist
&& make install DESTDIR=/prefix
RUN git clone https://github.com/libimobiledevice/libimobiledevice-glue.git \
&& cd libimobiledevice-glue \
ADD --keep-git-dir=true https://github.com/libimobiledevice/libimobiledevice-glue.git#1.3.1 /libimobiledevice-glue
RUN cd libimobiledevice-glue \
&& ./autogen.sh --prefix /usr \
&& make \
&& make install \
&& make install DESTDIR=/prefix \
&& cd .. \
&& rm -rf libimobiledevice-glue
&& make install DESTDIR=/prefix
RUN git clone https://github.com/libimobiledevice/libusbmuxd.git \
&& cd libusbmuxd \
ADD --keep-git-dir=true https://github.com/libimobiledevice/libusbmuxd.git#2.1.0 /libusbmuxd
RUN cd libusbmuxd \
&& ./autogen.sh --prefix /usr \
&& make \
&& make install \
&& make install DESTDIR=/prefix \
&& cd .. \
&& rm -rf libusbmuxd
&& make install DESTDIR=/prefix
RUN git clone https://github.com/libimobiledevice/libtatsu.git \
&& cd libtatsu \
ADD --keep-git-dir=true https://github.com/libimobiledevice/libtatsu.git#1.0.4 /libtatsu
RUN cd libtatsu \
&& ./autogen.sh --prefix /usr \
&& make \
&& make install \
&& make install DESTDIR=/prefix \
&& cd .. \
&& rm -rf libtatsu
&& make install DESTDIR=/prefix
RUN git clone https://github.com/libimobiledevice/libimobiledevice.git \
&& cd libimobiledevice \
&& ./autogen.sh --prefix /usr --without-cython --enable-debug \
ADD --keep-git-dir=true https://github.com/libimobiledevice/libimobiledevice.git#master /libimobiledevice
RUN cd libimobiledevice \
&& ./autogen.sh --prefix /usr --without-cython \
&& make \
&& make install \
&& make install DESTDIR=/prefix \
&& cd .. \
&& rm -rf libimobiledevice
&& make install DESTDIR=/prefix
ADD https://api.github.com/repos/SuperchargeApp/SupersetteD/git/refs/heads/main Supersette-version.json
RUN git clone https://github.com/SuperchargeApp/SupersetteD.git \
&& cd SupersetteD \
FROM build-base AS build-xadi
RUN mkdir -p /prefix/usr/lib
RUN curl -fsS https://dlang.org/install.sh | bash -s ldc
ADD https://github.com/xtool-org/xadi.git#main /xadi
RUN cd xadi \
&& /bin/bash -c 'source $(/root/dlang/install.sh ldc -a) && dub build --build=release' \
&& cp -r bin/libsupersette.so /prefix/usr/lib/libsupersette.so \
&& cd .. \
&& rm -rf SupersetteD
FROM swift:6.0-focal
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
libssl-dev \
ca-certificates \
zip unzip \
&& rm -rf /var/lib/apt/lists/*
&& cp -r bin/libxadi.so /prefix/usr/lib/libxadi.so
COPY --from=limd-build /prefix/usr /usr
FROM build-base
COPY --from=build-limd /prefix/usr /usr
COPY --from=build-xadi /prefix/usr /usr
# Docker doesn't support FUSE
ENV APPIMAGE_EXTRACT_AND_RUN=1
@@ -97,6 +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 /Supersign
WORKDIR /xtool
ENTRYPOINT [ "/bin/bash" ]
CMD [ "/bin/bash" ]
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
rm -rf docs
if type -p xcrun &>/dev/null; then
docc="$(xcrun -f docc)"
else
docc="docc"
fi
if [[ $# == 0 ]]; then
command="convert"
elif [[ $# == 1 && ( "$1" == "preview" || "$1" == "convert" ) ]]; then
command="$1"
else
echo "Usage: $0 [convert|preview]"
exit 1
fi
"$docc" "$command" xtool.docc \
--experimental-enable-custom-templates
+109
View File
@@ -0,0 +1,109 @@
# Control your app's structure
Add resources, modify your `Info.plist`, and more.
## Overview
When building your app, xtool provides many knobs to add resources and modify files in its `.app` bundle. This article explains how to perform some common tasks along these lines.
Many of the tasks here involve modifying the `xtool.yml` file. The default `xtool new` template should generate this file for you. If you don't have it, make sure you create one first.
```bash
cat > xtool.yml << EOF
version: 1
bundleID: com.example.Hello
EOF
```
## Change your bundle ID
You can update your app's bundle ID by editing the `bundleID` field in `xtool.yml`.
> Note:
>
> xtool adds a prefix to your bundle ID when signing and installing the app on a real device. For example, it may update the above bundle id to `XTL-1234.com.example.Hello`. This is because, at least with free accounts (those not enrolled in the Apple Developer Program), two accounts cannot use the same bundle ID. Prefixing ensures that if you share your app with someone else, they won't run into a bundle ID conflict when installing it.
>
> With additional engineering effort, this limitation could be lifted for paid Developer Program users by leveraging wildcard provisioning profiles. If you have a concrete use case for this and/or wish to contribute, please [file an issue](https://github.com/xtool-org/xtool/issues/new).
## Customize Info.plist
xtool automatically generates a bare-bones `Info.plist` file for you. However, you may need to add new `Info.plist` keys or edit existing ones.
To do this, create an `Info.plist` file in your project containing just the keys you want to add/update, and tell xtool about it by adding the `infoPath` key:
```yaml
infoPath: path/to/Info.plist
```
> Tip:
>
> After running `xtool dev [build]`, you can inspect the built app bundle at `./xtool/YourApp.app` to view its `Info.plist` and other resources.
For example, you might create an `Info.plist` file that looks something like
```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>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleDisplayName</key>
<string>My App</string>
</dict>
</plist>
```
- The default `Info.plist` has a `UISupportedInterfaceOrientations` value of portrait. This will replace it with landscape-only.
- We don't include a `CFBundleDisplayName` by default, so this will add the key and specify a display name of "My App".
## Copy resources (SwiftPM)
If you need to include non-code resource files, like images, the easiest way to do so is to use [SwiftPM Resources](https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package). These "just work" with xtool.
For example, if you have `Sources/Hello/Blob.png`, you can include it in your app by updating the `targets` in your `Package.swift` to
```swift
targets: [
.target(
name: "Hello",
resources: [.copy("Blob.png")]
),
]
```
Then, to draw it on screen, you can use
```swift
Image("Blob", bundle: Bundle.module)
```
## Copy resources (top level)
SwiftPM resources are copied into `.bundle` directories nested inside your `.app`. Sometimes, you need to place a file in a specific location in the app directory instead.
To achieve this, you can include a `resources` array in your `xtool.yml` containing a list of files that should be directly included at the root level of the app bundle.
For example, if you use Firebase, you usually need to include a [`GoogleServices-Info.plist`](https://firebase.google.com/docs/ios/setup#add-config-file) file in your root bundle. If you saved this file in your project directory at `./Resources/GoogleServices-Info.plist`, you can update your `xtool.yml` with
```yaml
resources:
- Resources/GoogleServices-Info.plist
```
The file will be copied to `Hello.app/GoogleServices-Info.plist`.
## Add an app icon
Say your app icon is saved at `Resources/AppIcon.png`. You can make this your app icon by setting the `iconPath` key in `xtool.yml`:
```yaml
iconPath: Resources/AppIcon.png
```
> Tip:
>
> Your app icon must be a png, and it should ideally have a resolution of 1024x1024px.
@@ -0,0 +1,5 @@
Hello$
Planning...
Building for debugging...
[8/8] Linking Hello-App
Build of product 'Hello-App' complete! (4.94s)
@@ -0,0 +1,5 @@
Hello$ xtool dev
Planning...
Building for debugging...
[8/8] Linking Hello-App
Build of product 'Hello-App' complete! (4.94s)
@@ -0,0 +1,6 @@
Hello$ xtool dev
Planning...
Building for debugging...
[8/8] Linking Hello-App
Build of product 'Hello-App' complete! (4.94s)
Waiting for device to be connected...
@@ -0,0 +1,17 @@
Hello$ xtool dev
Planning...
Building for debugging...
[8/8] Linking Hello-App
Build of product 'Hello-App' complete! (4.94s)
Waiting for device to be connected...
Installing to device: Kabir's iPhone (udid: *****)
[Unpacking app] 100%
[Logging in] 100%
[Preparing device] 100%
[Provisioning] 100%
[Signing] 100%
[Packaging] 100%
[Connecting] 100%
[Installing] 100%
[Verifying] 100%
@@ -0,0 +1,13 @@
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
@@ -0,0 +1,15 @@
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
.bold()
.foregroundStyle(.purple)
}
.padding()
}
}
@@ -0,0 +1,17 @@
Hello$
Planning...
Building for debugging...
[8/8] Linking Hello-App
Build of product 'Hello-App' complete! (5s)
Waiting for device to be connected...
Installing to device: Kabir's iPhone (udid: *****)
[Unpacking app] 100%
[Logging in] 100%
[Preparing device] 100%
[Provisioning] 100%
[Signing] 100%
[Packaging] 100%
[Connecting] 100%
[Installing] 100%
[Verifying] 100%
@@ -0,0 +1,17 @@
Hello$ xtool dev
Planning...
Building for debugging...
[8/8] Linking Hello-App
Build of product 'Hello-App' complete! (5s)
Waiting for device to be connected...
Installing to device: Kabir's iPhone (udid: *****)
[Unpacking app] 100%
[Logging in] 100%
[Preparing device] 100%
[Provisioning] 100%
[Signing] 100%
[Packaging] 100%
[Connecting] 100%
[Installing] 100%
[Verifying] 100%
@@ -0,0 +1,17 @@
Hello$ xtool dev
Planning...
Building for debugging...
[8/8] Linking Hello-App
Build of product 'Hello-App' complete! (5s)
Waiting for device to be connected...
Installing to device: Kabir's iPhone (udid: *****)
[Unpacking app] 100%
[Logging in] 100%
[Preparing device] 100%
[Provisioning] 100%
[Signing] 100%
[Packaging] 100%
[Connecting] 100%
[Installing] 100%
[Verifying] 100%
@@ -0,0 +1,10 @@
Developer$
Creating package: Hello
Creating Package.swift
Creating xtool.yml
Creating .gitignore
Creating .sourcekit-lsp/config.json
Creating Sources/Hello/HelloApp.swift
Creating Sources/Hello/ContentView.swift
Finished generating project Hello.
@@ -0,0 +1,10 @@
Developer$ xtool new Hello
Creating package: Hello
Creating Package.swift
Creating xtool.yml
Creating .gitignore
Creating .sourcekit-lsp/config.json
Creating Sources/Hello/HelloApp.swift
Creating Sources/Hello/ContentView.swift
Finished generating project Hello.
@@ -0,0 +1,18 @@
Developer$ xtool new Hello
Creating package: Hello
Creating Package.swift
Creating xtool.yml
Creating .gitignore
Creating .sourcekit-lsp/config.json
Creating Sources/Hello/HelloApp.swift
Creating Sources/Hello/ContentView.swift
Finished generating project Hello.
Developer$
Hello$
-rw-rw-r-- 1 user user 187 .gitignore
drwxrwxr-x 2 user user 4096 .sourcekit-lsp
-rw-rw-r-- 1 user user 463 Package.swift
drwxrwxr-x 3 user user 4096 Sources
-rw-rw-r-- 1 user user 39 xtool.yml
@@ -0,0 +1,18 @@
Developer$ xtool new Hello
Creating package: Hello
Creating Package.swift
Creating xtool.yml
Creating .gitignore
Creating .sourcekit-lsp/config.json
Creating Sources/Hello/HelloApp.swift
Creating Sources/Hello/ContentView.swift
Finished generating project Hello.
Developer$ cd Hello
Hello$ ls -la
-rw-rw-r-- 1 user user 187 .gitignore
drwxrwxr-x 2 user user 4096 .sourcekit-lsp
-rw-rw-r-- 1 user user 463 Package.swift
drwxrwxr-x 3 user user 4096 Sources
-rw-rw-r-- 1 user user 39 xtool.yml
@@ -0,0 +1,22 @@
Developer$ xtool new Hello
Creating package: Hello
Creating Package.swift
Creating xtool.yml
Creating .gitignore
Creating .sourcekit-lsp/config.json
Creating Sources/Hello/HelloApp.swift
Creating Sources/Hello/ContentView.swift
Finished generating project Hello.
Developer$ cd Hello
Hello$ ls -la
-rw-rw-r-- 1 user user 187 .gitignore
drwxrwxr-x 2 user user 4096 .sourcekit-lsp
-rw-rw-r-- 1 user user 463 Package.swift
drwxrwxr-x 3 user user 4096 Sources
-rw-rw-r-- 1 user user 39 xtool.yml
Hello$
version: 1
bundleID: com.example.Hello
@@ -0,0 +1,22 @@
Developer$ xtool new Hello
Creating package: Hello
Creating Package.swift
Creating xtool.yml
Creating .gitignore
Creating .sourcekit-lsp/config.json
Creating Sources/Hello/HelloApp.swift
Creating Sources/Hello/ContentView.swift
Finished generating project Hello.
Developer$ cd Hello
Hello$ ls -la
-rw-rw-r-- 1 user user 187 .gitignore
drwxrwxr-x 2 user user 4096 .sourcekit-lsp
-rw-rw-r-- 1 user user 463 Package.swift
drwxrwxr-x 3 user user 4096 Sources
-rw-rw-r-- 1 user user 39 xtool.yml
Hello$ cat xtool.yml
version: 1
bundleID: com.example.Hello
@@ -0,0 +1,25 @@
Developer$ xtool new Hello
Creating package: Hello
Creating Package.swift
Creating xtool.yml
Creating .gitignore
Creating .sourcekit-lsp/config.json
Creating Sources/Hello/HelloApp.swift
Creating Sources/Hello/ContentView.swift
Finished generating project Hello.
Developer$ cd Hello
Hello$ ls -la
-rw-rw-r-- 1 user user 187 .gitignore
drwxrwxr-x 2 user user 4096 .sourcekit-lsp
-rw-rw-r-- 1 user user 463 Package.swift
drwxrwxr-x 3 user user 4096 Sources
-rw-rw-r-- 1 user user 39 xtool.yml
Hello$ cat xtool.yml
version: 1
bundleID: com.example.Hello
Hello$
{ "swiftPM": { "swiftSDK": "arm64-apple-ios" } }
@@ -0,0 +1,25 @@
Developer$ xtool new Hello
Creating package: Hello
Creating Package.swift
Creating xtool.yml
Creating .gitignore
Creating .sourcekit-lsp/config.json
Creating Sources/Hello/HelloApp.swift
Creating Sources/Hello/ContentView.swift
Finished generating project Hello.
Developer$ cd Hello
Hello$ ls -la
-rw-rw-r-- 1 user user 187 .gitignore
drwxrwxr-x 2 user user 4096 .sourcekit-lsp
-rw-rw-r-- 1 user user 463 Package.swift
drwxrwxr-x 3 user user 4096 Sources
-rw-rw-r-- 1 user user 39 xtool.yml
Hello$ cat xtool.yml
version: 1
bundleID: com.example.Hello
Hello$ cat .sourcekit-lsp/config.json
{ "swiftPM": { "swiftSDK": "arm64-apple-ios" } }
+161
View File
@@ -0,0 +1,161 @@
@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.
}
@Section(title: "Create an xtool project") {
We'll start by creating a project from xtool's default template.
@Steps {
@Step {
xtool comes with a template for iOS-capable Swift Packages. Run `xtool new` to create a new package.
@Code(name: "Terminal", file: "template-1b.sh", previousFile: "template-1a.sh") {}
}
@Step {
At this point, feel free to poke around.
Observe that the package is structured a lot like a regular SwiftPM library, with a few extra files.
@Code(name: "Terminal", file: "template-2b.sh", previousFile: "template-2a.sh") {}
}
@Step {
Read `xtool.yml`.
This file describes how to bundle the Swift library into an iOS app. At minimum, you need to provide a Bundle ID. This defaults to `com.example.<PackageName>`, in this case `com.example.Hello`.
@Code(name: "Terminal", file: "template-3b.sh", previousFile: "template-3a.sh") {}
}
@Step {
Read `.sourcekit-lsp/config.json`.
This file tells SourceKit to build for the `arm64-apple-ios` system defined in `darwin.artifactbundle`. This is the [Swift SDK](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md) that we built during the setup process. It contains the necessary modules for building iOS apps, such as UIKit and SwiftUI, as well as tools for building and manipulating iOS binaries. Under the hood, xtool also calls `swift build` with `--swift-sdk arm64-apple-ios` for the same reason.
@Code(name: "Terminal", file: "template-4b.sh", previousFile: "template-4a.sh") {}
}
}
}
@Section(title: "Build and run") {
Now that we have a skeleton project, let's get it running on your device.
@Steps {
@Step {
From inside the package directory, run `xtool dev`.
The first time you run this, SwiftPM might take a few minutes to build the app. This is because it needs to build the Swift Modules for the iOS SDK. Subsequent runs should be a lot faster since SwiftPM caches these modules globally.
@Code(name: "Terminal", file: "build-1b.sh", previousFile: "build-1a.sh")
}
@Step {
After the build is complete, xtool will attempt to install it on your device.
At this point, connect your iOS device to your computer via USB. If you installed `libimobiledevice-utils` during setup, you can verify that your device is connected by running `ideviceinfo`. xtool will continue after automatically detecting that your device is connected.
@Code(name: "Terminal", file: "build-2.sh", reset: true)
}
@Step {
Pair your device if prompted.
The first time you run `xtool dev`, you may see a "Trust" dialog on your iOS device to proceed with pairing. Tap **Trust** and enter your passcode on iOS. xtool may throw an error after this: if so, just run `xtool dev` again.
@Code(name: "Terminal", file: "build-2.sh", reset: true) {
@Image(source: "Trust", alt: "Prompt alerting user to trust device")
}
}
@Step {
xtool will now connect to Apple Developer Services, register your device with your Apple ID, generate a Certificate + App ID + Provisioning Profile, sign the app, and then install it.
@Code(name: "Terminal", file: "build-3.sh", reset: true) {}
}
@Step {
Enable Developer Mode if needed.
At this point, you may run into an error asking you to enable **Development Mode** on your iOS device. Follow [these instructions](https://developer.apple.com/documentation/xcode/enabling-developer-mode-on-a-device) and then run `xtool dev` again.
@Code(name: "Terminal", file: "build-3.sh", reset: true) {
@Image(source: "Developer", alt: "Developer mode in Settings")
}
}
@Step {
You should now see the app on your iOS device's home screen / App Library. Tap it to launch the app.
@Image(source: "Home", alt: "Hello app on the home screen")
}
@Step {
The first time you launch the app, observe that you may get an "Untrusted Developer" alert.
@Image(source: "UntrustedDev", alt: "Alert prompting user to trust certificate")
}
@Step {
Go to **Settings** > **General** > **VPN & Device Management** > _[your email]_ > **Trust**.
@Image(source: "Verified", alt: "Trust settings")
}
@Step {
You should now be able to launch the app!
@Image(source: "HelloWorld", alt: "Hello world app")
}
}
}
@Section(title: "Edit and re-run") {
We'll make a small change to the app in your favorite code editor, and then re-run it.
@Steps {
@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).
@Image(source: "SwiftExtension", alt: "Swift extension for VSCode")
}
@Step {
Open the project folder in your editor, and drill down to `Sources/Hello/ContentView.swift`.
@Code(name: "ContentView.swift", file: "edit-2.swift") {}
}
@Step {
If you've configured SourceKit-LSP correctly, you should see rich documentation when you hover over the various types and methods.
@Code(name: "ContentView.swift", file: "edit-2.swift") {
@Image(source: "Hover", alt: "Intellisense")
}
}
@Step {
Let's update the "Hello, world!" text to be bold and purple.
@Code(name: "ContentView.swift", file: "edit-4.swift") {}
}
@Step {
Run `xtool dev` again to re-build and re-install. This should go a lot faster than the first time.
@Code(name: "Terminal", file: "rerun-5b.sh", previousFile: "rerun-5a.sh") {}
}
@Step {
Launch the app again to see the updated text!
@Code(name: "Terminal", file: "rerun-6.sh") {
@Image(source: "HelloWorld-Purple", alt: "Updated Hello app")
}
}
}
}
}
@@ -0,0 +1,139 @@
# Installation (Linux/Windows)
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 (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>.
After following the steps there, confirm that Swift is installed correctly:
```bash
swift --version
# should say something like:
# Swift version 6.1 (swift-6.1-RELEASE)
```
### usbmuxd
xtool relies on [usbmuxd](https://github.com/libimobiledevice/usbmuxd) to talk to your iOS device from Linux.
Your Linux distro probably offers this package, and it may be preinstalled. To check if it is, run
```bash
usbmuxd --help
# Usage: usbmuxd [OPTIONS]
# ...
```
If instead you get "command not found", you need to install `usbmuxd` yourself. On Ubuntu/Debian, for example, you can do this with
```bash
sudo apt-get install usbmuxd
```
> Other useful tools:
>
> `usbmuxd` is part of the [libimobiledevice](https://libimobiledevice.org) project. You may want to install other libimobiledevice tools, such as `ideviceinfo`, that offer many ways to interact with your iOS device from the command line. On Ubuntu/Debian, you can run
>
> ```bash
> sudo apt-get install libimobiledevice-utils
> # The following NEW packages will be installed:
> # libimobiledevice-utils
> # 0 upgraded, 1 newly installed
> ideviceinfo
> # DeviceName: Kabir's iPhone
> # SerialNumber: ...
> # UniqueDeviceID: ...
> # ...
> ```
### Xcode.xip
Download **Xcode 16.3** from <https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_16.3/Xcode_16.3.xip>. Note the path where `Xcode_16.3.xip` is saved.
> Note:
>
> The URL above requires authentication, so make sure to visit it in your browser rather than running `curl`. You'll be asked to log in with your Apple ID and accept the license agreement to download Xcode.
## Installation
### 1. Download xtool
Once you have the prerequisites, download the [latest GitHub Release](https://github.com/xtool-org/xtool/releases/latest) of `xtool.AppImage` for your architecture. Rename it to `xtool` and add it to a location in your `PATH`.
```bash
curl -fL \
"https://github.com/xtool-org/xtool/releases/latest/download/xtool-$(uname -m).AppImage" \
-o xtool
chmod +x xtool
sudo mv xtool /usr/local/bin/
```
Confirm that xtool is installed correctly:
```bash
xtool --help
# OVERVIEW: Cross-platform Xcode replacement
# ...
```
### 2. Configure xtool: log in
Perform one-time setup with
```bash
xtool setup
```
You'll be asked to log in:
```
Select login mode
0: API Key (requires paid Apple Developer Program membership)
1: Password (works with any Apple ID but uses private APIs)
Choice (0-1):
```
> Choosing a login mode:
>
> **API Key:** If you have a paid [Apple Developer Program](https://developer.apple.com/programs/enroll/) membership, this is the recommended option. It relies on the public App Store Connect API. You'll want to follow the [instructions](https://developer.apple.com/documentation/appstoreconnectapi/creating-api-keys-for-app-store-connect-api) to generate a **Team Key** with the **App Manager** role.
>
> **Password:** If you aren't enrolled in the paid developer program, you'll want to use password-based authentication. This relies on private Apple APIs to authenticate, so you may want to create a throwaway Apple ID to be extra cautious.
Once you select a login mode, you'll be asked to provide the corresponding credentials (API key or email+password+2FA). Needless to say, *your credentials are only sent to Apple* and nobody else (feel free to build xtool from source and check!)
### 3. Configure xtool: SDK
After you're logged in, you'll be asked to provide the path to the `Xcode.xip` file you downloaded earlier.
```
Choice (0-1): 0
...
Path to Xcode.xip:
```
Enter the path (for example `~/Downloads/Xcode_16.3.xip`) and hit enter. xtool will extract the Xcode XIP to generate and install an iOS Swift SDK for you.
Confirm that it worked:
```bash
swift sdk list
# darwin
```
## Next steps
You're now ready to use xtool! See <doc:First-app>.
@@ -0,0 +1,81 @@
# Installation (macOS)
Set up xtool for declarative, Xcode-free iOS app development on macOS.
## Overview
This article outlines the steps to install `xtool` for declarative, SwiftPM-driven iOS app development on macOS.
## Prerequisites
### Xcode
Though we don't rely on the Xcode build system, you still need to install Xcode for the iOS SDK and toolchain. You'll want to [install Xcode](https://developer.apple.com/xcode/) and launch it once, completing any installation prompts.
Confirm that Xcode is set up with the iOS SDK:
```bash
xcrun -sdk iphoneos -show-sdk-path
# /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.4.sdk
```
As well as Swift:
```bash
swift --version
# swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
# Target: arm64-apple-macosx15.0
```
## Installation
### 1. Download xtool
If you have [Homebrew](https://brew.sh), you can install xtool with
```bash
brew install xtool-org/tap/xtool
```
Otherwise, you can download `xtool.app` from the [latest GitHub release](https://github.com/xtool-org/xtool/releases/latest). After moving it into `/Applications`, launch it and run the suggested script to add the `xtool` command to your `PATH`.
> Note:
>
> If you install xtool manually, you'll also need to check for new GitHub releases and update it yourself. If you're interested in contributing support for auto-updates through Sparkle, pull requests are appreciated. See [issue #34 on GitHub](https://github.com/xtool-org/xtool/issues/34).
Confirm that xtool is installed correctly:
```bash
xtool --help
# OVERVIEW: Cross-platform Xcode replacement
# ...
```
### 2. Configure xtool: log in
Perform one-time setup with
```bash
xtool setup
```
You'll be asked to log in:
```
Select login mode
0: API Key (requires paid Apple Developer Program membership)
1: Password (works with any Apple ID but uses private APIs)
Choice (0-1):
```
> Choosing a login mode:
>
> **API Key:** If you have a paid [Apple Developer Program](https://developer.apple.com/programs/enroll/) membership, this is the recommended option. It relies on the public App Store Connect API. You'll want to follow the [instructions](https://developer.apple.com/documentation/appstoreconnectapi/creating-api-keys-for-app-store-connect-api) to generate a **Team Key** with the **App Manager** role.
>
> **Password:** If you aren't enrolled in the paid developer program, you'll want to use password-based authentication. This relies on private Apple APIs to authenticate, so you may want to create a throwaway Apple ID to be extra cautious.
Once you select a login mode, you'll be asked to provide the corresponding credentials (API key or email+password+2FA). Needless to say, *your credentials are only sent to Apple* and nobody else (feel free to build xtool from source and check!)
## Next steps
You're now ready to use xtool! See <doc:First-app>. (The tutorial is tailored to Linux, but it works the same on macOS.)
Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 948 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

+19
View File
@@ -0,0 +1,19 @@
<style>
footer {
display: flex;
justify-content: center;
padding: 0.5rem 0.8rem;
background-color: var(--color-fill-secondary);
text-align: center;
}
a, a:visited {
color: var(--color-text);
}
</style>
<footer>
<span>
&copy; xtool maintainers. This site is powered by <a href="https://www.netlify.com">Netlify</a>.
</span>
</footer>
+33
View File
@@ -0,0 +1,33 @@
# xtool
@Metadata {
@TechnologyRoot
@TitleHeading("Command-line Tool")
@CallToAction(url: "https://github.com/xtool-org/xtool", label: "View on GitHub")
}
Cross-platform Xcode replacement.
## Overview
xtool is a cross-platform (Linux/WSL/macOS) tool that replicates Xcode functionality with open standards.
✅ Build a SwiftPM package into an iOS app
✅ Sign and install iOS apps
✅ Interact with Apple Developer Services programmatically
![A screenshot of xtool being invoked from VSCode](Cover.png)
## Topics
### Getting started
- <doc:Installation-Linux>
- <doc:Installation-macOS>
- <doc:First-app>
### Common tasks
- <doc:Control>
+11
View File
@@ -0,0 +1,11 @@
@Tutorials(name: "xtool") {
@Intro(title: "Tutorials") {
Install xtool and build your first iOS app on Linux.
}
@Chapter(name: "Getting Started") {
@Image(source: "HelloWorld", alt: "Getting Started")
@TutorialReference(tutorial: "doc:First-app")
}
}
+5 -5
View File
@@ -1,6 +1,6 @@
# Supersign + Linux = <3
# xtool + Linux = <3
Supersign currently uses AppImage to build its Linux CLI. It is possible to build and run the AppImage on a native Linux host, as well as through Docker (natively or through Docker Desktop on macOS).
xtool currently uses AppImage to build its Linux CLI. It is possible to build and run the AppImage on a native Linux host, as well as through Docker (natively or through Docker Desktop on macOS).
## Setup
@@ -10,9 +10,9 @@ Make sure `usbmuxd` is installed on your host machine. On macOS, `usbmuxd` is pr
You can build and run a container with standard Docker Compose commands, for example:
```
docker compose run --rm supersign
docker compose run --rm xtool
```
This will spawn a shell inside the container. The Supersign root directory will be bind-mounted at `/Supersign`.
This will spawn a shell inside the container. The xtool root directory will be bind-mounted at `/xtool`.
To actually access iOS devices from inside Docker, you'll also need to forward the host's `usbmuxd` to a port which the Docker container's libusbmuxd will connect to. Keep this command running on your host machine:
```
@@ -21,4 +21,4 @@ socat -dd TCP-LISTEN:27015,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/ru
## Building
Simply run `./build.sh` in this directory. This will output an AppImage to `packages/Supersign.AppImage`, which can directly be invoked.
Simply run `./build.sh` in this directory. This will output an AppImage to `packages/xtool.AppImage`, which can directly be invoked.
+12 -11
View File
@@ -5,9 +5,6 @@ shopt -s nullglob
cd "$(dirname "$0")"
# installer version
export LINUXDEPLOY_OUTPUT_VERSION="1.0.0"
if ! command -v fusermount &>/dev/null; then
# Docker doesn't support FUSE
export APPIMAGE_EXTRACT_AND_RUN=1
@@ -16,11 +13,12 @@ fi
rm -rf staging/tmp
mkdir -p staging/tmp staging/linuxdeploy
swift build --package-path .. -c release --product SupersignCLI --static-swift-stdlib
swift build --package-path .. -c release --product xtool --static-swift-stdlib
bin="$(swift build --package-path .. -c release --show-bin-path)"
strip "${bin}/SupersignCLI"
strip "${bin}/xtool"
curr_git_info="$(curl -fsSL https://api.github.com/repos/linuxdeploy/linuxdeploy/git/refs/tags/continuous)"
curr_arch="$(uname -m)"
if [[ -f staging/linuxdeploy/git.json ]]; then
if ! cmp -s staging/linuxdeploy/git.json <(echo "$curr_git_info"); then
@@ -33,7 +31,7 @@ else
fi
if [[ ! -f staging/linuxdeploy/linuxdeploy.AppImage ]]; then
curl -fsSL "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$(arch).AppImage" \
curl -fsSL "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${curr_arch}.AppImage" \
-o staging/linuxdeploy/linuxdeploy.AppImage
chmod +x staging/linuxdeploy/linuxdeploy.AppImage
echo "$curr_git_info" > staging/linuxdeploy/git.json
@@ -42,14 +40,17 @@ fi
mkdir -p staging/tmp/AppDir/usr/bin
find "${bin}"/ -name '*.resources' -print0 | xargs -0 -I {} cp -a {} "${PWD}/staging/tmp/AppDir/usr/bin/"
LDAI_OUTPUT="staging/tmp/Supersign.AppImage" ./staging/linuxdeploy/linuxdeploy.AppImage \
export LINUXDEPLOY_OUTPUT_VERSION="${XTOOL_VERSION:-unversioned}"
export LDAI_OUTPUT="staging/tmp/xtool-${curr_arch}.AppImage"
export LDAI_UPDATE_INFORMATION="gh-releases-zsync|xtool-org|xtool|latest|xtool-${curr_arch}.AppImage.zsync"
./staging/linuxdeploy/linuxdeploy.AppImage \
--appdir staging/tmp/AppDir \
--output appimage \
-e "${bin}/SupersignCLI" \
-d Supersign.desktop \
-i Supersign.png
-e "${bin}/xtool" \
-d xtool.desktop \
-i xtool.png
mkdir -p packages
mv -f staging/tmp/Supersign.AppImage packages/Supersign.AppImage
mv -f "staging/tmp/xtool-${curr_arch}.AppImage" "./xtool-${curr_arch}.AppImage.zsync" packages/
rm -rf staging/tmp
@@ -1,9 +1,9 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Supersign
Name=xtool
Categories=Development;
Exec=SupersignCLI
Icon=Supersign
Exec=xtool
Icon=xtool
# TODO: remove
Terminal=true

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 119 KiB

+140 -6
View File
@@ -1,18 +1,152 @@
ifeq ($(shell uname -s),Darwin)
IS_MAC = 1
ifneq ($(VERBOSE),1)
ifeq ($(shell type -p xcbeautify &>/dev/null && echo 1),1)
XC_FORMAT = | xcbeautify
endif
endif
endif
ifeq ($(RELEASE),1)
INTERNAL_SWIFTFLAGS = -c release
INTERNAL_XCFLAGS = -configuration Release
else
INTERNAL_SWIFTFLAGS = -c debug
INTERNAL_XCFLAGS = -configuration Debug
endif
ALL_SWIFTFLAGS = $(INTERNAL_SWIFTFLAGS) $(SWIFTFLAGS)
ALL_XCFLAGS = $(INTERNAL_XCFLAGS) $(XCFLAGS)
TEAM_CONFIG = macOS/Support/Private-Team.xcconfig
.PHONY: all
# dev build for the current platform
all:
ifeq ($(IS_MAC),1)
@+$(MAKE) mac
else
@+$(MAKE) linux
endif
.PHONY: clean
# clean build artifacts
clean:
ifeq ($(IS_MAC),1)
@+$(MAKE) mac-clean
else
@+$(MAKE) linux-clean
endif
.PHONY: linux
# dev build for Linux
linux:
swift build --product xtool $(ALL_SWIFTFLAGS)
.PHONY: linux-clean
# clean build artifacts for Linux
linux-clean:
rm -rf .build
.PHONY: linux-dist
# dist build for Linux
linux-dist:
docker compose run --build --rm xtool Linux/build.sh
.PHONY: mac
# dev build for macOS
mac: project
@rm -rf macOS/Build/XcodeInstall
@set -o pipefail && cd macOS && \
xcodebuild install \
-skipMacroValidation -skipPackagePluginValidation \
-scheme XToolMac -destination generic/platform=macOS \
-derivedDataPath Build/DerivedData \
DSTROOT="$$PWD"/Build/XcodeInstall INSTALL_PATH=/ \
$(ALL_XCFLAGS) $(XC_FORMAT)
@ln -fs XcodeInstall/xtool.app/Contents/Resources/bin/xtool macOS/Build/xtool
@echo "Output: ./macOS/Build/xtool"
.PHONY: mac-clean
# clean build artifacts for macOS
mac-clean:
rm -rf macOS/Build
.PHONY: mac-dist
# dist build for macOS
# requires a few secrets in the env (see .github/workflows/release.yml)
mac-dist:
@echo "bundle exec fastlane package"
@cd macOS && bundle exec fastlane package
.PHONY: reload
# update Xcode project and restart Xcode
reload:
killall Xcode || :
@+$(MAKE) project
xed macOS/XToolMac.xcodeproj
.PHONY: project
# update Xcode project
project: $(TEAM_CONFIG)
@echo "xcodegen"
@cd macOS && xcodegen
.PHONY: team
# update development team
team:
@+$(MAKE) -B $(TEAM_CONFIG)
# update development team if needed.
#
# will prompt interactively if there are multiple valid options.
# set DEVELOPMENT_TEAM=... to force a specific value.
$(TEAM_CONFIG):
ifeq ($(DEVELOPMENT_TEAM),)
@mkdir -p macOS/Support
@team=$$(./scripts/select-identity.sh); \
echo "echo \"DEVELOPMENT_TEAM = $$team\" > $@"; \
echo "DEVELOPMENT_TEAM = $$team" > $@
else
@mkdir -p macOS/Support
echo "DEVELOPMENT_TEAM = $(DEVELOPMENT_TEAM)" > $@
.PHONY: $(TEAM_CONFIG)
endif
.PHONY: docs
# build documentation
docs:
./Documentation/build.sh
.PHONY: docs-preview
# preview documentation
docs-preview:
./Documentation/build.sh preview
SPEC_URL = https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip
.PHONY: api update-api
api: openapi.json
.PHONY: api
# Regenerate the OpenAPI client code
api: openapi/openapi.json
swift run swift-openapi-generator generate \
openapi.json \
openapi/openapi.json \
--config Sources/DeveloperAPI/openapi-generator-config.yaml \
--output-directory Sources/DeveloperAPI/Generated
for file in Sources/DeveloperAPI/Generated/*.swift; do \
sed -i '' -e 's/[[:<:]]Client[[:>:]]/DeveloperAPIClient/g' $$file; \
done
.PHONY: update-api
# Update OpenAPI spec and regenerate the client code
update-api:
@+$(MAKE) -B api
openapi.json:
curl -fsSL "$(SPEC_URL)" | bsdtar -xOf- > openapi.json
openapi/openapi.json: openapi/base.json Sources/DeveloperAPI/openapi-overlay.yaml
npx --yes bump-cli overlay openapi/base.json Sources/DeveloperAPI/openapi-overlay.yaml > openapi/openapi.json
openapi/base.json:
@mkdir -p openapi
curl -fsSL "$(SPEC_URL)" | bsdtar -xOf- > openapi/base.json
+148 -76
View File
@@ -1,5 +1,5 @@
{
"originHash" : "093c707d9a59dbc3862fcc4682cd2a725695bec85446dcc453245f6ec0363481",
"originHash" : "6980154be7e8da0aace058cc72033471d7d9573fa77fdbf53972129e4cd1d0a2",
"pins" : [
{
"identity" : "aexml",
@@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "0a9b72369b9d87ab155ef585ef50700a34abf070",
"version" : "1.23.1"
"revision" : "333f51104b75d1a5b94cb3b99e4c58a3b442c9f7",
"version" : "1.25.2"
}
},
{
@@ -24,8 +24,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/attaswift/BigInt",
"state" : {
"revision" : "a7ee11486233ba45f5ceee0b8cb3d6629ed450ef",
"version" : "5.5.0"
"revision" : "114343a705df4725dfe7ab8a2a326b8883cfd79c",
"version" : "5.5.1"
}
},
{
"identity" : "combine-schedulers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/combine-schedulers",
"state" : {
"revision" : "5928286acce13def418ec36d05a001a9641086f2",
"version" : "1.0.3"
}
},
{
@@ -42,8 +51,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattpolzin/OpenAPIKit",
"state" : {
"revision" : "5b5ee49624dda5b3e3b85aff184f44a007862fb7",
"version" : "3.3.0"
"revision" : "da7d3a5ddff0dd8e5e9fdb5585d186d645bcc21b",
"version" : "3.5.0"
}
},
{
@@ -60,8 +69,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/onevcat/Rainbow.git",
"state" : {
"revision" : "e0dada9cd44e3fa7ec3b867e49a8ddbf543e3df3",
"version" : "4.0.1"
"revision" : "0c627a4f8a39ef37eadec1ceec02e4a7f55561ac",
"version" : "4.1.0"
}
},
{
@@ -73,22 +82,13 @@
"version" : "0.10.1"
}
},
{
"identity" : "superchargecore",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SuperchargeApp/SuperchargeCore",
"state" : {
"revision" : "e409f42fd5736fac149c8288eba69c50e7eac5c2",
"version" : "1.2.0"
}
},
{
"identity" : "swift-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-algorithms.git",
"state" : {
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
"version" : "1.2.0"
"revision" : "87e50f483c54e6efd60e885f7f5aa946cee68023",
"version" : "1.2.1"
}
},
{
@@ -105,8 +105,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-asn1.git",
"state" : {
"revision" : "7faebca1ea4f9aaf0cda1cef7c43aecd2311ddf6",
"version" : "1.3.0"
"revision" : "a54383ada6cecde007d374f58f864e29370ba5c3",
"version" : "1.3.2"
}
},
{
@@ -123,8 +123,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-certificates",
"state" : {
"revision" : "1fbb6ef21f1525ed5faf4c95207b9c11bea27e94",
"version" : "1.6.1"
"revision" : "999fd70c7803da89f3904d635a6815a2a7cd7585",
"version" : "1.10.0"
}
},
{
"identity" : "swift-clocks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-clocks",
"state" : {
"revision" : "cc46202b53476d64e824e0b6612da09d84ffde8e",
"version" : "1.0.6"
}
},
{
@@ -139,10 +148,10 @@
{
"identity" : "swift-concurrency-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras.git",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "163409ef7dae9d960b87f34b51587b6609a76c1f",
"version" : "1.3.0"
"revision" : "82a4ae7170d98d8538ec77238b7eb8e7199ef2e8",
"version" : "1.3.1"
}
},
{
@@ -150,8 +159,44 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto",
"state" : {
"revision" : "06dc63c6d8da54ee11ceb268cde1fa68161afc96",
"version" : "3.9.1"
"revision" : "e8d6eba1fef23ae5b359c46b03f7d94be2f41fed",
"version" : "3.12.3"
}
},
{
"identity" : "swift-dependencies",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-dependencies",
"state" : {
"revision" : "4c90d6b2b9bf0911af87b103bb40f41771891596",
"version" : "1.9.2"
}
},
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
"version" : "1.4.3"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
},
{
"identity" : "swift-http-structured-headers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-structured-headers.git",
"state" : {
"revision" : "f280fc7676b9940ff2c6598642751ea333c6544f",
"version" : "1.2.2"
}
},
{
@@ -159,8 +204,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "ef18d829e8b92d731ad27bb81583edd2094d1ce3",
"version" : "1.3.1"
"revision" : "a0a57e949a8903563aba4615869310c0ebf14c03",
"version" : "1.4.0"
}
},
{
@@ -168,17 +213,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
"revision" : "3d8596ed08bd13520157f0355e35caed215ffbfa",
"version" : "1.6.3"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"location" : "https://github.com/apple/swift-nio",
"state" : {
"revision" : "914081701062b11e3bb9e21accc379822621995e",
"version" : "2.76.1"
"revision" : "0f54d58bb5db9e064f332e8524150de379d1e51c",
"version" : "2.82.1"
}
},
{
@@ -186,8 +231,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "2e9746cfc57554f70b650b021b6ae4738abef3e6",
"version" : "1.24.1"
"revision" : "f1f6f772198bee35d99dd145f1513d8581a54f2c",
"version" : "1.26.0"
}
},
{
@@ -195,8 +240,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "eaa71bb6ae082eee5a07407b1ad0cbd8f48f9dca",
"version" : "1.34.1"
"revision" : "4281466512f63d1bd530e33f4aa6993ee7864be0",
"version" : "1.36.0"
}
},
{
@@ -204,8 +249,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "c7e95421334b1068490b5d41314a50e70bab23d1",
"version" : "2.29.0"
"revision" : "6df102a39c8da5fdc2eae29a0f63546d660866fc",
"version" : "2.30.0"
}
},
{
@@ -213,8 +258,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "bbd5e63cf949b7db0c9edaf7a21e141c52afe214",
"version" : "1.23.0"
"revision" : "cd1e89816d345d2523b11c55654570acd5cd4c56",
"version" : "1.24.0"
}
},
{
@@ -222,8 +267,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-numerics.git",
"state" : {
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
"revision" : "e0ec0f5f3af6f3e4d5e7a19d2af26b481acb6ba8",
"version" : "1.0.3"
}
},
{
@@ -231,8 +276,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/swift-openapi-async-http-client",
"state" : {
"revision" : "abfe558a66992ef1e896a577010f957915f30591",
"version" : "1.0.0"
"revision" : "915aeff168625b0f88a5810ee7ab8e9c00af671b",
"version" : "1.1.0"
}
},
{
@@ -240,8 +285,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-openapi-generator",
"state" : {
"revision" : "e971af5c5374e4ea83c20d0ad0a0df2cc84d39ad",
"version" : "1.5.0"
"revision" : "02cab48b66b4b412013827c2938adaf0eb67dc8d",
"version" : "1.7.2"
}
},
{
@@ -249,8 +294,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-openapi-runtime",
"state" : {
"revision" : "5e119a3d52dde0229312ed586be99c666c6b6f64",
"version" : "1.7.0"
"revision" : "8f33cc5dfe81169fb167da73584b9c72c3e8bc23",
"version" : "1.8.2"
}
},
{
@@ -258,17 +303,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-openapi-urlsession",
"state" : {
"revision" : "9bf4c712ad7989d6a91dbe68748b8829a50837e4",
"version" : "1.0.2"
"revision" : "6fac6f7c428d5feea2639b5f5c8b06ddfb79434b",
"version" : "1.1.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2",
"version" : "601.0.1"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"location" : "https://github.com/apple/swift-system",
"state" : {
"revision" : "c8a44d836fe7913603e246acab7c528c2e780168",
"version" : "1.4.0"
"revision" : "a34201439c74b53f0fd71ef11741af7e7caf01e1",
"version" : "1.4.2"
}
},
{
@@ -281,21 +335,21 @@
}
},
{
"identity" : "swiftpack",
"identity" : "swiftymobiledevice",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kabiroberai/swiftpack",
"location" : "https://github.com/xtool-org/SwiftyMobileDevice",
"state" : {
"revision" : "3610144c5fd3b1a50c323476ac7f42cebb9780bc",
"version" : "1.0.1"
"revision" : "5ee5f680d065519dd6ac56c96435a7db0d599ade",
"version" : "1.4.0"
}
},
{
"identity" : "swiftymobiledevice",
"identity" : "unxip",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SuperchargeApp/SwiftyMobileDevice",
"location" : "https://github.com/saagarjha/unxip",
"state" : {
"revision" : "954fff0438c181b64c0ab5dac5428486cc0cb6e0",
"version" : "1.3.0"
"revision" : "d6f0009109f7502f8f5b3f23dcd5b43cf5b29b32",
"version" : "3.1.0"
}
},
{
@@ -312,8 +366,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/websocket-kit.git",
"state" : {
"revision" : "4232d34efa49f633ba61afde365d3896fc7f8740",
"version" : "2.15.0"
"revision" : "014ccd52891b8c098d7e1033d5e72ed76fef7a86",
"version" : "2.16.0"
}
},
{
@@ -321,8 +375,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/yonaskolb/XcodeGen",
"state" : {
"revision" : "82c6ab9bbd5b6075fc0887d897733fc0c4ffc9ab",
"version" : "2.42.0"
"revision" : "7193eb447a6f60061f069e07bc1efd32d73c0e19",
"version" : "2.43.0"
}
},
{
@@ -330,8 +384,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tuist/XcodeProj.git",
"state" : {
"revision" : "447c159b0c5fb047a024fd8d942d4a76cf47dde0",
"version" : "8.16.0"
"revision" : "dc3b87a4e69f9cd06c6cb16199f5d0472e57ef6b",
"version" : "8.24.3"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "39de59b2d47f7ef3ca88a039dff3084688fe27f4",
"version" : "1.5.2"
}
},
{
"identity" : "xtool-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/xtool-org/xtool-core",
"state" : {
"revision" : "63c644eef014f7faff53daaebe8bad37c31fbbe5",
"version" : "1.3.0"
}
},
{
@@ -339,17 +411,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams",
"state" : {
"revision" : "3036ba9d69cf1fd04d433527bc339dc0dc75433d",
"version" : "5.1.3"
"revision" : "b4b8042411dc7bbb696300a34a4bf3ba1b7ad19b",
"version" : "5.3.1"
}
},
{
"identity" : "zsign",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kabiroberai/zsign",
"location" : "https://github.com/xtool-org/zsign",
"state" : {
"revision" : "c3fea016227f595cd51f037450650a2ff362f7db",
"version" : "1.3.0"
"revision" : "e9853fd3be36ea1a61fa9d4b7f71f4b4d8244369",
"version" : "1.4.0"
}
}
],
+80 -33
View File
@@ -2,83 +2,113 @@
import PackageDescription
let xtoolVersion: String? = {
if let explicitVersion = Context.environment["XTOOL_VERSION"] {
return explicitVersion
} else if let info = Context.gitInformation {
let gitCommit = info.currentCommit
let gitTag = info.currentTag
let gitRef = gitTag ?? "commit \(gitCommit)"
return "\(gitRef)\(info.hasUncommittedChanges ? " (dirty)" : "")"
} else {
return nil
}
}()
let cSettings: [CSetting] = [
.define("_GNU_SOURCE", .when(platforms: [.linux])),
]
let package = Package(
name: "Supersign",
name: "xtool",
platforms: [
.iOS(.v15),
.macOS(.v12),
],
products: [
.library(
name: "Supersign",
targets: ["Supersign"]
name: "XKit",
targets: ["XKit"]
),
.library(
name: "SupersignCLISupport",
targets: ["SupersignCLISupport"]
name: "XToolSupport",
targets: ["XToolSupport"]
),
.executable(
name: "SupersignCLI",
targets: ["SupersignCLI"]
name: "xtool",
targets: ["xtool"]
),
],
dependencies: [
.package(url: "https://github.com/SuperchargeApp/SuperchargeCore", .upToNextMinor(from: "1.2.0")),
.package(url: "https://github.com/SuperchargeApp/SwiftyMobileDevice", .upToNextMinor(from: "1.3.0")),
.package(url: "https://github.com/kabiroberai/swiftpack", .upToNextMinor(from: "1.0.1")),
.package(url: "https://github.com/kabiroberai/zsign", .upToNextMinor(from: "1.3.0")),
.package(url: "https://github.com/xtool-org/xtool-core", .upToNextMinor(from: "1.3.0")),
.package(url: "https://github.com/xtool-org/SwiftyMobileDevice", .upToNextMinor(from: "1.4.0")),
.package(url: "https://github.com/xtool-org/zsign", .upToNextMinor(from: "1.4.0")),
.package(url: "https://github.com/apple/swift-system", from: "1.4.0"),
.package(url: "https://github.com/apple/swift-http-types", from: "1.3.1"),
.package(url: "https://github.com/apple/swift-certificates", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-crypto", from: "3.9.1"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio", from: "2.77.0"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0"),
.package(url: "https://github.com/swift-server/swift-openapi-async-http-client", from: "1.0.0"),
.package(url: "https://github.com/vapor/websocket-kit.git", from: "2.15.0"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.3.0"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.6.2"),
.package(url: "https://github.com/attaswift/BigInt", from: "5.5.0"),
.package(url: "https://github.com/mxcl/Version", from: "2.1.0"),
.package(url: "https://github.com/jpsim/Yams", from: "5.1.3"),
.package(url: "https://github.com/saagarjha/unxip", from: "3.1.0"),
// TODO: just depend on tuist/XcodeProj instead
.package(url: "https://github.com/yonaskolb/XcodeGen", from: "2.43.0"),
],
targets: [
.systemLibrary(name: "CSupersette"),
.systemLibrary(name: "XADI"),
.target(
name: "CSupersign",
name: "CXKit",
dependencies: [
.product(name: "OpenSSL", package: "SuperchargeCore")
.product(name: "OpenSSL", package: "xtool-core")
],
cSettings: cSettings
cSettings: cSettings + (
xtoolVersion
.map { [.define("XTOOL_VERSION", to: "\"\($0)\"")] }
?? []
)
),
.target(
name: "DeveloperAPI",
dependencies: [
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
],
exclude: ["openapi-generator-config.yaml"]
exclude: ["openapi-generator-config.yaml", "openapi-overlay.yaml"]
),
.target(
name: "Supersign",
name: "XKit",
dependencies: [
"DeveloperAPI",
"CSupersign",
.byName(name: "CSupersette", condition: .when(platforms: [.linux])),
"CXKit",
.byName(name: "XADI", condition: .when(platforms: [.linux])),
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "SwiftyMobileDevice", package: "SwiftyMobileDevice"),
.product(name: "Zupersign", package: "zsign"),
.product(name: "SignerSupport", package: "SuperchargeCore"),
.product(name: "ProtoCodable", package: "SuperchargeCore"),
.product(name: "Superutils", package: "SuperchargeCore"),
.product(name: "SignerSupport", package: "xtool-core"),
.product(name: "ProtoCodable", package: "xtool-core"),
.product(name: "Superutils", package: "xtool-core"),
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "_CryptoExtras", package: "swift-crypto"),
.product(name: "X509", package: "swift-certificates"),
.product(name: "BigInt", package: "BigInt"),
.product(name: "HTTPTypes", package: "swift-http-types"),
.product(name: "HTTPTypesFoundation", package: "swift-http-types"),
.product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
.product(
name: "OpenAPIAsyncHTTPClient",
@@ -99,10 +129,16 @@ let package = Package(
cSettings: cSettings
),
.testTarget(
name: "SupersignTests",
name: "XToolTests",
dependencies: [
"Supersign",
.product(name: "SuperutilsTestSupport", package: "SuperchargeCore")
"XToolSupport",
]
),
.testTarget(
name: "XKitTests",
dependencies: [
"XKit",
.product(name: "SuperutilsTestSupport", package: "xtool-core")
],
exclude: [
"config/config-template.json",
@@ -113,21 +149,32 @@ let package = Package(
]
),
.target(
name: "SupersignCLISupport",
name: "XToolSupport",
dependencies: [
"SwiftyMobileDevice",
"Supersign",
.product(name: "PackLib", package: "swiftpack"),
.product(name: "ArgumentParser", package: "swift-argument-parser")
"XKit",
"PackLib",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SystemPackage", package: "swift-system"),
.product(name: "NIOPosix", package: "swift-nio"),
.product(name: "Version", package: "Version"),
.product(name: "libunxip", package: "unxip"),
],
cSettings: cSettings
),
.target(
name: "PackLib",
dependencies: [
.product(name: "Yams", package: "Yams"),
.product(name: "XcodeGenKit", package: "XcodeGen", condition: .when(platforms: [.macOS])),
]
),
.executableTarget(
name: "SupersignCLI",
name: "xtool",
dependencies: [
"SwiftyMobileDevice",
"Supersign",
"SupersignCLISupport",
"XKit",
"XToolSupport",
],
cSettings: cSettings
),
+43 -19
View File
@@ -1,43 +1,67 @@
# Supersign
# xtool
An all-in-one tool/library for sideloading iOS apps and talking to Apple Developer Services. Supports macOS and Linux.
Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, and macOS.
## Prerequisites
## Overview
- Supersign works out of the box on macOS.
- On Linux, you'll need the development packages of [libimobiledevice](https://github.com/libimobiledevice/libimobiledevice) + its dependencies.
- Alternatively, we provide a Dockerfile that does this for you. See [Linux/README.md](/Linux/README.md).
xtool is a cross-platform (Linux/WSL/macOS) tool that replicates Xcode functionality with open standards.
## Installation (CLI)
✅ Build a SwiftPM package into an iOS app
✅ Sign and install iOS apps
✅ Interact with Apple Developer Services programmatically
## Getting Started
1. Follow the guide to install `xtool`
- [Installation (Linux/Windows)](https://xtool.sh/documentation/xtooldocs/installation-linux)
- [Installation (macOS)](https://xtool.sh/documentation/xtooldocs/installation-macos)
2. Create and run your first xtool-powered app by following the [tutorial](https://xtool.sh/tutorials/xtooldocs/first-app)!
## Examples
### Screenshot
![A screenshot of xtool being invoked from VSCode](Documentation/xtool.docc/Resources/Cover.png)
### Command line interface
```bash
$ git clone https://github.com/SuperchargeApp/Supersign
$ cd Supersign
$ swift run SupersignCLI --help
OVERVIEW: The Supersign command line tool
$ xtool --help
OVERVIEW: Cross-platform Xcode replacement
USAGE: supersign <subcommand>
USAGE: xtool <subcommand>
OPTIONS:
-h, --help Show help information.
SUBCOMMANDS:
CONFIGURATION SUBCOMMANDS:
setup Set up xtool for iOS development
auth Manage Apple Developer Services authentication
sdk Manage the Darwin Swift SDK
DEVELOPMENT SUBCOMMANDS:
new Create a new xtool SwiftPM project
dev Build and run an xtool SwiftPM project
ds Interact with Apple Developer Services
DEVICE SUBCOMMANDS:
devices List devices
install Install an ipa file to your device
uninstall Uninstall an installed app
run Run an installed app
launch Launch an installed app
See 'supersign help <subcommand>' for detailed help.
See 'xtool help <subcommand>' for detailed help.
```
## Installation (Library)
### Library
Just add it as a SwiftPM dependency!
xtool includes a library that you can use to interact with Apple Developer Services, iOS devices, and more from your own app. You can use this by adding `XKit` as a SwiftPM dependency.
```swift
// package dependency:
.package(url: "https://github.com/SuperchargeApp/Supersign", .upToNextMinor(from: "1.2.0"))
.package(url: "https://github.com/xtool-org/xtool", .upToNextMinor(from: "1.2.0"))
// target dependency:
.product(name: "Supersign", package: "Supersign")
.product(name: "XKit", package: "xtool")
```
+5
View File
@@ -0,0 +1,5 @@
# Security Policy
## Reporting a Vulnerability
To report a vulnerability, please use GitHub's ["Report a Vulnerability"](https://github.com/xtool-org/xtool/security/advisories/new) tab. We'll be in touch regarding next steps.
-4
View File
@@ -1,4 +0,0 @@
module CSupersette [extern_c] {
header "supersette.h"
link "supersette"
}
-13
View File
@@ -1,13 +0,0 @@
#include <stdint.h>
void supersette_Load(const char *path);
int32_t supersette_SetAndroidID(const char *identifier, uint32_t length);
int32_t supersette_SetProvisioningPath(const char *path);
int32_t supersette_ProvisioningErase(uint64_t dsId);
int32_t supersette_Synchronize(uint64_t dsId, const void *serverIntermediateMetadata, uint32_t serverIntermediateMetadataLength, void **machineIdentifier, uint32_t *machineIdentifierLength, void **synchronizationResumeMetadata, uint32_t *synchronizationResumeMetadataLength);
int32_t supersette_ProvisioningDestroy(uint32_t session);
int32_t supersette_ProvisioningEnd(uint32_t session, const void *persistentTokenMetadata, uint32_t persistentTokenMetadataLength, const void *trustKey, uint32_t trustKeyLength);
int32_t supersette_ProvisioningStart(uint64_t dsId, const void *serverProvisioningIntermediateMetadata, uint32_t serverProvisioningIntermediateMetadataLength, void **clientProvisioningIntermediateMetadata, uint32_t *clientProvisioningIntermediateMetadataLength, uint32_t *session);
int32_t supersette_GetLoginCode(uint64_t dsId);
int32_t supersette_Dispose(void *ptr);
int32_t supersette_OTPRequest(uint64_t dsId, void **machineIdentifier, uint32_t *machineIdentifierLength, void **oneTimePassword, uint32_t *oneTimePasswordLength);
@@ -1,6 +1,6 @@
//
// mobileprovision_utils.h
// supersign
// XKit
//
// Created by Kabir Oberai on 05/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
+1
View File
@@ -0,0 +1 @@
const char * _Nonnull xtl_version(void);
@@ -1,6 +1,6 @@
//
// mobileprovision_utils.c
// supersign
// XKit
//
// Created by Kabir Oberai on 05/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
+9
View File
@@ -0,0 +1,9 @@
#include "version.h"
const char *xtl_version(void) {
#ifdef XTOOL_VERSION
return XTOOL_VERSION;
#else
return "unversioned";
#endif
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,7 +1,8 @@
generate:
- types
- client
accessModifier: package
accessModifier: public
namingStrategy: idiomatic
filter:
tags:
- BundleIds
+25
View File
@@ -0,0 +1,25 @@
overlay: 1.0.0
info:
title: Overlay for App Store Connect API
version: 1.0.0
actions:
- target: '$.components.schemas.BundleIdCapabilityCreateRequest.properties.data.properties.relationships'
update:
properties:
capability:
type: object
properties:
data:
type: object
properties:
type:
type: string
enum: [capabilities]
id:
"$ref": "#/components/schemas/CapabilityType"
required: [id, type]
required: [data]
required: [capability]
- target: '$.components.schemas.Device.properties.attributes.properties.deviceClass'
update:
enum: ["APPLE_VISION_PRO"]
+93
View File
@@ -0,0 +1,93 @@
import Foundation
public struct BuildSettings: Sendable {
private static let customBinDir =
// this is the same option used by SwiftPM itself for dev builds
ProcessInfo.processInfo.environment["SWIFTPM_CUSTOM_BIN_DIR"].map { URL(fileURLWithPath: $0) }
private static let envURL = URL(fileURLWithPath: "/usr/bin/env")
public let packagePath: String
public let configuration: BuildConfiguration
public let triple: String
public let sdkOptions: [String]
public let options: [String]
public init(
configuration: BuildConfiguration,
triple: String,
packagePath: String = ".",
options: [String] = []
) async throws {
self.packagePath = packagePath
self.configuration = configuration
self.options = options
self.triple = triple
// on macOS we don't explicitly install a Swift SDK but
// SwiftPM vends "implicit" Darwin SDKs as of Swift 6.1,
// i.e. we can pass `--swift-sdk arm64-apple-ios` and it
// just works. See:
// https://github.com/swiftlang/swift-package-manager/pull/6828
self.sdkOptions = ["--swift-sdk", triple]
}
#if os(macOS)
private static func xcrun(_ arguments: [String]) async throws -> String {
let xcrun = Process()
let pipe = Pipe()
xcrun.executableURL = URL(fileURLWithPath: "/usr/bin/xcrun")
xcrun.arguments = arguments
xcrun.standardOutput = pipe
try await xcrun.runUntilExit()
return String(decoding: pipe.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self)
.trimmingCharacters(in: .whitespacesAndNewlines)
}
private static let swiftURL = Task {
try await URL(fileURLWithPath: xcrun(["-f", "swift"]))
}
#endif
public func swiftPMInvocation(
forTool tool: String,
arguments: [String],
packagePathOverride: String? = nil
) async throws -> Process {
let process = Process()
let baseArguments: [String]
if let customBinDir = Self.customBinDir {
process.executableURL = customBinDir.appendingPathComponent("swift-\(tool)")
baseArguments = []
} else {
#if os(macOS)
// xcrun/libxcrun (via the /usr/bin/swift trampoline) is very trigger-happy
// to add SDKROOT=.../MacOSX.sdk to our invocations. We avoid this by
// 1) invoking the real swift executable (located with `xcrun -f`) and
// 2) explicitly removing SDKROOT from the env, as it may be inherited
// through the `swift run pack` invocation.
process.executableURL = try await Self.swiftURL.value
#else
process.executableURL = try await ToolRegistry.locate("swift")
#endif
baseArguments = [tool]
}
let extraArguments: [String] = [
"--package-path", packagePathOverride ?? packagePath,
"--configuration", configuration.rawValue,
]
var env = ProcessInfo.processInfo.environment
env.removeValue(forKey: "SDKROOT")
process.environment = env
process.arguments = baseArguments + extraArguments + sdkOptions + options + arguments
return process
}
}
public enum BuildConfiguration: String, CaseIterable, Sendable {
case debug
case release
}
+56
View File
@@ -0,0 +1,56 @@
import Foundation
package struct TemporaryDirectory: ~Copyable {
private var shouldDelete = true
package let url: URL
package init(name: String) throws {
self.url = FileManager.default.temporaryDirectory.appendingPathComponent(name, isDirectory: true)
_delete()
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)
}
private func _delete() {
try? FileManager.default.removeItem(at: url)
}
package consuming func persist() -> URL {
shouldDelete = false
return url
}
package consuming func persist(at location: URL) throws {
try FileManager.default.moveItem(at: url, to: location)
// we do this after moving, so that if the move fails we clean up
shouldDelete = false
}
deinit {
if shouldDelete { _delete() }
}
}
extension Data {
// AsyncBytes is Darwin-only :/
package init(reading fileHandle: FileHandle) async throws {
#if canImport(Darwin)
self = try await fileHandle.bytes.reduce(into: Data()) { $0.append($1) }
#else
self = try fileHandle.readToEnd() ?? Data()
#endif
}
package init(reading file: URL) async throws {
#if canImport(Darwin)
self = try await file.resourceBytes.reduce(into: Data()) { $0.append($1) }
#else
try self.init(contentsOf: file)
#endif
}
}
package func stderrPrint(_ message: String, terminator: String = "\n") {
try? FileHandle.standardError.write(contentsOf: Data("\(message)\(terminator)".utf8))
}
+71
View File
@@ -0,0 +1,71 @@
import Foundation
import Yams
public struct PackSchemaBase: Codable, Sendable {
public enum Version: Int, Codable, Sendable {
case v1 = 1
}
public var version: Version
public var orgID: String?
public var bundleID: String?
public var product: String?
public var infoPath: String?
public var iconPath: String?
public var resources: [String]?
}
public struct PackSchema: Sendable {
public enum IDSpecifier: Sendable {
case orgID(String)
case bundleID(String)
func formBundleID(product: String) -> String {
switch self {
case .orgID(let orgID): "\(orgID).\(product)"
case .bundleID(let bundleID): bundleID
}
}
}
public let base: PackSchemaBase
public let idSpecifier: IDSpecifier
public init(validating base: PackSchemaBase) throws {
self.base = base
if base.version != .v1 {
throw StringError("xtool.yml: Unsupported schema version: \(base.version.rawValue)")
}
switch (base.bundleID, base.orgID) {
case (let bundleID?, _):
idSpecifier = .bundleID(bundleID)
case (nil, let orgID?):
idSpecifier = .orgID(orgID)
case (nil, nil):
throw StringError("xtool.yml: Must specify either orgID or bundleID")
}
if let iconPath = base.iconPath {
let ext = URL(fileURLWithPath: iconPath).pathExtension
guard ext == "png" else {
throw StringError("xtool.yml: iconPath should have a 'png' path extension. Got '\(ext)'.")
}
}
}
public static let `default` = try! PackSchema(validating: .init(
version: .v1,
orgID: "com.example"
))
public init(url: URL) async throws {
let data = try await Data(reading: url)
let base = try YAMLDecoder().decode(PackSchemaBase.self, from: data)
try self.init(validating: base)
}
}
+159
View File
@@ -0,0 +1,159 @@
import Foundation
public struct Packer: Sendable {
public let buildSettings: BuildSettings
public let plan: Plan
public init(buildSettings: BuildSettings, plan: Plan) {
self.plan = plan
self.buildSettings = buildSettings
}
private func build() async throws {
let xtoolDir = URL(fileURLWithPath: "xtool")
let packageDir = xtoolDir.appendingPathComponent(".xtool-tmp")
try? FileManager.default.removeItem(at: packageDir)
try FileManager.default.createDirectory(at: packageDir, withIntermediateDirectories: true)
let packageSwift = packageDir.appendingPathComponent("Package.swift")
let contents = """
// swift-tools-version: 6.0
import PackageDescription
let package = Package(
name: "\(plan.product)-Builder",
platforms: [
.iOS("\(plan.deploymentTarget)"),
],
dependencies: [
.package(name: "RootPackage", path: "../.."),
],
targets: [
.executableTarget(
name: "\(plan.product)-App",
dependencies: [
.product(name: "\(plan.product)", package: "RootPackage"),
]
),
]
)\n
"""
try Data(contents.utf8).write(to: packageSwift)
let sources = packageDir.appendingPathComponent("Sources")
try? FileManager.default.createDirectory(at: sources, withIntermediateDirectories: true)
try Data().write(to: sources.appendingPathComponent("stub.c"))
let builder = try await buildSettings.swiftPMInvocation(
forTool: "build",
arguments: [
"--package-path", packageDir.path,
"--scratch-path", ".build",
"--product", "\(plan.product)-App",
// resolving can cause SwiftPM to overwrite the root package deps
// with just the deps needed for the builder package (which is to
// say, any "dev dependencies" of the root package may be removed.)
// fortunately we've already resolved the root package by this point
// in order to dump the plan, so we can skip resolution here to skirt
// the issue.
"--disable-automatic-resolution",
"-Xlinker", "-rpath", "-Xlinker", "@executable_path/Frameworks",
]
)
builder.standardOutput = FileHandle.standardError
try await builder.runUntilExit()
}
public func pack() async throws -> URL {
try await build()
let output = try TemporaryDirectory(name: "\(plan.product).app")
let binDir = URL(
fileURLWithPath: ".build/\(buildSettings.triple)/\(buildSettings.configuration.rawValue)",
isDirectory: true
)
let outputURL = output.url
@Sendable func packFileToRoot(srcName: String) async throws {
let srcURL = URL(fileURLWithPath: srcName)
let destURL = outputURL.appendingPathComponent(srcURL.lastPathComponent)
try FileManager.default.copyItem(at: srcURL, to: destURL)
try Task.checkCancellation()
}
@Sendable func packFile(srcName: String, dstName: String? = nil, sign: Bool = false) async throws {
let srcURL = URL(fileURLWithPath: srcName, relativeTo: binDir)
let dstURL = URL(fileURLWithPath: dstName ?? srcURL.lastPathComponent, relativeTo: outputURL)
try? FileManager.default.createDirectory(at: dstURL.deletingLastPathComponent(), withIntermediateDirectories: true)
try FileManager.default.copyItem(at: srcURL, to: dstURL)
try Task.checkCancellation()
}
try await withThrowingTaskGroup(of: Void.self) { group in
for command in plan.resources {
group.addTask {
switch command {
case .bundle(let package, let target):
try await packFile(srcName: "\(package)_\(target).bundle")
case .binaryTarget(let name):
let src = URL(fileURLWithPath: "\(name).framework/\(name)", relativeTo: binDir)
let magic = Data("!<arch>\n".utf8)
let thinMagic = Data("!<thin>\n".utf8)
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
if bytes != magic && bytes != thinMagic {
try await packFile(srcName: "\(name).framework", dstName: "Frameworks/\(name).framework", sign: true)
}
case .library(let name):
try await packFile(srcName: "lib\(name).dylib", dstName: "Frameworks/lib\(name).dylib", sign: true)
case .root(let source):
try await packFileToRoot(srcName: source)
}
}
}
if let iconPath = plan.iconPath {
group.addTask {
try await packFileToRoot(srcName: iconPath)
}
}
group.addTask {
try await packFile(srcName: "\(plan.product)-App", dstName: plan.product)
}
group.addTask {
var info = plan.infoPlist
if let iconPath = plan.iconPath {
let iconName = URL(fileURLWithPath: iconPath).deletingPathExtension().lastPathComponent
info["CFBundleIconFile"] = iconName
}
let infoPath = outputURL.appendingPathComponent("Info.plist")
let encodedPlist = try PropertyListSerialization.data(
fromPropertyList: info,
format: .xml,
options: 0
)
try encodedPlist.write(to: infoPath)
}
while !group.isEmpty {
do {
try await group.next()
} catch is CancellationError {
// continue
} catch {
group.cancelAll()
throw error
}
}
}
let dest = URL(fileURLWithPath: "xtool")
.appendingPathComponent(output.url.lastPathComponent)
try? FileManager.default.removeItem(at: dest)
try output.persist(at: dest)
return dest
}
}
+301
View File
@@ -0,0 +1,301 @@
import Foundation
public struct Planner: Sendable {
public var buildSettings: BuildSettings
public var schema: PackSchema
public init(
buildSettings: BuildSettings,
schema: PackSchema
) {
self.buildSettings = buildSettings
self.schema = schema
}
private static let decoder: JSONDecoder = {
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
return decoder
}()
public func createPlan() async throws -> Plan {
// TODO: cache plan using (Package.swift+Package.resolved) as the key?
let dependencyData = try await _dumpAction(
arguments: ["show-dependencies", "--format", "json"],
path: buildSettings.packagePath
)
let dependencyRoot = try Self.decoder.decode(PackageDependency.self, from: dependencyData)
let packages = try await withThrowingTaskGroup(
of: (PackageDependency, PackageDump).self,
returning: [String: PackageDump].self
) { group in
var visited: Set<String> = []
var dependencies: [PackageDependency] = [dependencyRoot]
while let dependencyNode = dependencies.popLast() {
guard visited.insert(dependencyNode.identity).inserted else { continue }
dependencies.append(contentsOf: dependencyNode.dependencies)
group.addTask { (dependencyNode, try await dumpPackage(at: dependencyNode.path)) }
}
var packages: [String: PackageDump] = [:]
while let result = await group.nextResult() {
switch result {
case .success((let dependency, let dump)):
packages[dependency.identity] = dump
case .failure(_ as CancellationError):
// continue loop
break
case .failure(let error):
group.cancelAll()
throw error
}
}
return packages
}
var packagesByProductName: [String: String] = [:]
for (packageID, package) in packages {
for product in package.products ?? [] {
packagesByProductName[product.name] = packageID
}
}
let rootPackage = packages[dependencyRoot.identity]!
let deploymentTarget = rootPackage.platforms?.first { $0.name == "ios" }?.version ?? "13.0"
let libraries = rootPackage.products?.filter { $0.type == .autoLibrary } ?? []
let library = try selectLibrary(
from: libraries,
matching: schema.base.product
)
var resources: [Resource] = []
var visited: Set<String> = []
var targets = library.targets.map { (rootPackage, $0) }
while let (targetPackage, targetName) = targets.popLast() {
guard let target = targetPackage.targets?.first(where: { $0.name == targetName }) else {
throw StringError("Could not find target '\(targetName)' in package '\(targetPackage.name)'")
}
guard visited.insert(targetName).inserted else { continue }
if target.moduleType == "BinaryTarget" {
resources.append(.binaryTarget(name: targetName))
}
if target.resources?.isEmpty == false {
resources.append(.bundle(package: targetPackage.name, target: targetName))
}
for targetName in (target.targetDependencies ?? []) {
targets.append((targetPackage, targetName))
}
for productName in (target.productDependencies ?? []) {
guard let packageID = packagesByProductName[productName] else {
throw StringError("Could not find package containing product '\(productName)'")
}
guard let package = packages[packageID] else {
throw StringError("Could not find package by id '\(packageID)'")
}
guard let product = package.products?.first(where: { $0.name == productName }) else {
throw StringError("Could not find product '\(productName)' in package '\(packageID)'")
}
if product.type == .dynamicLibrary {
resources.append(.library(name: productName))
}
targets.append(contentsOf: product.targets.map { (package, $0) })
}
}
if let rootResources = schema.base.resources {
resources += rootResources.map { .root(source: $0) }
}
let bundleID = schema.idSpecifier.formBundleID(product: library.name)
var infoPlist: [String: Sendable] = [
"CFBundleInfoDictionaryVersion": "6.0",
"UIRequiredDeviceCapabilities": ["arm64"],
"LSRequiresIPhoneOS": true,
"CFBundleSupportedPlatforms": ["iPhoneOS"],
"CFBundlePackageType": "APPL",
"UIDeviceFamily": [1, 2],
"CFBundleDevelopmentRegion": "en",
"UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait"],
"UISupportedInterfaceOrientations~ipad": [
"UIInterfaceOrientationPortrait",
"UIInterfaceOrientationPortraitUpsideDown",
"UIInterfaceOrientationLandscapeLeft",
"UIInterfaceOrientationLandscapeRight"
],
"UILaunchScreen": [:] as [String: Sendable],
"CFBundleVersion": "1",
"CFBundleShortVersionString": "1.0.0",
"MinimumOSVersion": deploymentTarget,
"CFBundleIdentifier": bundleID,
"CFBundleName": "\(library.name)",
"CFBundleExecutable": "\(library.name)",
]
if let plist = self.schema.base.infoPath {
let data = try await Data(reading: URL(fileURLWithPath: plist))
let info = try PropertyListSerialization.propertyList(from: data, format: nil)
if let info = info as? [String: Sendable] {
infoPlist.merge(info, uniquingKeysWith: { $1 })
} else {
throw StringError("Info.plist has invalid format: expected a dictionary.")
}
}
return Plan(
product: library.name,
deploymentTarget: deploymentTarget,
bundleID: bundleID,
infoPlist: infoPlist,
resources: resources,
iconPath: self.schema.base.iconPath
)
}
private func dumpPackage(at path: String) async throws -> PackageDump {
let data = try await _dumpAction(arguments: ["describe", "--type", "json"], path: path)
try Task.checkCancellation()
return try Self.decoder.decode(PackageDump.self, from: data)
}
private func _dumpAction(arguments: [String], path: String) async throws -> Data {
let dump = try await buildSettings.swiftPMInvocation(
forTool: "package",
arguments: arguments,
packagePathOverride: path
)
let pipe = Pipe()
dump.standardOutput = pipe
async let task = Data(reading: pipe.fileHandleForReading)
try await dump.runUntilExit()
return try await task
}
private func selectLibrary(
from products: [PackageDump.Product],
matching name: String?
) throws -> PackageDump.Product {
switch products.count {
case 0:
throw StringError("No library products were found in the package")
case 1:
let product = products[0]
if let name, product.name != name {
throw StringError("""
Product name ('\(product.name)') does not match the 'product' value in the schema ('\(name)')
""")
}
return product
default:
guard let name else {
throw StringError("""
Multiple library products were found (\(products.map(\.name))). Please either:
1) Expose exactly one library product, or
2) Specify the product you want via the 'product' key in xtool.yml.
""")
}
guard let product = products.first(where: { $0.name == name }) else {
throw StringError("""
Schema declares a 'product' name of '\(name)' but no matching product was found.
Found: \(products.map(\.name)).
""")
}
return product
}
}
}
public struct Plan: Sendable {
public var product: String
public var deploymentTarget: String
public var bundleID: String
public var infoPlist: [String: any Sendable]
public var resources: [Resource]
public var iconPath: String?
}
public enum Resource: Codable, Sendable {
case bundle(package: String, target: String)
case binaryTarget(name: String)
case library(name: String)
case root(source: String)
}
private struct PackageDependency: Decodable {
let identity: String
let name: String
let path: String // on disk
let dependencies: [PackageDependency]
}
private struct PackageDump: Decodable {
enum ProductType: Decodable {
case executable
case dynamicLibrary
case staticLibrary
case autoLibrary
case other
private enum CodingKeys: String, CodingKey {
case executable
case library
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if container.contains(.executable) {
self = .executable
} else if let library = try container.decodeIfPresent([String].self, forKey: .library) {
if library.count == 1 {
switch library[0] {
case "dynamic":
self = .dynamicLibrary
case "static":
self = .staticLibrary
case "automatic":
self = .autoLibrary
default:
self = .other
}
} else {
self = .other
}
} else {
self = .other
}
}
}
struct Product: Decodable {
let name: String
let targets: [String]
let type: ProductType
}
struct Target: Decodable {
let name: String
let moduleType: String
let productDependencies: [String]?
let targetDependencies: [String]?
let resources: [Resource]?
}
struct Resource: Decodable {
let path: String
}
struct Platform: Decodable {
let name: String
let version: String
}
let name: String
let products: [Product]?
let targets: [Target]?
let platforms: [Platform]?
}
+63
View File
@@ -0,0 +1,63 @@
import Foundation
extension Process {
/// Launches the process and suspends until the receiver is finished.
///
/// - Parameter onCancel: The action to take if the current
/// task is cancelled.
public func runUntilExit(onCancel: TaskCancelAction = .interrupt) async throws {
try Task.checkCancellation()
let (terminationStream, terminationContinuation) = AsyncStream<Never>.makeStream()
terminationHandler = { _ in
terminationContinuation.finish()
}
do {
try run()
} catch {
terminationContinuation.finish()
throw error
}
await withTaskCancellationHandler {
for await _ in terminationStream {}
} onCancel: {
switch onCancel {
case .interrupt:
interrupt()
case .terminate:
terminate()
case .ignore:
break
}
}
try Task.checkCancellation()
switch terminationReason {
case .exit where terminationStatus == 0:
break
case .exit:
throw Failure.exit(terminationStatus)
case .uncaughtSignal:
throw Failure.uncaughtSignal(terminationStatus)
@unknown default:
break
}
}
public enum Failure: Error {
case exit(CInt)
case uncaughtSignal(CInt)
}
public enum TaskCancelAction: Sendable {
/// Sends `SIGINT` to the process.
case interrupt
/// Sends `SIGTERM` to the process.
case terminate
/// Don't participate in cooperative cancellation.
case ignore
}
}
+6
View File
@@ -0,0 +1,6 @@
package struct StringError: Error, CustomStringConvertible {
package var description: String
package init(_ description: String) {
self.description = description
}
}
+61
View File
@@ -0,0 +1,61 @@
import Foundation
package enum ToolRegistry {
package enum Errors: Error, CustomStringConvertible {
case toolNotFound(String)
package var description: String {
switch self {
case .toolNotFound(let tool):
"Could not find executable '\(tool)' in PATH"
}
}
}
private static let cache = Cache()
/// Obtain the full path to a tool in the user's `PATH`.
///
/// This effectively invokes `/bin/sh -c "command -v '$tool'"`.
///
/// - Warning: Make sure you trust/sanitize the `tool` parameter. If it
/// contains a single quote, it can be used in a shell escape.
///
/// - Throws: `Errors.toolNotFound` if the tool could not be located.
package static func locate(_ tool: String) async throws -> URL {
try await cache.locate(tool: tool)
}
private actor Cache {
private var cache: [String: Task<URL, Error>] = [:]
private func _locate(tool: String) async throws -> URL {
let pipe = Pipe()
let proc = Process()
proc.executableURL = URL(fileURLWithPath: "/bin/sh")
proc.arguments = ["-c", "command -v '\(tool)'"]
proc.standardOutput = pipe
async let bytes = pipe.fileHandleForReading.readToEnd()
do {
try await proc.runUntilExit()
} catch is Process.Failure {
throw Errors.toolNotFound(tool)
}
let path = String(decoding: try await bytes ?? Data(), as: UTF8.self)
.trimmingCharacters(in: .whitespacesAndNewlines)
return URL(fileURLWithPath: path)
}
func locate(tool: String) async throws -> URL {
let task: Task<URL, Error>
if let cached = cache[tool] {
task = cached
} else {
task = Task { try await _locate(tool: tool) }
cache[tool] = task
}
return try await task.value
}
}
}
+145
View File
@@ -0,0 +1,145 @@
#if os(macOS)
import Foundation
import PathKit
import Version
import ProjectSpec
import XcodeGenKit
import XcodeProj
public struct XcodePacker {
public var plan: Plan
public init(plan: Plan) {
self.plan = plan
}
public func createProject() async throws -> URL {
let targetName = "\(plan.product)-App"
let xtoolDir: Path = "xtool"
let projectDir: Path = xtoolDir + ".xtool-tmp"
try? xtoolDir.delete()
try projectDir.mkpath()
let infoPath = projectDir + "Info.plist"
var plist = plan.infoPlist
let families = (plist.removeValue(forKey: "UIDeviceFamily") as? [Int]) ?? [1, 2]
plist["CFBundleExecutable"] = targetName
plist["CFBundleName"] = targetName
plist["CFBundleDisplayName"] = plan.product
let encodedPlist = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
try infoPath.write(encodedPlist)
let emptyFile = projectDir + "empty.c"
try emptyFile.write(Data("// leave this file empty".utf8))
let fromProjectToRoot = try Path(".").relativePath(from: projectDir)
guard let deploymentTarget = Version(tolerant: plan.deploymentTarget) else {
throw StringError("Could not parse deployment target '\(plan.deploymentTarget)'")
}
let project = Project(
name: plan.product,
targets: [
Target(
name: targetName,
type: .application,
platform: .iOS,
deploymentTarget: deploymentTarget,
settings: Settings(buildSettings: [
"PRODUCT_BUNDLE_IDENTIFIER": plan.bundleID,
"TARGETED_DEVICE_FAMILY": families.map { "\($0)" }.joined(separator: ","),
]),
sources: [
TargetSource(path: (fromProjectToRoot + emptyFile).string),
],
dependencies: [
Dependency(
type: .package(products: [plan.product]),
reference: "RootPackage"
),
],
info: Plist(
path: (fromProjectToRoot + infoPath).string,
attributes: [:]
)
)
],
packages: [
"RootPackage": .local(
path: fromProjectToRoot.string,
group: nil,
excludeFromProject: false
),
],
options: SpecOptions(
localPackagesGroup: ""
)
)
// TODO: Handle plan.resources of type .root
// TODO: Handle plan.iconPath
let generator = ProjectGenerator(project: project)
let xcodeproj = projectDir + "\(plan.product).xcodeproj"
let xcworkspace = xtoolDir + "\(plan.product).xcworkspace"
do {
let current = Path.current
Path.current = xcodeproj.parent()
defer { Path.current = current }
let xcodeProject = try generator.generateXcodeProject(userName: NSUserName())
if let packageRef = xcodeProject.pbxproj.fileReferences.first(where: { $0.name == ".." }) {
for group in xcodeProject.pbxproj.groups {
group.children.removeAll(where: { $0.uuid == packageRef.uuid })
}
xcodeProject.pbxproj.delete(object: packageRef)
}
if let emptyFileRef = xcodeProject.pbxproj.fileReferences.first(where: { $0.path == "empty.c" }),
let existingGroup = xcodeProject.pbxproj.groups.first(where: {
$0.children.contains { $0.uuid == emptyFileRef.uuid }
}),
let existingGroupGroup = xcodeProject.pbxproj.groups.first(where: {
$0.children.contains { $0.uuid == existingGroup.uuid }
}) {
existingGroupGroup.children.removeAll(where: { $0.uuid == existingGroup.uuid })
existingGroupGroup.children.insert(emptyFileRef, at: 0)
xcodeProject.pbxproj.delete(object: existingGroup)
}
try xcodeProject.write(path: Path(xcodeproj.lastComponent))
}
do {
let current = Path.current
Path.current = xcworkspace.parent()
defer { Path.current = current }
let xcworkspaceDirectory = xcworkspace.parent()
let fromWorkspaceToSelf = try Path(".").relativePath(from: xcworkspaceDirectory).withName()
let fromWorkspaceToProject = try xcodeproj.relativePath(from: xcworkspaceDirectory).withName()
let workspace = XCWorkspace(data: .init(children: [
.file(.init(location: .container(fromWorkspaceToSelf.string))),
.file(.init(location: .group(fromWorkspaceToProject.string))),
]))
try workspace.write(path: Path(xcworkspace.lastComponent))
}
return xcworkspace.url
}
}
extension Path {
fileprivate func withName() -> Path {
// eg if curr dir is Foo, this converts "." to "../Foo"
// which includes the name in the path, and therefore
// in the Xcode navigator
self.parent() + self.absolute().lastComponent
}
}
#endif
@@ -1,66 +0,0 @@
//
// DeveloperServicesAddAppIDRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesAddAppIDRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {
let appId: DeveloperServicesAppID
}
public typealias Value = DeveloperServicesAppID
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
public let bundleID: String
public let appName: String
public let entitlements: Entitlements
public let additionalFeatures: [DeveloperServicesFeature]
public let isFree: Bool
var subAction: String { return "addAppId" }
var subParameters: [String: Any] {
var parameters: [String: Any] = [
"teamId": teamID.rawValue,
"identifier": bundleID,
"name": appName
]
DeveloperServicesAppIDRequestApplier.apply(
entitlements: entitlements,
additionalFeatures: additionalFeatures,
to: &parameters,
isFree: isFree
)
return parameters
}
public func parse(_ response: Response) -> DeveloperServicesAppID {
response.appId
}
public init(
platform: DeveloperServicesPlatform,
teamID: DeveloperServicesTeam.ID,
bundleID: String,
appName: String,
entitlements: Entitlements,
additionalFeatures: [DeveloperServicesFeature],
isFree: Bool
) {
self.platform = platform
self.teamID = teamID
self.bundleID = bundleID
self.appName = appName
self.entitlements = entitlements
self.additionalFeatures = additionalFeatures
self.isFree = isFree
}
}
@@ -1,192 +0,0 @@
//
// DeveloperServicesAddAppOperation.swift
// Supersign
//
// Created by Kabir Oberai on 14/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {
public enum Error: LocalizedError {
case invalidApp(URL)
case teamNotFound(DeveloperServicesTeam.ID)
public var errorDescription: String? {
switch self {
case .invalidApp(let url):
return url.path.withCString {
String.localizedStringWithFormat(
NSLocalizedString(
"add_app_operation.error.invalid_app", value: "Invalid app: %s", comment: ""
), $0
)
}
case .teamNotFound(let id):
return id.rawValue.withCString {
String.localizedStringWithFormat(
NSLocalizedString(
"add_app_operation.error.team_not_found",
value: "A team with the ID '%s' could not be found. Please select another team.",
comment: ""
), $0
)
}
}
}
}
public let context: SigningContext
public let root: URL
public init(context: SigningContext, root: URL) {
self.context = context
self.root = root
}
/// Registers the app with the given entitlements
private func upsertApp(
bundleID: String,
entitlements: Entitlements,
team: DeveloperServicesTeam,
appIDs: [String: DeveloperServicesAppID]
) async throws -> DeveloperServicesAppID {
if let appID = appIDs[bundleID] {
let request = DeveloperServicesUpdateAppIDRequest(
platform: self.context.platform,
teamID: self.context.teamID,
appIDID: appID.id,
entitlements: entitlements,
additionalFeatures: [],
isFree: team.isFree
)
return try await context.client.send(request)
} else {
let newBundleID = ProvisioningIdentifiers.identifier(fromSanitized: bundleID, context: self.context)
let name = ProvisioningIdentifiers.appName(fromSanitized: bundleID)
let request = DeveloperServicesAddAppIDRequest(
platform: self.context.platform,
teamID: self.context.teamID,
bundleID: newBundleID,
appName: name,
entitlements: entitlements,
additionalFeatures: [],
isFree: team.isFree
)
return try await context.client.send(request)
}
}
/// Registers the app and creates a profile. Returns the resultant entitlements as well as
/// the profile (note that the profile does not necessarily include all of the entitlements
/// that the app has).
private func addApp(
_ app: URL,
team: DeveloperServicesTeam,
appIDs: [String: DeveloperServicesAppID]
) async throws -> ProvisioningInfo {
let infoURL = app.appendingPathComponent("Info.plist")
guard let data = try? Data(contentsOf: infoURL),
let dict = try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any],
let bundleID = dict["CFBundleIdentifier"] as? String,
let executable = dict["CFBundleExecutable"] as? String else {
throw Error.invalidApp(app)
}
let executableURL = app.appendingPathComponent(executable)
var entitlements: Entitlements
// if the executable doesn't already have entitlements, that's
// okay. We don't have to throw an error.
if let entitlementsData = try? await context.signerImpl.analyze(executable: executableURL),
let decodedEntitlements = try? PropertyListDecoder().decode(Entitlements.self, from: entitlementsData) {
entitlements = decodedEntitlements
if team.isFree {
// re-assign rather than using updateEntitlements since the latter will
// retain unrecognized entitlements
let filtered = try entitlements.entitlements().filter { type(of: $0).isFree }
entitlements = try Entitlements(entitlements: filtered)
}
} else {
entitlements = try Entitlements(entitlements: [])
}
let appID = try await upsertApp(bundleID: bundleID, entitlements: entitlements, team: team, appIDs: appIDs)
try entitlements.update(teamID: self.context.teamID, bundleID: appID.bundleID)
// set get-task-allow to YES, required for dev certs
try entitlements.updateEntitlements { ents in
if let getTaskAllow = ents.firstIndex(where: { $0 is GetTaskAllowEntitlement }) {
ents[getTaskAllow] = GetTaskAllowEntitlement(rawValue: true)
} else {
ents.append(GetTaskAllowEntitlement(rawValue: true))
}
}
if var entitlementsArray = try? entitlements.entitlements(),
let groupsIdx = entitlementsArray.firstIndex(where: { $0 is AppGroupEntitlement }),
let groupsEntitlement = entitlementsArray[groupsIdx] as? AppGroupEntitlement {
let groups = groupsEntitlement.rawValue
let newGroups = try await DeveloperServicesAssignAppGroupsOperation(
context: self.context,
groupIDs: groups,
appID: appID
).perform()
entitlementsArray[groupsIdx] = AppGroupEntitlement(rawValue: newGroups)
try entitlements.setEntitlements(entitlementsArray)
}
let profile = try await DeveloperServicesFetchProfileOperation(context: self.context, appID: appID).perform()
guard let mobileprovision = profile.mobileprovision
else { throw Mobileprovision.Error.invalidProfile }
return ProvisioningInfo(
newBundleID: appID.bundleID, entitlements: entitlements, mobileprovision: mobileprovision
)
}
private func getTeam() async throws -> DeveloperServicesTeam {
let request = DeveloperServicesListTeamsRequest()
let teams = try await context.client.send(request)
guard let team = teams.first(where: { $0.id == self.context.teamID })
else { throw Error.teamNotFound(self.context.teamID) }
return team
}
// keyed by sanitized bundle ID
private func getCurrentAppIDs() async throws -> [String: DeveloperServicesAppID] {
let request = DeveloperServicesListAppIDsRequest(platform: context.platform, teamID: context.teamID)
let appIDs = try await context.client.send(request)
let keyedIDs = appIDs.map { (ProvisioningIdentifiers.sanitize(identifier: $0.bundleID), $0) }
return Dictionary(keyedIDs, uniquingKeysWith: { $1 })
}
/// Registers the app + its extensions, returning the profile and entitlements of each
public func perform() async throws -> [URL: ProvisioningInfo] {
var apps: [URL] = [root]
let plugins = root.appendingPathComponent("PlugIns")
if plugins.dirExists {
apps += plugins.implicitContents.filter { $0.pathExtension.lowercased() == "appex" }
}
async let teamTask = getTeam()
async let appIDsTask = getCurrentAppIDs()
let (team, appIDs) = try await (teamTask, appIDsTask)
return try await withThrowingTaskGroup(
of: (URL, ProvisioningInfo).self,
returning: [URL: ProvisioningInfo].self
) { group in
for app in apps {
group.addTask {
let info = try await addApp(app, team: team, appIDs: appIDs)
return (app, info)
}
}
return try await group.reduce(into: [:]) { $0[$1.0] = $1.1 }
}
}
}
@@ -1,47 +0,0 @@
//
// DeveloperServiceAppID.swift
// Supercharge
//
// Created by Kabir Oberai on 29/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
import ProtoCodable
public struct DeveloperServicesAppID: Decodable, Sendable {
public struct ID: RawRepresentable, Decodable, Sendable {
public let rawValue: String
public init(rawValue: String) { self.rawValue = rawValue }
}
public let id: ID
public let name: String
public let platform: DeveloperServicesPlatform
public let bundleID: String
public let isWildCard: Bool
private let _features: DeveloperServicesFeatures
public var features: [DeveloperServicesFeature] { return _features.values }
private let _enabledFeatures: [String]?
public var enabledFeatures: [DeveloperServicesFeature.Type] {
guard let enabledFeatures = _enabledFeatures else { return [] }
return enabledFeatures.compactMap { identifier in
let type = ProtoCodableIdentifierMapper.shared.type(
for: identifier, in: DeveloperServicesFeatureContainer.self
)
return type as? DeveloperServicesFeature.Type
}
}
private enum CodingKeys: String, CodingKey {
case id = "appIdId"
case name
case platform = "appIdPlatform"
case bundleID = "identifier"
case isWildCard
case _features = "features"
case _enabledFeatures = "enabledFeatures"
}
}
@@ -1,33 +0,0 @@
//
// DeveloperServicesAppIDRequestApplier.swift
// Supersign
//
// Created by Kabir Oberai on 11/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
enum DeveloperServicesAppIDRequestApplier {
static func apply(
entitlements: Entitlements, additionalFeatures: [DeveloperServicesFeature],
to dict: inout [String: Any], isFree: Bool
) {
var entitlements = entitlements
try? entitlements.updateEntitlements {
$0.removeAll {
let type = Swift.type(of: $0)
return !type.canList || (isFree && !type.isFree)
}
}
dict["entitlements"] = try? entitlements.plistValue()
let entFeatures = (try? entitlements.entitlements().compactMap { $0.feature() }) ?? []
let allFeatures = entFeatures + additionalFeatures
guard let features = try? DeveloperServicesFeatures(values: allFeatures).plistValue() as? [String: Any]
else { return }
dict.merge(features) { a, _ in a }
}
}
@@ -1,35 +0,0 @@
//
// DeveloperServicesDeleteAppIDRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesDeleteAppIDRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {}
public typealias Value = Response
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
public let appIDID: DeveloperServicesAppID.ID
var subAction: String { return "deleteAppId" }
var subParameters: [String: Any] {
return ["teamId": teamID.rawValue, "appIdId": appIDID.rawValue]
}
public init(
platform: DeveloperServicesPlatform,
teamID: DeveloperServicesTeam.ID,
appIDID: DeveloperServicesAppID.ID
) {
self.platform = platform
self.teamID = teamID
self.appIDID = appIDID
}
}
@@ -1,35 +0,0 @@
//
// DeveloperServicesListAppIDsRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesListAppIDsRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {
public let appIds: [DeveloperServicesAppID]
}
public typealias Value = [DeveloperServicesAppID]
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
var subAction: String { return "listAppIds" }
var subParameters: [String: Any] {
return ["teamId": teamID.rawValue]
}
public func parse(_ response: Response) -> [DeveloperServicesAppID] {
response.appIds
}
public init(platform: DeveloperServicesPlatform, teamID: DeveloperServicesTeam.ID) {
self.platform = platform
self.teamID = teamID
}
}
@@ -1,62 +0,0 @@
//
// DeveloperServicesUpdateAppIDRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesUpdateAppIDRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {
let appId: DeveloperServicesAppID
}
public typealias Value = DeveloperServicesAppID
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
public let appIDID: DeveloperServicesAppID.ID
public let entitlements: Entitlements
public let additionalFeatures: [DeveloperServicesFeature]
public let isFree: Bool
var subAction: String { return "updateAppId" }
var subParameters: [String: Any] {
var parameters: [String: Any] = [
"teamId": teamID.rawValue,
"appIdId": appIDID.rawValue
]
DeveloperServicesAppIDRequestApplier.apply(
entitlements: entitlements,
additionalFeatures: additionalFeatures,
to: &parameters,
isFree: isFree
)
return parameters
}
public func parse(_ response: Response) -> DeveloperServicesAppID {
response.appId
}
public init(
platform: DeveloperServicesPlatform,
teamID: DeveloperServicesTeam.ID,
appIDID: DeveloperServicesAppID.ID,
entitlements: Entitlements,
additionalFeatures: [DeveloperServicesFeature],
isFree: Bool
) {
self.platform = platform
self.teamID = teamID
self.appIDID = appIDID
self.entitlements = entitlements
self.additionalFeatures = additionalFeatures
self.isFree = isFree
}
}
@@ -1,38 +0,0 @@
//
// Entitlement+DeveloperServicesFeature.swift
// Supersign
//
// Created by Kabir Oberai on 09/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
protocol BaseEntitlementWithFeature: Entitlement {
func baseFeature() -> DeveloperServicesFeature
}
protocol EntitlementWithFeature: BaseEntitlementWithFeature {
associatedtype Feature: DeveloperServicesFeature
func typedFeature() -> Feature
}
extension EntitlementWithFeature {
func baseFeature() -> DeveloperServicesFeature {
return typedFeature()
}
}
extension EntitlementWithFeature
where Self: RawRepresentable,
Feature: RawRepresentable,
RawValue == Feature.RawValue {
func typedFeature() -> Feature {
return Feature(rawValue: rawValue)!
}
}
public extension Entitlement {
func feature() -> DeveloperServicesFeature? {
return (self as? BaseEntitlementWithFeature)?.baseFeature()
}
}
@@ -1,273 +0,0 @@
//
// DeveloperServicesFeatureTypes.swift
// Supercharge
//
// Created by Kabir Oberai on 29/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
import ProtoCodable
// swiftlint:disable type_name
extension DeveloperServicesFeatureContainer {
static let supportedTypes: [ProtoCodable.Type] = [
DeveloperServicesCloudKitFeature.self,
DeveloperServicesDataProtectionFeature.self,
DeveloperServicesAccessWifiFeature.self,
DeveloperServicesAppGroupFeature.self,
DeveloperServicesApplePayFeature.self,
DeveloperServicesAssociatedDomainsFeature.self,
DeveloperServicesClassKitFeature.self,
DeveloperServicesAutoFillCredentialFeature.self,
DeveloperServicesGameCenterFeature.self,
DeveloperServicesHealthKitFeature.self,
DeveloperServicesHomeKitFeature.self,
DeveloperServicesHotspotFeature.self,
DeveloperServicesCloudFeature.self,
DeveloperServicesInAppPurchaseFeature.self,
DeveloperServicesInterAppAudioFeature.self,
DeveloperServicesMultipathFeature.self,
DeveloperServicesNetworkExtensionFeature.self,
DeveloperServicesNFCTagReadingFeature.self,
DeveloperServicesPersonalVPNFeature.self,
DeveloperServicesPassbookFeature.self,
DeveloperServicesPushNotificationFeature.self,
DeveloperServicesSiriKitFeature.self,
DeveloperServicesVPNConfigurationFeature.self,
DeveloperServicesWalletFeature.self,
DeveloperServicesWirelessAccessoryFeature.self,
]
}
// MARK: - Special Features
public enum DeveloperServicesCloudKitFeature: Int, DeveloperServicesFeature {
public static let identifier = "cloudKitVersion"
case xcode5Compatible = 1
case cloudKit = 2
}
public enum DeveloperServicesDataProtectionFeature: String, DeveloperServicesFeature {
public static let identifier = "dataProtection"
case off = ""
case complete
case unlessOpen = "unlessopen"
case untilFirstAuth = "untilfirstauth"
}
extension DataProtectionEntitlement: EntitlementWithFeature {
func typedFeature() -> DeveloperServicesDataProtectionFeature {
switch self {
case .complete: return .complete
case .unlessOpen: return .unlessOpen
case .untilFirstAuth: return .untilFirstAuth
}
}
}
// MARK: - Boolean Features
// https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/portal/app_service.rb
public struct DeveloperServicesAccessWifiFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "AWEQ28MY3E"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesAppGroupFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "APG3427HIY"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension AppGroupEntitlement: EntitlementWithFeature {
func typedFeature() -> DeveloperServicesAppGroupFeature {
.init(rawValue: !rawValue.isEmpty)
}
}
public struct DeveloperServicesApplePayFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "OM633U5T5G"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesAssociatedDomainsFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "SKC3T5S89Y"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension AssociatedDomainsEntitlement: EntitlementWithFeature {
func typedFeature() -> DeveloperServicesAssociatedDomainsFeature {
.init(rawValue: true)
}
}
public struct DeveloperServicesClassKitFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "PKTJAN2017"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesAutoFillCredentialFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "CPEQ28MX4E"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesGameCenterFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "gameCenter"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesHealthKitFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "HK421J6T7P"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension HealthKitEntitlement: EntitlementWithFeature {
typealias Feature = DeveloperServicesHealthKitFeature
}
public struct DeveloperServicesHomeKitFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "homeKit"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension HomeKitEntitlement: EntitlementWithFeature {
typealias Feature = DeveloperServicesHomeKitFeature
}
public struct DeveloperServicesHotspotFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "HSC639VEI8"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesCloudFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "iCloud"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesInAppPurchaseFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "inAppPurchase"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesInterAppAudioFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "IAD53UNK2F"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension InterAppAudioEntitlement: EntitlementWithFeature {
typealias Feature = DeveloperServicesInterAppAudioFeature
}
public struct DeveloperServicesMultipathFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "MP49FN762P"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension MultipathEntitlement: EntitlementWithFeature {
typealias Feature = DeveloperServicesMultipathFeature
}
public struct DeveloperServicesNetworkExtensionFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "NWEXT04537"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension NetworkExtensionEntitlement: EntitlementWithFeature {
typealias Feature = DeveloperServicesNetworkExtensionFeature
}
public struct DeveloperServicesNFCTagReadingFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "NFCTRMAY17"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesPersonalVPNFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "V66P55NK2I"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesPassbookFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "passbook"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesPushNotificationFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "push"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension APSEnvironmentEntitlement: EntitlementWithFeature {
func typedFeature() -> DeveloperServicesPushNotificationFeature {
.init(rawValue: true)
}
}
public struct DeveloperServicesSiriKitFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "SI015DKUHP"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension SiriKitEntitlement: EntitlementWithFeature {
typealias Feature = DeveloperServicesSiriKitFeature
}
public struct DeveloperServicesVPNConfigurationFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "V66P55NK2I"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension VPNConfigurationEntitlement: EntitlementWithFeature {
typealias Feature = DeveloperServicesVPNConfigurationFeature
}
public struct DeveloperServicesWalletFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "pass"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
public struct DeveloperServicesWirelessAccessoryFeature: DeveloperServicesFeature, RawRepresentable {
public static let identifier = "WC421J6T7P"
public let rawValue: Bool
public init(rawValue: Bool) { self.rawValue = rawValue }
}
extension WirelessAccessoryEntitlement: EntitlementWithFeature {
typealias Feature = DeveloperServicesWirelessAccessoryFeature
}
@@ -1,16 +0,0 @@
//
// DeveloperServicesFeatures.swift
// Supercharge
//
// Created by Kabir Oberai on 19/09/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
import ProtoCodable
struct DeveloperServicesFeatureContainer: ProtoCodableContainer {
var value: DeveloperServicesFeature
}
typealias DeveloperServicesFeatures = ProtoCodableKeyValueContainer<DeveloperServicesFeatureContainer>
@@ -1,35 +0,0 @@
//
// DeveloperServicesCSRResponse.swift
// Supersign
//
// Created by Kabir Oberai on 09/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesCSRResponse: Decodable, Sendable {
public struct ID: RawRepresentable, Decodable, Sendable {
public let rawValue: String
public init(rawValue: String) { self.rawValue = rawValue }
}
public let id: ID
public let certificateID: DeveloperServicesCertificate.ID
public let serialNumber: DeveloperServicesCertificate.SerialNumber
public let status: String
public let statusCode: Int
public let platform: DeveloperServicesPlatform
public let machineID: String?
public let machineName: String?
private enum CodingKeys: String, CodingKey {
case id = "certRequestId"
case certificateID = "certificateId"
case serialNumber = "serialNum"
case status = "statusString"
case statusCode
case platform = "csrPlatform"
case machineID = "machineId"
case machineName
}
}
@@ -1,67 +0,0 @@
//
// DeveloperServicesCertificate.swift
// Supercharge
//
// Created by Kabir Oberai on 29/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesCertificate: Decodable, Sendable {
public struct ID: RawRepresentable, Decodable, Sendable {
public let rawValue: String
public init(rawValue: String) { self.rawValue = rawValue }
}
public let id: ID
public struct SerialNumber: RawRepresentable, Decodable, Sendable {
public let rawValue: String
public init(rawValue: String) { self.rawValue = rawValue }
}
public enum Kind: String, Decodable, CaseIterable, Sendable {
case development = "DEVELOPMENT"
case distribution = "DISTRIBUTION"
case iOSDevelopment = "IOS_DEVELOPMENT"
case iOSDistribution = "IOS_DISTRIBUTION"
case macAppDistribution = "MAC_APP_DISTRIBUTION"
case macInstallerDistribution = "MAC_INSTALLER_DISTRIBUTION"
case developerIDKext = "DEVELOPER_ID_KEXT"
case developerIDApplication = "DEVELOPER_ID_APPLICATION"
case unknown
public init(platform: DeveloperServicesPlatform) {
switch platform {
case .iOS: self = .iOSDevelopment
default: self = .development
}
}
public init(from decoder: Decoder) throws {
let rawValue = try String(from: decoder)
self = Self.allCases.first { $0.rawValue == rawValue } ?? .unknown
}
}
public struct Attributes: Decodable, Sendable {
public let serialNumber: SerialNumber
public let name: String
public let kind: Kind
public let expiry: Date
public let machineID: String?
public let machineName: String?
public let content: Certificate
private enum CodingKeys: String, CodingKey {
case serialNumber
case name
case kind = "certificateType"
case expiry = "expirationDate"
case content = "certificateContent"
case machineID = "machineId"
case machineName
}
}
public let attributes: Attributes
}
@@ -1,109 +0,0 @@
//
// DeveloperServicesFetchCertificateOperation.swift
// Supersign
//
// Created by Kabir Oberai on 13/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOperation {
public enum Error: LocalizedError {
case csrFailed
case userCancelled
public var errorDescription: String? {
switch self {
case .csrFailed:
return NSLocalizedString(
"fetch_certificate_operation.error.csr_failed", value: "CSR request failed", comment: ""
)
case .userCancelled:
return NSLocalizedString(
"fetch_certificate_operation.error.user_cancelled", value: "The operation was cancelled", comment: ""
)
}
}
}
public let context: SigningContext
public let confirmRevocation: @Sendable ([DeveloperServicesCertificate]) async -> Bool
public init(
context: SigningContext,
confirmRevocation: @escaping @Sendable ([DeveloperServicesCertificate]) async -> Bool
) {
self.context = context
self.confirmRevocation = confirmRevocation
}
private func createCertificate() async throws -> SigningInfo {
let keypair = try Keypair()
let csr = try keypair.generateCSR()
let privateKey = try keypair.privateKey()
let request = DeveloperServicesSubmitCSRRequest(
platform: context.platform,
teamID: context.teamID,
csr: csr,
machineName: "Supercharge: \(SigningContext.hostName)",
machineID: context.client.deviceInfo.deviceID
)
let partialCert = try await context.client.send(request)
let serialNumber = partialCert.serialNumber
let listRequest = DeveloperServicesListCertificatesRequest(
teamID: self.context.teamID, certificateKind: .init(platform: self.context.platform)
)
let certificates = try await context.client.send(listRequest)
guard let fullCert = certificates.first(where: { $0.attributes.serialNumber == serialNumber })
else { throw Error.csrFailed }
return .init(privateKey: privateKey, certificate: fullCert.attributes.content)
}
private func revokeCreateSaveCertificate(certificates: [DeveloperServicesCertificate]) async throws -> SigningInfo {
if !certificates.isEmpty {
guard await confirmRevocation(certificates)
else { throw CancellationError() }
}
try await withThrowingTaskGroup(of: Void.self) { group in
for certificate in certificates {
group.addTask {
let request = DeveloperServicesRevokeCertificateRequest(
teamID: context.teamID, certificateID: certificate.id
)
_ = try await context.client.send(request)
}
}
try await group.waitForAll()
}
let signingInfo = try await createCertificate()
self.context.signingInfoManager[self.context.teamID] = signingInfo
return signingInfo
}
public func perform() async throws -> SigningInfo {
let request = DeveloperServicesListCertificatesRequest(
teamID: context.teamID, certificateKind: .init(platform: context.platform)
)
let certificates = try await context.client.send(request)
guard let certificate = certificates.first(where: {
$0.attributes.machineID == self.context.client.deviceInfo.deviceID
}) else {
// we need to revoke existing certs, otherwise it doesn't always let us make a new one
return try await self.revokeCreateSaveCertificate(certificates: certificates)
}
guard let signingInfo = self.context.signingInfoManager[self.context.teamID],
certificate.attributes.serialNumber.rawValue == signingInfo.certificate.serialNumber(),
certificate.attributes.expiry > Date() else {
// we have a certificate for this machine but it's not usable
return try await self.revokeCreateSaveCertificate(certificates: [certificate])
}
return signingInfo
}
}
@@ -1,35 +0,0 @@
//
// DeveloperServicesListCertificatesRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesListCertificatesRequest: DeveloperServicesRequest, Sendable {
public typealias Response = [DeveloperServicesCertificate]
public typealias Value = Response
public var apiVersion: DeveloperServicesAPIVersion { DeveloperServicesAPIVersionV1() }
public var methodOverride: String? { "GET" }
public let teamID: DeveloperServicesTeam.ID
public let certificateKind: DeveloperServicesCertificate.Kind
public var action: String { "certificates" }
public var parameters: [String: Any] {
[
"teamId": teamID.rawValue,
"filter[certificateType]": certificateKind.rawValue
]
}
public init(teamID: DeveloperServicesTeam.ID, certificateKind: DeveloperServicesCertificate.Kind) {
self.teamID = teamID
self.certificateKind = certificateKind
}
}
@@ -1,36 +0,0 @@
//
// DeveloperServicesRevokeCertificateRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
// swiftlint:disable:next type_name
public struct DeveloperServicesRevokeCertificateRequest: DeveloperServicesRequest {
public typealias Response = EmptyResponse
public typealias Value = Response
public var apiVersion: DeveloperServicesAPIVersion { DeveloperServicesAPIVersionV1() }
public var methodOverride: String? { "DELETE" }
public let teamID: DeveloperServicesTeam.ID
public let certificateID: DeveloperServicesCertificate.ID
public var action: String { "certificates/\(certificateID.rawValue)" }
public var parameters: [String: Any] {
["teamId": teamID.rawValue]
}
public init(
teamID: DeveloperServicesTeam.ID,
certificateID: DeveloperServicesCertificate.ID
) {
self.teamID = teamID
self.certificateID = certificateID
}
}
@@ -1,52 +0,0 @@
//
// DeveloperServicesSubmitCSRRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public final class DeveloperServicesSubmitCSRRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {
public let certRequest: DeveloperServicesCSRResponse
}
public typealias Value = DeveloperServicesCSRResponse
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
public let csr: CSR
public let machineName: String
public let machineID: String
var subAction: String { return "submitDevelopmentCSR" }
var subParameters: [String: Any] {
return [
"teamId": teamID.rawValue,
"csrContent": csr.pemString,
"machineId": machineID,
"machineName": machineName
]
}
public func parse(_ response: Response) -> DeveloperServicesCSRResponse {
response.certRequest
}
public init(
platform: DeveloperServicesPlatform,
teamID: DeveloperServicesTeam.ID,
csr: CSR,
machineName: String,
machineID: String
) {
self.platform = platform
self.teamID = teamID
self.csr = csr
self.machineName = machineName
self.machineID = machineID
}
}
@@ -1,48 +0,0 @@
//
// DeveloperServicesAddDeviceRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesAddDeviceRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {
let device: DeveloperServicesDevice
}
public typealias Value = DeveloperServicesDevice
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
public let udid: String
public let name: String
var subAction: String { return "addDevice" }
var subParameters: [String: Any] {
return [
"teamId": teamID.rawValue,
"deviceNumber": udid,
"name": name
]
}
public func parse(_ response: Response) -> DeveloperServicesDevice {
response.device
}
public init(
platform: DeveloperServicesPlatform,
teamID: DeveloperServicesTeam.ID,
udid: String,
name: String
) {
self.platform = platform
self.teamID = teamID
self.udid = udid
self.name = name
}
}
@@ -1,32 +0,0 @@
//
// DeveloperServicesDevice.swift
// Supercharge
//
// Created by Kabir Oberai on 07/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesDevice: Decodable, Sendable {
public struct ID: RawRepresentable, Decodable, Sendable {
public let rawValue: String
public init(rawValue: String) { self.rawValue = rawValue }
}
public let id: ID
public let name: String
public let udid: String
public let platform: DeveloperServicesPlatform
public let type: String // TODO: Create enum
public let model: String?
private enum CodingKeys: String, CodingKey {
case id = "deviceId"
case name
case udid = "deviceNumber"
case platform = "devicePlatform"
case type = "deviceClass"
case model
}
}
@@ -1,33 +0,0 @@
//
// DeveloperServicesFetchDeviceOperation.swift
// Supersign
//
// Created by Kabir Oberai on 13/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesFetchDeviceOperation: DeveloperServicesOperation {
public let context: SigningContext
public init(context: SigningContext) {
self.context = context
}
public func perform() async throws -> DeveloperServicesDevice {
let listRequest = DeveloperServicesListDevicesRequest(platform: context.platform, teamID: context.teamID)
let devices = try await context.client.send(listRequest)
if let device = devices.first(where: { $0.udid == self.context.udid }) {
return device
}
let addRequest = DeveloperServicesAddDeviceRequest(
platform: self.context.platform,
teamID: self.context.teamID,
udid: self.context.udid,
name: self.context.deviceName
)
return try await context.client.send(addRequest)
}
}
@@ -1,39 +0,0 @@
//
// DeveloperServicesListDevicesRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesListDevicesRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {
public let devices: [DeveloperServicesDevice]
}
public typealias Value = [DeveloperServicesDevice]
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
var subAction: String { return "listDevices" }
var subParameters: [String: Any] {
return [
"teamId": teamID.rawValue,
"pageSize": "500",
"includeRemovedDevices": "false"
]
}
public func parse(_ response: Response) -> Value {
response.devices
}
public init(platform: DeveloperServicesPlatform, teamID: DeveloperServicesTeam.ID) {
self.platform = platform
self.teamID = teamID
}
}
@@ -1,35 +0,0 @@
//
// DeveloperServicesDeleteProfileRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesDeleteProfileRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {}
public typealias Value = Response
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
public let profileID: DeveloperServicesProfile.ID
var subAction: String { return "deleteProvisioningProfile" }
var subParameters: [String: Any] {
return ["teamId": teamID.rawValue, "provisioningProfileId": profileID.rawValue]
}
public init(
platform: DeveloperServicesPlatform,
teamID: DeveloperServicesTeam.ID,
profileID: DeveloperServicesProfile.ID
) {
self.platform = platform
self.teamID = teamID
self.profileID = profileID
}
}
@@ -1,35 +0,0 @@
//
// DeveloperServicesFetchProfileOperation.swift
// Supersign
//
// Created by Kabir Oberai on 13/10/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
import Superutils
public struct DeveloperServicesFetchProfileOperation: DeveloperServicesOperation {
public let context: SigningContext
public let appID: DeveloperServicesAppID
public init(context: SigningContext, appID: DeveloperServicesAppID) {
self.context = context
self.appID = appID
}
public func perform() async throws -> DeveloperServicesProfile {
let profiles = try await context.client.send(DeveloperServicesListProfilesRequest(
platform: context.platform, teamID: context.teamID
))
if let profile = profiles.first(where: { $0.appID.id == self.appID.id }) {
_ = try await context.client.send(DeveloperServicesDeleteProfileRequest(
platform: context.platform, teamID: context.teamID, profileID: profile.id
))
}
return try await context.client.send(DeveloperServicesGetProfileRequest(
platform: context.platform, teamID: context.teamID, appIDID: appID.id
))
}
}
@@ -1,41 +0,0 @@
//
// DeveloperServicesGetProfileRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesGetProfileRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {
public let provisioningProfile: DeveloperServicesProfile
}
public typealias Value = DeveloperServicesProfile
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
public let appIDID: DeveloperServicesAppID.ID
var subAction: String { return "downloadTeamProvisioningProfile" }
var subParameters: [String: Any] {
return ["teamId": teamID.rawValue, "appIdId": appIDID.rawValue]
}
public func parse(_ response: Response) -> DeveloperServicesProfile {
response.provisioningProfile
}
public init(
platform: DeveloperServicesPlatform,
teamID: DeveloperServicesTeam.ID,
appIDID: DeveloperServicesAppID.ID
) {
self.platform = platform
self.teamID = teamID
self.appIDID = appIDID
}
}
@@ -1,35 +0,0 @@
//
// DeveloperServicesListProfilesRequest.swift
// Supercharge
//
// Created by Kabir Oberai on 24/07/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct DeveloperServicesListProfilesRequest: DeveloperServicesPlatformRequest {
public struct Response: Decodable, Sendable {
public let provisioningProfiles: [DeveloperServicesProfile]
}
public typealias Value = [DeveloperServicesProfile]
public let platform: DeveloperServicesPlatform
public let teamID: DeveloperServicesTeam.ID
var subAction: String { return "listProvisioningProfiles" }
var subParameters: [String: Any] {
return ["teamId": teamID.rawValue]
}
public func parse(_ response: Response) -> [DeveloperServicesProfile] {
response.provisioningProfiles
}
public init(platform: DeveloperServicesPlatform, teamID: DeveloperServicesTeam.ID) {
self.platform = platform
self.teamID = teamID
}
}

Some files were not shown because too many files have changed in this diff Show More