Compare commits
141 Commits
@@ -0,0 +1,8 @@
|
||||
*
|
||||
!/Package.swift
|
||||
!/Package.resolved
|
||||
!/Sources
|
||||
!/Tests
|
||||
!/Linux
|
||||
/Linux/packages
|
||||
/Linux/staging
|
||||
@@ -0,0 +1,17 @@
|
||||
## What does this PR do?
|
||||
|
||||
<!-- Focus on *what* the PR does in essence. The *how* should come second, if it's relevant. -->
|
||||
|
||||
## How was it tested?
|
||||
|
||||
<!-- e.g. Ran locally on macOS and added unit tests -->
|
||||
|
||||
## AI tool usage
|
||||
|
||||
How much of the code in this PR was AI-assisted? (check one)
|
||||
|
||||
- [ ] **0** - No AI was used to write code
|
||||
- [ ] **1** - I was assisted by AI in writing code. I reviewed the finished result.
|
||||
- [ ] **2** - I set the AI going and left it to it; nobody has read the result - no review, or AI review only
|
||||
|
||||
<!-- If an AI agent is filling this in: declare the level honestly, and open as a draft if it is #2. Do not lower the declared level to get the PR reviewed. -->
|
||||
@@ -0,0 +1,9 @@
|
||||
name: 'Configure Xcode'
|
||||
description: 'Set up Xcode version'
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Set up Xcode
|
||||
shell: bash
|
||||
run: |
|
||||
sudo xcode-select -s /Applications/Xcode_27.1.0.app
|
||||
@@ -1,5 +1,13 @@
|
||||
on:
|
||||
- push
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
env:
|
||||
XTL_CI: "1"
|
||||
jobs:
|
||||
build-linux:
|
||||
strategy:
|
||||
@@ -13,23 +21,29 @@ jobs:
|
||||
runs-on: ${{ matrix.host.runner }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Build
|
||||
uses: actions/checkout@v6
|
||||
- name: Build and test
|
||||
run: |
|
||||
docker compose run --build --rm xtool swift build --product xtool
|
||||
docker compose run --build -e XTL_CI=1 xtool bash -c \
|
||||
"swift build --product xtool && .build/debug/xtool --help && swift test"
|
||||
build-macos:
|
||||
runs-on: macos-15
|
||||
runs-on: xcode-27
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- uses: ./.github/actions/configure-xcode
|
||||
- name: Build
|
||||
run: |
|
||||
swift build --product xtool
|
||||
swift build --product xtool && .build/debug/xtool --help
|
||||
- name: Run tests
|
||||
run: |
|
||||
swift test
|
||||
build-ios:
|
||||
runs-on: macos-15
|
||||
runs-on: xcode-27
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- uses: ./.github/actions/configure-xcode
|
||||
- name: Build
|
||||
run: |
|
||||
set -o pipefail \
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
jobs:
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: macos-15
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
- name: Build DocC
|
||||
run: |
|
||||
./scripts/build-docs.sh
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: 'docs'
|
||||
- id: deployment
|
||||
name: Deploy to GitHub Pages
|
||||
uses: actions/deploy-pages@v4
|
||||
@@ -0,0 +1,18 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
concurrency:
|
||||
group: integration-${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
integration-test-linux:
|
||||
# https://github.com/xtool-org/mac-actions-runner
|
||||
runs-on: ubuntu-on-macos
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
./integration-tests/run.sh
|
||||
@@ -1,5 +1,10 @@
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
env:
|
||||
XTL_CI: "1"
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
@@ -16,24 +21,28 @@ jobs:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: Build
|
||||
run: |
|
||||
docker compose run --build --rm xtool Linux/build.sh
|
||||
docker compose run --build \
|
||||
-e XTOOL_VERSION=${{ github.ref_name }} \
|
||||
-e XTL_CI=1 \
|
||||
--rm xtool Linux/build.sh
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
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
|
||||
runs-on: xcode-27
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- uses: ./.github/actions/configure-xcode
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
@@ -46,11 +55,13 @@ jobs:
|
||||
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: |
|
||||
brew install -y xcodegen
|
||||
cd macOS
|
||||
bundle exec fastlane package
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: xtool-mac
|
||||
path: |
|
||||
@@ -64,14 +75,35 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: xtool-*
|
||||
path: output
|
||||
- name: Create and publish release
|
||||
run: |
|
||||
TAG="${GITHUB_REF##*/}-${GITHUB_SHA:0:7}"
|
||||
gh release create "$TAG" --draft --title "Draft Release"
|
||||
TAG="${{ github.ref_name }}"
|
||||
gh release create "$TAG" --draft --title "v$TAG"
|
||||
gh release upload "$TAG" output/**/*.{AppImage,AppImage.zsync,app.zip,app.dSYM.zip}
|
||||
docker:
|
||||
uses: docker/github-builder/.github/workflows/build.yml@v1
|
||||
permissions:
|
||||
contents: read # to fetch the repository content
|
||||
id-token: write # for signing attestations and cache entries with GitHub OIDC
|
||||
packages: write # to push built images to GitHub Container Registry
|
||||
with:
|
||||
build-args: |
|
||||
XTL_CI=1
|
||||
output: image
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
meta-images: |
|
||||
ghcr.io/xtool-org/xtool
|
||||
meta-tags: |
|
||||
type=semver,pattern={{version}}
|
||||
secrets:
|
||||
registry-auths: |
|
||||
- registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/swiftlint.yml'
|
||||
- '.swiftlint.yml'
|
||||
- '**/*.swift'
|
||||
jobs:
|
||||
swiftlint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Lint
|
||||
run: |
|
||||
make lint SWIFTLINT_FLAGS='--reporter=github-actions-logging' | tee swiftlint.log
|
||||
# fail if there are any errors or warnings
|
||||
! grep -Eq '^::(error|warning)' swiftlint.log
|
||||
@@ -12,4 +12,5 @@ DerivedData/
|
||||
.docc-build
|
||||
|
||||
/openapi
|
||||
/docs
|
||||
/.tmp
|
||||
/xtool
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"swiftPM": {
|
||||
"buildSystem": "swiftbuild",
|
||||
"scratchPath": ".build/index-build"
|
||||
},
|
||||
"backgroundIndexing": true
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
version: 1
|
||||
builder:
|
||||
configs:
|
||||
- scheme: xtool
|
||||
platform: macosSpm
|
||||
documentation_targets:
|
||||
- xtool
|
||||
- scheme: xtool
|
||||
platform: macosXcodebuild
|
||||
- scheme: xtool
|
||||
platform: linux
|
||||
image: kabiroberai/xtool-dev:latest
|
||||
- scheme: XKit
|
||||
platform: ios
|
||||
@@ -0,0 +1,75 @@
|
||||
swiftlint_version: 0.65.1
|
||||
disabled_rules:
|
||||
- trailing_comma
|
||||
- nesting
|
||||
- fallthrough
|
||||
- shorthand_operator
|
||||
- todo
|
||||
- large_tuple
|
||||
- identifier_name
|
||||
- type_name
|
||||
- unneeded_override
|
||||
- optional_data_string_conversion
|
||||
- for_where
|
||||
- blanket_disable_command
|
||||
opt_in_rules:
|
||||
- closure_end_indentation
|
||||
- closure_spacing
|
||||
- empty_count
|
||||
- explicit_init
|
||||
- fatal_error_message
|
||||
- first_where
|
||||
- implicit_return
|
||||
- joined_default_parameter
|
||||
- literal_expression_end_indentation
|
||||
- overridden_super_call
|
||||
- prohibited_super_call
|
||||
- sorted_first_last
|
||||
- unneeded_parentheses_in_closure_argument
|
||||
- vertical_parameter_alignment_on_call
|
||||
- yoda_condition
|
||||
- nslocalizedstring_key
|
||||
- unused_setter_value
|
||||
- optional_enum_case_matching
|
||||
- prefer_self_type_over_type_of_self
|
||||
- contains_over_range_nil_comparison
|
||||
- flatmap_over_map_reduce
|
||||
- empty_collection_literal
|
||||
- contains_over_first_not_nil
|
||||
- contains_over_filter_count
|
||||
- contains_over_filter_is_empty
|
||||
- reduce_into
|
||||
analyzer_rules:
|
||||
- unused_import
|
||||
custom_rules:
|
||||
prefer_dependency_print:
|
||||
name: "Dependency Output"
|
||||
included: '/Sources/'
|
||||
excluded: '/(Tests|Examples)/'
|
||||
regex: '(?<![\w.])(?:Swift\s*\.\s*)?print\s*\('
|
||||
match_kinds:
|
||||
- identifier
|
||||
message: "Use d.out.print instead of print or Swift.print."
|
||||
severity: error
|
||||
spaces_not_tabs:
|
||||
name: "Spaces not Tabs"
|
||||
regex: ^\t
|
||||
message: "Use four spaces, not tabs"
|
||||
force_try: warning
|
||||
force_cast: warning
|
||||
function_body_length: 100
|
||||
line_length: 135
|
||||
file_length: 1000
|
||||
type_body_length: 500
|
||||
cyclomatic_complexity: 12
|
||||
function_parameter_count: 7
|
||||
implicit_return:
|
||||
included:
|
||||
- closure
|
||||
included:
|
||||
- Package.swift
|
||||
- Sources
|
||||
- Tests
|
||||
- macOS/XToolMac
|
||||
excluded:
|
||||
- Sources/DeveloperAPI/Generated
|
||||
@@ -0,0 +1 @@
|
||||
/launch.json
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"swiftlang.swift-vscode",
|
||||
"vknabel.vscode-swiftlint",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"swiftlint.path": "./.tmp/swiftlint/swiftlint",
|
||||
"files.watcherExclude":{
|
||||
"*/.git/**": true,
|
||||
"*/.build/**": true,
|
||||
"*/.tmp/**": true,
|
||||
},
|
||||
"search.exclude": {
|
||||
"*/.git/**": true,
|
||||
"*/.build/**": true,
|
||||
"*/.tmp/**": true,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# About
|
||||
|
||||
xtool is a cross-platform replacement for Xcode (including build system, provisioning, deployment).
|
||||
|
||||
The `xtool` CLI supports macOS, Linux, WSL. The lower-level XKit (provisioning and device interaction) library additionally supports iOS.
|
||||
|
||||
## Development
|
||||
|
||||
- The majority of the code is in the Swift Package. You can use `swift build` / `swift test` / etc for iteration.
|
||||
- Caveat: on macOS, xtool is distributed as an app bundle (allows entitlements like Keychain). To build the Mac app, use `make mac`. You can then invoke the CLI at `./macOS/Build/xtool`.
|
||||
- Make sure to run `make lint` (swiftlint) when you're done
|
||||
|
||||
## Conventions
|
||||
|
||||
- Use modern Swift 6. Strict concurrency is enabled.
|
||||
- Use swift-dependencies (`@Dependency(\.foo)` / `d.foo`) for Dependency Injection. Passing dependencies around as arguments is an anti-pattern.
|
||||
- Commits should be in the format `subsystem: imperative description` e.g. `auth: support reading password from stdin`.
|
||||
- Don't use `Task.detached { ... }`. If you need to escape isolation, you want `Task { @concurrent in ... }` instead.
|
||||
- Uphold API stability guarantees for consumers who use xtool via the command line interface (e.g. don't remove subcommands or config fields). However, the Swift interface (including `public` types) when consuming xtool itself as a Swift Package is _NOT_ API stable; it's okay to break Swift API.
|
||||
@@ -0,0 +1,18 @@
|
||||
# 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.
|
||||
|
||||
## Code and documentation
|
||||
|
||||
External contributions are very welcome. Take a look at [/Documentation/Contributing/README.md](/Documentation/Contributing/README.md) for details regarding the development process.
|
||||
|
||||
## AI tool usage
|
||||
|
||||
You may use AI tools to assist your contributions. You are fully responsible
|
||||
for everything you submit.
|
||||
|
||||
- **Understand it**: You must be able to explain every line of your code.
|
||||
- **Disclose it**: Pick an AI assistance level (0/1/2) in the PR template.
|
||||
- **Own it**: You are the author. If a reviewer asks "why?", you answer - not the AI. [Don't be a meat proxy.](https://dontbeameatproxy.com)
|
||||
@@ -1,7 +1,9 @@
|
||||
# Note: We use 22.04 since AppImage recommends building on the
|
||||
# oldest configuration that you support
|
||||
|
||||
FROM swift:6.1-jammy AS build-base
|
||||
ARG SWIFT_VERSION=6.4.2
|
||||
|
||||
FROM swift:${SWIFT_VERSION}-jammy AS build-base
|
||||
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
@@ -66,23 +68,13 @@ RUN cd libimobiledevice \
|
||||
&& make install DESTDIR=/prefix
|
||||
|
||||
|
||||
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/libxadi.so /prefix/usr/lib/libxadi.so
|
||||
|
||||
|
||||
FROM build-base
|
||||
FROM build-base AS build-xtool-base
|
||||
|
||||
COPY --from=build-limd /prefix/usr /usr
|
||||
COPY --from=build-xadi /prefix/usr /usr
|
||||
|
||||
WORKDIR /xtool
|
||||
|
||||
FROM build-xtool-base AS dev
|
||||
|
||||
# Docker doesn't support FUSE
|
||||
ENV APPIMAGE_EXTRACT_AND_RUN=1
|
||||
@@ -92,6 +84,30 @@ ENV APPIMAGE_EXTRACT_AND_RUN=1
|
||||
# socat -dd TCP-LISTEN:27015,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/usbmuxd
|
||||
ENV USBMUXD_SOCKET_ADDRESS=host.docker.internal:27015
|
||||
|
||||
WORKDIR /xtool
|
||||
|
||||
CMD [ "/bin/bash" ]
|
||||
|
||||
FROM dev AS dev-test
|
||||
|
||||
ENV XTL_TEST_ENV=1
|
||||
|
||||
COPY --from=bats/bats:latest /opt/bats /opt/bats
|
||||
COPY --from=bats/bats:latest /usr/lib/bats /usr/lib/bats
|
||||
RUN ln -s /opt/bats/bin/bats /usr/local/bin/bats
|
||||
|
||||
FROM build-xtool-base AS build-xtool
|
||||
|
||||
ARG XTL_CI
|
||||
|
||||
ADD Package.swift Package.resolved /xtool/
|
||||
RUN swift package resolve
|
||||
|
||||
ADD . /xtool
|
||||
RUN ./Linux/build.sh
|
||||
|
||||
FROM swift:${SWIFT_VERSION} AS xtool
|
||||
|
||||
COPY --from=build-xtool /xtool/Linux/packages/xtool-*.AppImage /xtool/xtool.AppImage
|
||||
RUN (cd /xtool && ./xtool.AppImage --appimage-extract) \
|
||||
&& mv /xtool/squashfs-root /usr/local/xtool \
|
||||
&& rm -rf /xtool \
|
||||
&& ln -s /usr/local/xtool/AppRun /usr/local/bin/xtool
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# Debugging
|
||||
|
||||
## Environment variables
|
||||
|
||||
Some environment variables that help with debugging. Use these as e.g. `XTL_FOO=1 xtool ...`
|
||||
|
||||
### General
|
||||
|
||||
- `XTL_DEBUG_ERRORS`: If xtool terminates with an error, it normally prints a user-friendly error description. Set `XTL_DEBUG_ERRORS=1` for more verbose error logging.
|
||||
|
||||
### Disk
|
||||
|
||||
- `XTL_DEBUG_TMP`: Set to `1` to log details when xtool creates/destroys temporary directories.
|
||||
- `XTL_TMPDIR`: Control the location where xtool stores temporary directories. We also respect `XDG_CACHE_HOME` on Linux.
|
||||
|
||||
### Networking
|
||||
|
||||
- `XTL_DEV_LOG`: Regex. When making AppStoreConnect API requests, operation IDs that match the regex will log their response status and body. Set `XTL_DEV_LOG='.*'` to match all.
|
||||
- `XTL_DISABLE_TLS_VALIDATION`: Set to `1` to disable all TLS validation on HTTP requests. Useful when using an MITM proxy to inspect API requests. Use sparingly, since disabling TLS is generally unsafe.
|
||||
- `XTL_HTTP_PROXY`: non-Darwin only. Set to `<host>:<port>` to point the HTTP client to a proxy. e.g. `XTL_HTTP_PROXY=localhost:8080`. On Darwin (macOS/iOS), we instead use the system proxy configuration.
|
||||
@@ -0,0 +1,31 @@
|
||||
# Contributing to xtool
|
||||
|
||||
## 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.
|
||||
|
||||
## Debugging
|
||||
|
||||
Check out [./Debugging.md](./Debugging.md) for help with debugging xtool issues during development.
|
||||
|
||||
## Updating 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.
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/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 \
|
||||
--enable-experimental-code-block-annotations \
|
||||
--experimental-enable-custom-templates
|
||||
@@ -0,0 +1,143 @@
|
||||
# Create App Extensions
|
||||
|
||||
Add app extensions to your iOS app.
|
||||
|
||||
## Overview
|
||||
|
||||
iOS includes several [App Extension Points](https://developer.apple.com/documentation/technologyoverviews/app-extensions) to deeply integrate with system functionality: such as Widgets, Share Extensions, and Safari Extensions. With a little setup, you can create App Extensions with xtool.
|
||||
|
||||
This guide will show you how to add a **Widget Extension** to your app. The steps are similar for other extensions as well.
|
||||
|
||||
> Note: This guide assumes you already have an xtool-based application up and running. If you don't, create one first with <doc:First-app>.
|
||||
|
||||
## Step 1: Add a new product
|
||||
|
||||
Start by adding a new product declaration to your `Package.swift`.
|
||||
|
||||
```diff
|
||||
// swift-tools-version: 6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Hello",
|
||||
platforms: [.iOS(.v17)],
|
||||
products: [
|
||||
.library(
|
||||
name: "Hello",
|
||||
targets: ["Hello"]
|
||||
),
|
||||
+ .library(
|
||||
+ name: "HelloWidget",
|
||||
+ targets: ["HelloWidget"]
|
||||
+ ),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "Hello"),
|
||||
+ .target(name: "HelloWidget"),
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Step 2: Update xtool.yml
|
||||
|
||||
Now that we have two products, we'll need to tell xtool which one corresponds to the _application_ and which one corresponds to the _extension_.
|
||||
|
||||
You should already have a bare-bones `xtool.yml` file that describes metadata about your package (the bundle ID, at the bare minimum.) We'll add the new information to this file.
|
||||
|
||||
```diff
|
||||
version: 1
|
||||
bundleID: com.example.Hello
|
||||
+ product: Hello
|
||||
+ extensions:
|
||||
+ - product: HelloWidget
|
||||
+ infoPath: HelloWidget-Info.plist
|
||||
```
|
||||
|
||||
## Step 3: Add an Info.plist
|
||||
|
||||
App extensions require an `Info.plist` file that tells the system what kind of extension they are, amongst other things. In the previous step, we promised xtool that this file will be located at `./HelloWidget-Info.plist` in your project. We'll now create this file.
|
||||
|
||||
```xml
|
||||
<?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>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
> Note:
|
||||
>
|
||||
> The value `com.apple.widgetkit-extension` tells the system that this is a Widget Extension. If you're creating a different type of Extension, your `Info.plist` might look different.
|
||||
>
|
||||
> For a list of possible `NSExtensionPointIdentifier` values, see [Apple's documentation](https://developer.apple.com/documentation/bundleresources/information-property-list/nsextension/nsextensionpointidentifier) on the subject. You may also need other keys like `NSExtensionPrincipalClass`: refer to Apple's ~better~ legacy [documentation library](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AppExtensionKeys.html) for details.
|
||||
>
|
||||
> Finally, note that the above refers to the old paradigm of **Foundation Extensions**. Apple has started moving towards a newer framework called **ExtensionKit** for recent extension types. The main difference for extension consumers is that you replace `NSExtension -> EXAppExtensionAttributes`, and `NSExtensionPointIdentifier -> EXExtensionPointIdentifier`. xtool doesn't support ExtensionKit yet, but it's [planned](https://github.com/xtool-org/xtool/issues/138).
|
||||
|
||||
## Step 4: Code your widget
|
||||
|
||||
We can finally write the code for the widget. Create a new file at `Sources/HelloWidget/Widget.swift` with these contents:
|
||||
|
||||
```swift
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
@main struct Bundle: WidgetBundle {
|
||||
var body: some Widget {
|
||||
HelloWidget()
|
||||
}
|
||||
}
|
||||
|
||||
struct HelloWidget: Widget {
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(
|
||||
kind: "HelloWidget",
|
||||
provider: Provider()
|
||||
) { entry in
|
||||
VStack {
|
||||
Text(entry.date, style: .date)
|
||||
}
|
||||
.containerBackground(.fill.tertiary, for: .widget)
|
||||
}
|
||||
.configurationDisplayName("HelloWidget")
|
||||
.description("This is an example widget.")
|
||||
}
|
||||
|
||||
struct Entry: TimelineEntry {
|
||||
var date = Date()
|
||||
}
|
||||
|
||||
struct Provider: TimelineProvider {
|
||||
func placeholder(in context: Context) -> Entry {
|
||||
Entry()
|
||||
}
|
||||
|
||||
func getSnapshot(
|
||||
in context: Context,
|
||||
completion: @escaping (Entry) -> Void
|
||||
) {
|
||||
completion(Entry())
|
||||
}
|
||||
|
||||
func getTimeline(
|
||||
in context: Context,
|
||||
completion: @escaping (Timeline<Entry>) -> Void
|
||||
) {
|
||||
completion(Timeline(
|
||||
entries: [Entry()],
|
||||
policy: .after(.now + 3600)
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> Note: Blindly refreshing once an hour isn't a great strategy in practice but it makes for a short snippet. I never said this was a tutorial on writing _good_ WidgetKit code; there's plenty of other resources online if that's your goal, including Apple's own [documentation](https://developer.apple.com/documentation/widgetkit).
|
||||
|
||||
Finally, build and run with `xtool dev`. You should be able to locate the widget in your widget library and add it to your home screen!
|
||||
@@ -107,3 +107,36 @@ iconPath: Resources/AppIcon.png
|
||||
> Tip:
|
||||
>
|
||||
> Your app icon must be a png, and it should ideally have a resolution of 1024x1024px.
|
||||
|
||||
## Add entitlements
|
||||
|
||||
You may need to add special [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements) to your app, for example you need the `com.apple.developer.homekit` entitlement in order to connect to HomeKit devices.
|
||||
|
||||
First create an `App.entitlements` file with the necessary entitlements:
|
||||
|
||||
```plist
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.developer.homekit</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
Then, tell xtool about it via `xtool.yml`:
|
||||
|
||||
```yaml
|
||||
entitlementsPath: App.entitlements
|
||||
```
|
||||
|
||||
> Troubleshooting:
|
||||
>
|
||||
> There are a number of situations in which xtool may not be able to successfully apply an entitlement to your app.
|
||||
>
|
||||
> - Some entitlements, such as [Network Extension](https://developer.apple.com/documentation/bundleresources/entitlements/com.apple.developer.networking.networkextension), don't work with free developer accounts. You might need to enrol in one of the Apple Developer Programs to use these.
|
||||
> - Other entitlements, like [User Notifications Filtering](https://developer.apple.com/documentation/bundleresources/entitlements/com.apple.developer.usernotifications.filtering), require special permission from Apple. If you do have the appropriate permission, these may or may not work with xtool.
|
||||
> - Many entitlements require specific "Capabilities" to be enabled on your app in the Developer Services portal. xtool handles this for you, but we need to add code to xtool for each Entitlement-Capability mapping. If you run into a Capability that we don't handle yet, please let us know.
|
||||
>
|
||||
> Entitlements are a large surface area. If you find any bugs or missing functionality, please [create a GitHub Issue](https://github.com/xtool-org/xtool/issues/new/choose).
|
||||
@@ -3,7 +3,7 @@ Creating package: Hello
|
||||
Creating Package.swift
|
||||
Creating xtool.yml
|
||||
Creating .gitignore
|
||||
Creating .sourcekit-lsp/config.json
|
||||
Creating .bsp/xtool.json
|
||||
Creating Sources/Hello/HelloApp.swift
|
||||
Creating Sources/Hello/ContentView.swift
|
||||
|
||||
@@ -3,7 +3,7 @@ Creating package: Hello
|
||||
Creating Package.swift
|
||||
Creating xtool.yml
|
||||
Creating .gitignore
|
||||
Creating .sourcekit-lsp/config.json
|
||||
Creating .bsp/xtool.json
|
||||
Creating Sources/Hello/HelloApp.swift
|
||||
Creating Sources/Hello/ContentView.swift
|
||||
|
||||
@@ -3,7 +3,7 @@ Creating package: Hello
|
||||
Creating Package.swift
|
||||
Creating xtool.yml
|
||||
Creating .gitignore
|
||||
Creating .sourcekit-lsp/config.json
|
||||
Creating .bsp/xtool.json
|
||||
Creating Sources/Hello/HelloApp.swift
|
||||
Creating Sources/Hello/ContentView.swift
|
||||
|
||||
@@ -12,7 +12,7 @@ Finished generating project Hello.
|
||||
Developer$
|
||||
Hello$
|
||||
-rw-rw-r-- 1 user user 187 .gitignore
|
||||
drwxrwxr-x 2 user user 4096 .sourcekit-lsp
|
||||
drwxrwxr-x 2 user user 4096 .bsp
|
||||
-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
|
||||
@@ -3,7 +3,7 @@ Creating package: Hello
|
||||
Creating Package.swift
|
||||
Creating xtool.yml
|
||||
Creating .gitignore
|
||||
Creating .sourcekit-lsp/config.json
|
||||
Creating .bsp/xtool.json
|
||||
Creating Sources/Hello/HelloApp.swift
|
||||
Creating Sources/Hello/ContentView.swift
|
||||
|
||||
@@ -12,7 +12,7 @@ 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
|
||||
drwxrwxr-x 2 user user 4096 .bsp
|
||||
-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
|
||||
@@ -3,7 +3,7 @@ Creating package: Hello
|
||||
Creating Package.swift
|
||||
Creating xtool.yml
|
||||
Creating .gitignore
|
||||
Creating .sourcekit-lsp/config.json
|
||||
Creating .bsp/xtool.json
|
||||
Creating Sources/Hello/HelloApp.swift
|
||||
Creating Sources/Hello/ContentView.swift
|
||||
|
||||
@@ -12,7 +12,7 @@ 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
|
||||
drwxrwxr-x 2 user user 4096 .bsp
|
||||
-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
|
||||
@@ -3,7 +3,7 @@ Creating package: Hello
|
||||
Creating Package.swift
|
||||
Creating xtool.yml
|
||||
Creating .gitignore
|
||||
Creating .sourcekit-lsp/config.json
|
||||
Creating .bsp/xtool.json
|
||||
Creating Sources/Hello/HelloApp.swift
|
||||
Creating Sources/Hello/ContentView.swift
|
||||
|
||||
@@ -12,7 +12,7 @@ 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
|
||||
drwxrwxr-x 2 user user 4096 .bsp
|
||||
-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
|
||||
@@ -3,7 +3,7 @@ Creating package: Hello
|
||||
Creating Package.swift
|
||||
Creating xtool.yml
|
||||
Creating .gitignore
|
||||
Creating .sourcekit-lsp/config.json
|
||||
Creating .bsp/xtool.json
|
||||
Creating Sources/Hello/HelloApp.swift
|
||||
Creating Sources/Hello/ContentView.swift
|
||||
|
||||
@@ -12,7 +12,7 @@ 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
|
||||
drwxrwxr-x 2 user user 4096 .bsp
|
||||
-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
|
||||
@@ -3,7 +3,7 @@ Creating package: Hello
|
||||
Creating Package.swift
|
||||
Creating xtool.yml
|
||||
Creating .gitignore
|
||||
Creating .sourcekit-lsp/config.json
|
||||
Creating .bsp/xtool.json
|
||||
Creating Sources/Hello/HelloApp.swift
|
||||
Creating Sources/Hello/ContentView.swift
|
||||
|
||||
@@ -12,7 +12,7 @@ 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
|
||||
drwxrwxr-x 2 user user 4096 .bsp
|
||||
-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
|
||||
@@ -21,5 +21,9 @@ Hello$ cat xtool.yml
|
||||
version: 1
|
||||
bundleID: com.example.Hello
|
||||
|
||||
Hello$ cat .sourcekit-lsp/config.json
|
||||
{ "swiftPM": { "swiftSDK": "arm64-apple-ios" } }
|
||||
Hello$ cat .bsp/xtool.json
|
||||
{
|
||||
"name": "xtool",
|
||||
...
|
||||
"argv": ["/usr/bin/env", "xtool", "dev", "build-server"]
|
||||
}
|
||||
@@ -30,9 +30,9 @@
|
||||
}
|
||||
|
||||
@Step {
|
||||
Read `.sourcekit-lsp/config.json`.
|
||||
Read `.bsp/xtool.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.
|
||||
This file tells your IDE to ask xtool for build information (via the Build Server Protocol). It enables features like syntax highlighting and documentation lookup.
|
||||
|
||||
@Code(name: "Terminal", file: "template-4b.sh", previousFile: "template-4a.sh") {}
|
||||
}
|
||||
@@ -14,16 +14,22 @@ If you're on Windows, you can use xtool via [Windows Subsystem for Linux](https:
|
||||
|
||||
Once you install WSL, you'll also need to set up USB passthrough. See Microsoft's instructions on [installing USBIPD](https://learn.microsoft.com/en-us/windows/wsl/connect-usb). Make sure you're able to bind your iOS device to WSL via USB.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> If you encounter `Error: AFCClient.Error.muxError`, follow the steps described in [this issue comment](https://github.com/xtool-org/xtool/issues/19#issuecomment-2898986718) from user rena2019.
|
||||
>
|
||||
> This relays the device connection from iTunes on Windows, instead of relying on USBIPD.
|
||||
|
||||
### Swift
|
||||
|
||||
Install the Swift 6.1 toolchain for your Linux distribution from <https://swift.org/install/linux>.
|
||||
Install the Swift 6.4 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)
|
||||
# Swift version 6.4 (swift-6.4-RELEASE)
|
||||
```
|
||||
|
||||
### usbmuxd
|
||||
@@ -62,7 +68,7 @@ sudo apt-get install usbmuxd
|
||||
|
||||
### 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.
|
||||
Download **Xcode 27.1** from <https://developer.apple.com/download/all/?q=Xcode>. Note the path where `Xcode.xip` is saved.
|
||||
|
||||
> Note:
|
||||
>
|
||||
@@ -125,7 +131,7 @@ 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.
|
||||
Enter the path (for example `~/Downloads/Xcode_27.1.xip`) and hit enter. xtool will extract the Xcode XIP to generate and install an iOS Swift SDK for you.
|
||||
|
||||
Confirm that it worked:
|
||||
|
||||
|
Before Width: | Height: | Size: 286 KiB After Width: | Height: | Size: 286 KiB |
|
Before Width: | Height: | Size: 948 KiB After Width: | Height: | Size: 948 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 5.0 MiB After Width: | Height: | Size: 5.0 MiB |
|
Before Width: | Height: | Size: 222 KiB After Width: | Height: | Size: 222 KiB |
|
Before Width: | Height: | Size: 316 KiB After Width: | Height: | Size: 316 KiB |
|
Before Width: | Height: | Size: 232 KiB After Width: | Height: | Size: 232 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 127 KiB |
@@ -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>
|
||||
© xtool maintainers. This site is powered by <a href="https://www.netlify.com">Netlify</a>.
|
||||
</span>
|
||||
</footer>
|
||||
@@ -1,15 +1,15 @@
|
||||
# ``XToolDocs``
|
||||
# xtool
|
||||
|
||||
@Metadata {
|
||||
@DisplayName("xtool")
|
||||
@TechnologyRoot
|
||||
@TitleHeading("Command-line Tool")
|
||||
@CallToAction(url: "https://github.com/xtool-org/xtool", label: "View on GitHub")
|
||||
}
|
||||
|
||||
Cross-platform Xcode replacement.
|
||||
|
||||
## Overview
|
||||
|
||||
[View on GitHub](https://github.com/xtool-org/xtool)
|
||||
|
||||
xtool is a cross-platform (Linux/WSL/macOS) tool that replicates Xcode functionality with open standards.
|
||||
|
||||
✅ Build a SwiftPM package into an iOS app
|
||||
@@ -31,3 +31,4 @@ xtool is a cross-platform (Linux/WSL/macOS) tool that replicates Xcode functiona
|
||||
### Common tasks
|
||||
|
||||
- <doc:Control>
|
||||
- <doc:Appex>
|
||||
@@ -0,0 +1,6 @@
|
||||
.DS_Store
|
||||
.build
|
||||
.swiftpm
|
||||
*/xtool
|
||||
*/.bsp
|
||||
/out
|
||||
@@ -0,0 +1,29 @@
|
||||
// swift-tools-version: 6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "DemoDynamic",
|
||||
platforms: [
|
||||
.iOS(.v17),
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "DemoDynamic",
|
||||
targets: ["DemoDynamic"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../ExampleSupport"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "DemoDynamic",
|
||||
dependencies: [
|
||||
"ExampleSupport",
|
||||
.product(name: "ExampleDynamicLibrary", package: "ExampleSupport"),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
import ExampleDynamicLibrary
|
||||
import ExampleSupport
|
||||
import SwiftUI
|
||||
|
||||
@main struct DemoApp: ExampleApp {
|
||||
init() {
|
||||
let message = exampleDynamicLibraryFunction()
|
||||
guard message == "Hello from the dynamic library\n" else {
|
||||
fatalError("Unexpected message from dynamic library: \(message)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
version: 1
|
||||
bundleID: sh.xtool.examples.DemoDynamic
|
||||
@@ -0,0 +1,33 @@
|
||||
// swift-tools-version: 6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "DemoExtensions",
|
||||
platforms: [
|
||||
.iOS(.v17),
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "DemoExtensions",
|
||||
targets: ["DemoExtensions"]
|
||||
),
|
||||
.library(
|
||||
name: "DemoExtensionsWidget",
|
||||
targets: ["DemoExtensionsWidget"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../ExampleSupport"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "DemoExtensions",
|
||||
dependencies: [
|
||||
"ExampleSupport",
|
||||
]
|
||||
),
|
||||
.target(name: "DemoExtensionsWidget"),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,4 @@
|
||||
import SwiftUI
|
||||
import ExampleSupport
|
||||
|
||||
@main struct DemoApp: ExampleApp {}
|
||||
@@ -0,0 +1,51 @@
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
@main struct Bundle: WidgetBundle {
|
||||
var body: some Widget {
|
||||
DemoWidget()
|
||||
}
|
||||
}
|
||||
|
||||
struct DemoWidget: Widget {
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(
|
||||
kind: "DemoWidget",
|
||||
provider: Provider()
|
||||
) { entry in
|
||||
VStack {
|
||||
Text(entry.date, style: .date)
|
||||
}
|
||||
.containerBackground(.fill.tertiary, for: .widget)
|
||||
}
|
||||
.configurationDisplayName("DemoWidget")
|
||||
.description("This is an example widget.")
|
||||
}
|
||||
|
||||
struct Entry: TimelineEntry {
|
||||
var date = Date()
|
||||
}
|
||||
|
||||
struct Provider: TimelineProvider {
|
||||
func placeholder(in context: Context) -> Entry {
|
||||
Entry()
|
||||
}
|
||||
|
||||
func getSnapshot(
|
||||
in context: Context,
|
||||
completion: @escaping (Entry) -> Void
|
||||
) {
|
||||
completion(Entry())
|
||||
}
|
||||
|
||||
func getTimeline(
|
||||
in context: Context,
|
||||
completion: @escaping (Timeline<Entry>) -> Void
|
||||
) {
|
||||
completion(Timeline(
|
||||
entries: [Entry()],
|
||||
policy: .after(.now + 3600)
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,6 @@
|
||||
version: 1
|
||||
bundleID: sh.xtool.examples.DemoExtensions
|
||||
product: DemoExtensions
|
||||
extensions:
|
||||
- product: DemoExtensionsWidget
|
||||
infoPath: Support/DemoExtensionsWidget-Info.plist
|
||||
@@ -0,0 +1,31 @@
|
||||
// swift-tools-version: 6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "DemoResources",
|
||||
platforms: [
|
||||
.iOS(.v17),
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "DemoResources",
|
||||
targets: ["DemoResources"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../ExampleSupport"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "DemoResources",
|
||||
dependencies: [
|
||||
"ExampleSupport",
|
||||
],
|
||||
resources: [
|
||||
.process("bundled.txt"),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
Top level resource
|
||||
@@ -0,0 +1,34 @@
|
||||
import ExampleSupport
|
||||
import SwiftUI
|
||||
|
||||
@main struct DemoApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
Text("Hello, world!")
|
||||
.task {
|
||||
guard let bundled = #bundle.url(forResource: "bundled", withExtension: "txt")
|
||||
else { fatalError("Missing bundled.txt resource") }
|
||||
assertContents(of: bundled, equal: "Bundled resource\n")
|
||||
|
||||
guard let top = Bundle.main.url(forResource: "top", withExtension: "txt")
|
||||
else { fatalError("Missing top.txt resource") }
|
||||
assertContents(of: top, equal: "Top level resource\n")
|
||||
|
||||
Example.pass()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func assertContents(of url: URL, equal value: String) {
|
||||
let name = url.lastPathComponent
|
||||
let contents: String
|
||||
do {
|
||||
contents = try String(contentsOf: url, encoding: .utf8)
|
||||
} catch {
|
||||
fatalError("Failed to read \(name): \(error)")
|
||||
}
|
||||
guard contents == value else {
|
||||
fatalError("\(name) had unexpected contents: \(contents)")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Bundled resource
|
||||
@@ -0,0 +1,4 @@
|
||||
version: 1
|
||||
bundleID: sh.xtool.examples.DemoResources
|
||||
resources:
|
||||
- Resources/top.txt
|
||||
@@ -0,0 +1,28 @@
|
||||
// swift-tools-version: 6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "DemoSimple",
|
||||
platforms: [
|
||||
.iOS(.v17),
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "DemoSimple",
|
||||
targets: ["DemoSimple"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../ExampleSupport"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "DemoSimple",
|
||||
dependencies: [
|
||||
"ExampleSupport",
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,26 @@
|
||||
import ExampleSupport
|
||||
import SwiftUI
|
||||
|
||||
@main struct DemoApp: App {
|
||||
public var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct ContentView: View {
|
||||
@State var counter = 0
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Button("Counter = \(counter)") {
|
||||
counter += 1
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.task {
|
||||
Example.pass()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
version: 1
|
||||
bundleID: sh.xtool.examples.DemoSimple
|
||||
@@ -0,0 +1,141 @@
|
||||
{
|
||||
"originHash" : "87792a9d5953dfe62ed2edf7c4f142774813bd3ea31882cbf6659b62fb2827ab",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "combine-schedulers",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/combine-schedulers",
|
||||
"state" : {
|
||||
"revision" : "114354e8c1667a2edc4993700fb9fa4f90157b56",
|
||||
"version" : "1.2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "opencombine",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/OpenCombine/OpenCombine.git",
|
||||
"state" : {
|
||||
"revision" : "8576f0d579b27020beccbccc3ea6844f3ddfc2c2",
|
||||
"version" : "0.14.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-case-paths",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-case-paths",
|
||||
"state" : {
|
||||
"revision" : "cb4cba6a8a46a86db0d37dbe09935ead6b24c91a",
|
||||
"version" : "1.10.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-clocks",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-clocks",
|
||||
"state" : {
|
||||
"revision" : "82440fa0a8b1c381a6d1e8e0fc7bbba53ec63204",
|
||||
"version" : "1.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-collections",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-collections",
|
||||
"state" : {
|
||||
"revision" : "98ef3c98609a1e31b7e157b5b619579001a789d6",
|
||||
"version" : "1.7.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-composable-architecture",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-composable-architecture.git",
|
||||
"state" : {
|
||||
"revision" : "377da4061db10d26337a71bb279c506bb951f50f",
|
||||
"version" : "1.26.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-concurrency-extras",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
|
||||
"state" : {
|
||||
"revision" : "5fa253428866f2360c3754e88537f700ed2656b5",
|
||||
"version" : "1.4.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-custom-dump",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-custom-dump",
|
||||
"state" : {
|
||||
"revision" : "4fb9e7cbb4b8f5a7354005db39447f570d6b3e19",
|
||||
"version" : "1.7.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-dependencies",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-dependencies",
|
||||
"state" : {
|
||||
"revision" : "b476cc5761057d8d857de063fe7ac8daecf5c06b",
|
||||
"version" : "1.17.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-identified-collections",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-identified-collections",
|
||||
"state" : {
|
||||
"revision" : "322d9ffeeba85c9f7c4984b39422ec7cc3c56597",
|
||||
"version" : "1.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-issue-reporting",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-issue-reporting",
|
||||
"state" : {
|
||||
"revision" : "75b000cea2ca6d7527a57e1b9cc0bdf21a9abe9f",
|
||||
"version" : "2.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-navigation",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-navigation",
|
||||
"state" : {
|
||||
"revision" : "7e95e5e9ff0a64f6ad8bca59083f8d6ba381b6ff",
|
||||
"version" : "2.11.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-perception",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-perception",
|
||||
"state" : {
|
||||
"revision" : "597afd46249f4a71885b95d26b26cc5b893daf32",
|
||||
"version" : "2.0.12"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-sharing",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-sharing",
|
||||
"state" : {
|
||||
"revision" : "3552faf8a6c18ce896ec5a72bd8c34755f0f03e0",
|
||||
"version" : "2.10.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-syntax",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/swiftlang/swift-syntax",
|
||||
"state" : {
|
||||
"revision" : "050f1a346fbbac0ca2cfb15a95274f7bd1cf0ccf",
|
||||
"version" : "604.0.0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 3
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// swift-tools-version: 6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "DemoTCA",
|
||||
platforms: [
|
||||
.iOS(.v17),
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "DemoTCA",
|
||||
targets: ["DemoTCA"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../ExampleSupport"),
|
||||
.package(url: "https://github.com/pointfreeco/swift-composable-architecture.git", from: "1.0.0"),
|
||||
// we don't use this but need the explicit dependency to keep the lockfile stable.
|
||||
// TODO: remove once https://github.com/pointfreeco/combine-schedulers/issues/120 is fixed
|
||||
.package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.14.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "DemoTCA",
|
||||
dependencies: [
|
||||
"ExampleSupport",
|
||||
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
import SwiftUI
|
||||
import ComposableArchitecture
|
||||
import ExampleSupport
|
||||
|
||||
struct ContentView: View {
|
||||
let store: StoreOf<CounterFeature>
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Image(systemName: "globe")
|
||||
.imageScale(.large)
|
||||
.foregroundStyle(.tint)
|
||||
Text("Count: \(store.count)")
|
||||
}
|
||||
.padding()
|
||||
.onAppear {
|
||||
store.send(.appear)
|
||||
}
|
||||
.onChange(of: store.count) { _, count in
|
||||
guard count == 1 else { return }
|
||||
Example.pass()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import ComposableArchitecture
|
||||
|
||||
@Reducer
|
||||
struct CounterFeature {
|
||||
@ObservableState
|
||||
struct State {
|
||||
var count = 0
|
||||
}
|
||||
|
||||
enum Action {
|
||||
case appear
|
||||
case timerElapsed
|
||||
}
|
||||
|
||||
@Dependency(\.continuousClock) var continuousClock
|
||||
|
||||
var body: some Reducer<State, Action> {
|
||||
Reduce { state, action in
|
||||
switch action {
|
||||
case .appear:
|
||||
return .run { [continuousClock] send in
|
||||
try await continuousClock.sleep(for: .seconds(1))
|
||||
await send(.timerElapsed)
|
||||
}
|
||||
case .timerElapsed:
|
||||
state.count += 1
|
||||
return .none
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import SwiftUI
|
||||
import ComposableArchitecture
|
||||
|
||||
@main
|
||||
struct DemoTCAApp: App {
|
||||
private let store = Store(initialState: CounterFeature.State()) {
|
||||
CounterFeature()
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView(store: store)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
version: 1
|
||||
bundleID: sh.xtool.examples.DemoTCA
|
||||
@@ -0,0 +1,31 @@
|
||||
// swift-tools-version: 6.4
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "ExampleSupport",
|
||||
platforms: [
|
||||
.iOS(.v17),
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "ExampleSupport",
|
||||
targets: ["ExampleSupport"]
|
||||
),
|
||||
.library(
|
||||
name: "ExampleDynamicLibrary",
|
||||
type: .dynamic,
|
||||
targets: ["ExampleDynamicLibrary"]
|
||||
),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "ExampleSupport"),
|
||||
.target(
|
||||
name: "ExampleDynamicLibrary",
|
||||
resources: [
|
||||
.process("response.txt"),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
import Foundation
|
||||
|
||||
public func exampleDynamicLibraryFunction() -> String {
|
||||
guard let bundled = #bundle.url(forResource: "response", withExtension: "txt")
|
||||
else { fatalError("Missing bundled.txt resource") }
|
||||
// swiftlint:disable:next force_try
|
||||
let contents = try! String(contentsOf: bundled, encoding: .utf8)
|
||||
return "Hello \(contents)"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
from the dynamic library
|
||||
@@ -0,0 +1,25 @@
|
||||
import SwiftUI
|
||||
|
||||
public protocol ExampleApp: App {}
|
||||
extension ExampleApp {
|
||||
public var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct ContentView: View {
|
||||
var body: some View {
|
||||
VStack {
|
||||
Image(systemName: "globe")
|
||||
.imageScale(.large)
|
||||
.foregroundStyle(.tint)
|
||||
Text("Hello, world!")
|
||||
}
|
||||
.padding()
|
||||
.task {
|
||||
Example.pass()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import Foundation
|
||||
|
||||
public enum Example {}
|
||||
extension Example {
|
||||
public static func pass() {
|
||||
Task {
|
||||
try? await Task.sleep(for: .seconds(1))
|
||||
print("xtool test succeeded")
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Examples
|
||||
|
||||
These primarily exist as fixtures for integration tests, but also double as snippets of sample code.
|
||||
|
||||
Each demo is designed to make some assertions shortly after launching, and then exit. On success, stdout will include the message "xtool test succeeded".
|
||||
|
||||
## Testing
|
||||
|
||||
```
|
||||
./Examples/test.sh [--build | --run] [DemoName]
|
||||
```
|
||||
|
||||
- Omit `--build`/`--run` to build _and_ run
|
||||
- Omit the demo name to loop through all demos
|
||||
@@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
shopt -s nullglob
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [--build | --run] [DemoName]"
|
||||
}
|
||||
|
||||
mode=both
|
||||
case "${1:-}" in
|
||||
--build) mode=build; shift ;;
|
||||
--run) mode=run; shift ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
esac
|
||||
|
||||
if [[ $# -gt 1 || (${1:-} != "" && (${1:-} != Demo* || ${1:-} == */*)) ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
examples_dir="$PWD"
|
||||
out_dir="$examples_dir/out"
|
||||
|
||||
if [[ -n "${1:-}" ]]; then
|
||||
demos=("$1")
|
||||
elif [[ "$mode" == run ]]; then
|
||||
demos=()
|
||||
for app in "$out_dir"/*.app; do
|
||||
name="${app##*/}"
|
||||
demos+=("${name%.app}")
|
||||
done
|
||||
else
|
||||
demos=()
|
||||
for demo in "$examples_dir"/Demo*/; do
|
||||
[[ -f "$demo/Package.swift" ]] || continue
|
||||
demo="${demo%/}"
|
||||
demos+=("${demo##*/}")
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ${#demos[@]} -eq 0 ]]; then
|
||||
echo "No demos found. Run $0 --build first if using --run." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
logs_dir="$(mktemp -d)"
|
||||
trap 'rm -rf "$logs_dir"' EXIT
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
|
||||
build_demo() {
|
||||
local demo="$1"
|
||||
echo "Building $demo..."
|
||||
mkdir -p "$out_dir" || return 1
|
||||
# Do not leave an older successful build available after a failed rebuild.
|
||||
rm -rf "$out_dir/$demo.app" || return 1
|
||||
(cd "$examples_dir/$demo" && xtool dev build --triple arm64-apple-ios-simulator) || return 1
|
||||
cp -R "$examples_dir/$demo/xtool/$demo.app" "$out_dir/$demo.app"
|
||||
}
|
||||
|
||||
run_demo() (
|
||||
demo="$1"
|
||||
app="$out_dir/$demo.app"
|
||||
log="$logs_dir/$demo-run.log"
|
||||
if [[ ! -d "$app" ]]; then
|
||||
echo "Missing $app. Run $0 --build $demo first." >&2
|
||||
exit 1
|
||||
fi
|
||||
bundle_id=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$app/Info.plist") || exit 1
|
||||
echo "Running $demo..."
|
||||
xcrun simctl install booted "$app" || exit 1
|
||||
xcrun simctl launch --terminate-running-process --console booted "$bundle_id" >"$log" 2>&1 &
|
||||
launch_pid=$!
|
||||
# A demo should exit shortly after launch. Bound failures that hang instead.
|
||||
(
|
||||
sleep_pid=""
|
||||
trap '[[ -z "$sleep_pid" ]] || kill "$sleep_pid" 2>/dev/null || true' EXIT
|
||||
sleep 60 &
|
||||
sleep_pid=$!
|
||||
wait "$sleep_pid"
|
||||
sleep_pid=""
|
||||
touch "$log.timeout"
|
||||
kill -TERM "$launch_pid" 2>/dev/null || exit 0
|
||||
sleep 5 &
|
||||
sleep_pid=$!
|
||||
wait "$sleep_pid"
|
||||
sleep_pid=""
|
||||
kill -KILL "$launch_pid" 2>/dev/null || true
|
||||
) >/dev/null 2>&1 &
|
||||
timeout_pid=$!
|
||||
trap 'kill "$timeout_pid" "$launch_pid" 2>/dev/null || true' EXIT
|
||||
status=0
|
||||
wait "$launch_pid" || status=$?
|
||||
kill "$timeout_pid" 2>/dev/null || true
|
||||
wait "$timeout_pid" 2>/dev/null || true
|
||||
cat "$log"
|
||||
if [[ -f "$log.timeout" ]]; then
|
||||
echo "$demo did not terminate within 60 seconds." >&2
|
||||
exit 1
|
||||
fi
|
||||
[[ "$status" -eq 0 ]] && grep -Fxq 'xtool test succeeded' "$log"
|
||||
)
|
||||
|
||||
status=0
|
||||
for demo in "${demos[@]}"; do
|
||||
if [[ "$mode" != run ]] && ! build_demo "$demo"; then
|
||||
echo "Build failed: $demo" >&2
|
||||
status=1
|
||||
continue
|
||||
fi
|
||||
if [[ "$mode" != build ]] && ! run_demo "$demo"; then
|
||||
echo "Test failed: $demo" >&2
|
||||
status=1
|
||||
fi
|
||||
done
|
||||
exit "$status"
|
||||
@@ -5,9 +5,6 @@ shopt -s nullglob
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# release version
|
||||
export LINUXDEPLOY_OUTPUT_VERSION="latest"
|
||||
|
||||
if ! command -v fusermount &>/dev/null; then
|
||||
# Docker doesn't support FUSE
|
||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||
@@ -16,7 +13,7 @@ fi
|
||||
rm -rf staging/tmp
|
||||
mkdir -p staging/tmp staging/linuxdeploy
|
||||
|
||||
swift build --package-path .. -c release --product xtool --static-swift-stdlib
|
||||
swift build --package-path .. -c release --product xtool
|
||||
bin="$(swift build --package-path .. -c release --show-bin-path)"
|
||||
strip "${bin}/xtool"
|
||||
|
||||
@@ -41,12 +38,12 @@ if [[ ! -f staging/linuxdeploy/linuxdeploy.AppImage ]]; then
|
||||
fi
|
||||
|
||||
mkdir -p staging/tmp/AppDir/usr/bin
|
||||
find "${bin}"/ -name '*.resources' -print0 | xargs -0 -I {} cp -a {} "${PWD}/staging/tmp/AppDir/usr/bin/"
|
||||
find "${bin}"/ -name '*.resources' -or -name '*.bundle' -print0 | xargs -0 -I {} cp -a {} "${PWD}/staging/tmp/AppDir/usr/bin/"
|
||||
|
||||
env \
|
||||
LDAI_OUTPUT="staging/tmp/xtool-${curr_arch}.AppImage" \
|
||||
LDAI_UPDATE_INFORMATION="gh-releases-zsync|xtool-org|xtool|latest|xtool-${curr_arch}.AppImage.zsync" \
|
||||
./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}/xtool" \
|
||||
|
||||
@@ -1,7 +1,157 @@
|
||||
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: docker
|
||||
docker:
|
||||
docker build . -t ghcr.io/xtool-org/xtool:latest
|
||||
|
||||
.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
|
||||
|
||||
SWIFTLINT_VERSION = $(shell head -1 .swiftlint.yml | cut -d' ' -f2)
|
||||
SWIFTLINT_BIN = .tmp/swiftlint/swiftlint-$(SWIFTLINT_VERSION)
|
||||
SWIFTLINT_ARCH = $(subst aarch64,arm64,$(subst x86_64,amd64,$(shell uname -m)))
|
||||
SWIFTLINT_URL = https://github.com/realm/SwiftLint/releases/download/$(SWIFTLINT_VERSION)/$(if $(IS_MAC),portable_swiftlint,swiftlint_linux_$(SWIFTLINT_ARCH)).zip
|
||||
|
||||
.PHONY: lint
|
||||
lint: $(SWIFTLINT_BIN)
|
||||
$(SWIFTLINT_BIN) $(SWIFTLINT_FLAGS)
|
||||
|
||||
$(SWIFTLINT_BIN):
|
||||
@rm -rf .tmp/swiftlint
|
||||
@mkdir -p .tmp/swiftlint
|
||||
curl -fSL $(SWIFTLINT_URL) -o .tmp/swiftlint/swiftlint.zip
|
||||
unzip -q .tmp/swiftlint/swiftlint.zip swiftlint -d .tmp/swiftlint
|
||||
@rm -f .tmp/swiftlint/swiftlint.zip
|
||||
@mv .tmp/swiftlint/swiftlint $@
|
||||
@ln -s swiftlint-$(SWIFTLINT_VERSION) .tmp/swiftlint/swiftlint
|
||||
|
||||
SPEC_URL = https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip
|
||||
|
||||
.PHONY: api update-api
|
||||
|
||||
.PHONY: api
|
||||
# Regenerate the OpenAPI client code
|
||||
api: openapi/openapi.json
|
||||
swift run swift-openapi-generator generate \
|
||||
openapi/openapi.json \
|
||||
@@ -11,12 +161,17 @@ api: openapi/openapi.json
|
||||
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/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/openapi.json: openapi/base.json Sources/DeveloperAPI/patch.js
|
||||
node Sources/DeveloperAPI/patch.js < openapi/base.json > openapi/openapi.json
|
||||
|
||||
openapi/base.json:
|
||||
@mkdir -p openapi
|
||||
curl -fsSL "$(SPEC_URL)" | bsdtar -xOf- > openapi/base.json
|
||||
# piping curl|bsdtar concatenates xattrs into the JSON :thonk:
|
||||
curl -fsSL "$(SPEC_URL)" -o openapi/spec.zip
|
||||
bsdtar -xO -f openapi/spec.zip > openapi/base.json
|
||||
rm -f openapi/spec.zip
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"originHash" : "6980154be7e8da0aace058cc72033471d7d9573fa77fdbf53972129e4cd1d0a2",
|
||||
"originHash" : "2ccd077fc130f0f1b1279d87aa61d1fc243964d7ad49489a12021577c54df9de",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "aexml",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/tadija/AEXML.git",
|
||||
"state" : {
|
||||
"revision" : "38f7d00b23ecd891e1ee656fa6aeebd6ba04ecc3",
|
||||
"version" : "4.6.1"
|
||||
"revision" : "dd9206de0717d658daec6a064992894fdab8ae17",
|
||||
"version" : "4.7.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -15,8 +15,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/swift-server/async-http-client.git",
|
||||
"state" : {
|
||||
"revision" : "333f51104b75d1a5b94cb3b99e4c58a3b442c9f7",
|
||||
"version" : "1.25.2"
|
||||
"revision" : "4c005f955e83f888d5616e579717a36d2dfc6301",
|
||||
"version" : "1.36.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -24,8 +24,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/attaswift/BigInt",
|
||||
"state" : {
|
||||
"revision" : "114343a705df4725dfe7ab8a2a326b8883cfd79c",
|
||||
"version" : "5.5.1"
|
||||
"revision" : "63feef7820abb1a8fb08587d7da56bb0b7db8751",
|
||||
"version" : "6.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -33,17 +33,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/combine-schedulers",
|
||||
"state" : {
|
||||
"revision" : "5928286acce13def418ec36d05a001a9641086f2",
|
||||
"version" : "1.0.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "jsonutilities",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/yonaskolb/JSONUtilities.git",
|
||||
"state" : {
|
||||
"revision" : "128d2ffc22467f69569ef8ff971683e2393191a0",
|
||||
"version" : "4.2.0"
|
||||
"revision" : "114354e8c1667a2edc4993700fb9fa4f90157b56",
|
||||
"version" : "1.2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -51,8 +42,17 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/mattpolzin/OpenAPIKit",
|
||||
"state" : {
|
||||
"revision" : "da7d3a5ddff0dd8e5e9fdb5585d186d645bcc21b",
|
||||
"version" : "3.5.0"
|
||||
"revision" : "5b72eb9a6b23b1fec439d9a0bf38f115400421f9",
|
||||
"version" : "6.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "opencombine",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/OpenCombine/OpenCombine.git",
|
||||
"state" : {
|
||||
"revision" : "8576f0d579b27020beccbccc3ea6844f3ddfc2c2",
|
||||
"version" : "0.14.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -64,15 +64,6 @@
|
||||
"version" : "1.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "rainbow",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/onevcat/Rainbow.git",
|
||||
"state" : {
|
||||
"revision" : "0c627a4f8a39ef37eadec1ceec02e4a7f55561ac",
|
||||
"version" : "4.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "spectre",
|
||||
"kind" : "remoteSourceControl",
|
||||
@@ -94,10 +85,10 @@
|
||||
{
|
||||
"identity" : "swift-argument-parser",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-argument-parser",
|
||||
"location" : "https://github.com/apple/swift-argument-parser.git",
|
||||
"state" : {
|
||||
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
|
||||
"version" : "1.5.0"
|
||||
"revision" : "6a52f3251125d74daf04fcbd5e6f08a75d074382",
|
||||
"version" : "1.8.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -105,8 +96,17 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-asn1.git",
|
||||
"state" : {
|
||||
"revision" : "a54383ada6cecde007d374f58f864e29370ba5c3",
|
||||
"version" : "1.3.2"
|
||||
"revision" : "3b6410f7dee09eb33cdd26260c5fd47fda19b0e2",
|
||||
"version" : "1.7.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-async-algorithms",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-async-algorithms.git",
|
||||
"state" : {
|
||||
"revision" : "13713a4ffdee8abd929f92568ee9462a46ae26e0",
|
||||
"version" : "1.1.7"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -114,8 +114,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-atomics.git",
|
||||
"state" : {
|
||||
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
|
||||
"version" : "1.2.0"
|
||||
"revision" : "0442cb5a3f98ab802acb777929fdb446bda11a34",
|
||||
"version" : "1.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -123,8 +123,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-certificates",
|
||||
"state" : {
|
||||
"revision" : "999fd70c7803da89f3904d635a6815a2a7cd7585",
|
||||
"version" : "1.10.0"
|
||||
"revision" : "ff86b924ead66f853b8baf91f3c41926a8f36177",
|
||||
"version" : "1.21.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -132,17 +132,17 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-clocks",
|
||||
"state" : {
|
||||
"revision" : "cc46202b53476d64e824e0b6612da09d84ffde8e",
|
||||
"version" : "1.0.6"
|
||||
"revision" : "82440fa0a8b1c381a6d1e8e0fc7bbba53ec63204",
|
||||
"version" : "1.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-collections",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-collections.git",
|
||||
"location" : "https://github.com/apple/swift-collections",
|
||||
"state" : {
|
||||
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
|
||||
"version" : "1.1.4"
|
||||
"revision" : "35a1edcb8ebd2bfe251d587f0b69e62af28f508c",
|
||||
"version" : "1.7.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -150,8 +150,17 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
|
||||
"state" : {
|
||||
"revision" : "82a4ae7170d98d8538ec77238b7eb8e7199ef2e8",
|
||||
"version" : "1.3.1"
|
||||
"revision" : "8a4260f7373493435bd21194585c95b72bfdd401",
|
||||
"version" : "1.4.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-configuration",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-configuration.git",
|
||||
"state" : {
|
||||
"revision" : "8bae88f79dbddec793390c5bf3e2abb4ac2ece42",
|
||||
"version" : "1.2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -159,8 +168,17 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-crypto",
|
||||
"state" : {
|
||||
"revision" : "e8d6eba1fef23ae5b359c46b03f7d94be2f41fed",
|
||||
"version" : "3.12.3"
|
||||
"revision" : "c2cbadd7263439d8015189668f96ff5b5be565ce",
|
||||
"version" : "5.0.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-custom-dump",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-custom-dump",
|
||||
"state" : {
|
||||
"revision" : "4fb9e7cbb4b8f5a7354005db39447f570d6b3e19",
|
||||
"version" : "1.7.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -168,17 +186,26 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-dependencies",
|
||||
"state" : {
|
||||
"revision" : "4c90d6b2b9bf0911af87b103bb40f41771891596",
|
||||
"version" : "1.9.2"
|
||||
"revision" : "b476cc5761057d8d857de063fe7ac8daecf5c06b",
|
||||
"version" : "1.17.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-distributed-tracing",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-distributed-tracing.git",
|
||||
"state" : {
|
||||
"revision" : "297b5b9c82a5631e3199ce3ec0993a3cfb0fbb84",
|
||||
"version" : "1.7.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-docc-plugin",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-docc-plugin",
|
||||
"location" : "https://github.com/swiftlang/swift-docc-plugin",
|
||||
"state" : {
|
||||
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
|
||||
"version" : "1.4.3"
|
||||
"revision" : "647c708be89f834fa6a6d4945442793a77ddf5b6",
|
||||
"version" : "1.5.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -195,8 +222,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-http-structured-headers.git",
|
||||
"state" : {
|
||||
"revision" : "f280fc7676b9940ff2c6598642751ea333c6544f",
|
||||
"version" : "1.2.2"
|
||||
"revision" : "933538faa42c432d385f02e07df0ace7c5ecfc47",
|
||||
"version" : "1.7.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -204,8 +231,17 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-http-types",
|
||||
"state" : {
|
||||
"revision" : "a0a57e949a8903563aba4615869310c0ebf14c03",
|
||||
"version" : "1.4.0"
|
||||
"revision" : "bff4b6903cdc99dda49649dd52f46c11cfd3ed50",
|
||||
"version" : "1.8.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-issue-reporting",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-issue-reporting",
|
||||
"state" : {
|
||||
"revision" : "b23bb4493c439d3e05152bc167014235ba3d47fc",
|
||||
"version" : "2.1.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -213,8 +249,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-log.git",
|
||||
"state" : {
|
||||
"revision" : "3d8596ed08bd13520157f0355e35caed215ffbfa",
|
||||
"version" : "1.6.3"
|
||||
"revision" : "4038b6a4f74a1426f47eb1dd5b4bb5628a15d597",
|
||||
"version" : "1.16.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -222,8 +258,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio",
|
||||
"state" : {
|
||||
"revision" : "0f54d58bb5db9e064f332e8524150de379d1e51c",
|
||||
"version" : "2.82.1"
|
||||
"revision" : "6db9d9abd92ad7399b8a564cafbb87d3507245fa",
|
||||
"version" : "2.104.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -231,8 +267,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-extras.git",
|
||||
"state" : {
|
||||
"revision" : "f1f6f772198bee35d99dd145f1513d8581a54f2c",
|
||||
"version" : "1.26.0"
|
||||
"revision" : "41449336c8ecfadac6b4b5be75f9c3c306e61ced",
|
||||
"version" : "1.35.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -240,8 +276,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-http2.git",
|
||||
"state" : {
|
||||
"revision" : "4281466512f63d1bd530e33f4aa6993ee7864be0",
|
||||
"version" : "1.36.0"
|
||||
"revision" : "0f3e54e29c944c2e835ad52159da7d9e1c94ac69",
|
||||
"version" : "1.46.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -249,8 +285,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-ssl.git",
|
||||
"state" : {
|
||||
"revision" : "6df102a39c8da5fdc2eae29a0f63546d660866fc",
|
||||
"version" : "2.30.0"
|
||||
"revision" : "322f3c2a4a21df31c84ca416bf65ee5e9059e440",
|
||||
"version" : "2.37.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -258,8 +294,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-transport-services.git",
|
||||
"state" : {
|
||||
"revision" : "cd1e89816d345d2523b11c55654570acd5cd4c56",
|
||||
"version" : "1.24.0"
|
||||
"revision" : "67787bb645a5e67d2edcdfbe48a216cc549222d5",
|
||||
"version" : "1.28.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -267,8 +303,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-numerics.git",
|
||||
"state" : {
|
||||
"revision" : "e0ec0f5f3af6f3e4d5e7a19d2af26b481acb6ba8",
|
||||
"version" : "1.0.3"
|
||||
"revision" : "0c0290ff6b24942dadb83a929ffaaa1481df04a2",
|
||||
"version" : "1.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -276,8 +312,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/swift-server/swift-openapi-async-http-client",
|
||||
"state" : {
|
||||
"revision" : "915aeff168625b0f88a5810ee7ab8e9c00af671b",
|
||||
"version" : "1.1.0"
|
||||
"revision" : "3681f659d9417652b8119f0adbdf57c04b6cb292",
|
||||
"version" : "1.5.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -285,8 +321,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-openapi-generator",
|
||||
"state" : {
|
||||
"revision" : "02cab48b66b4b412013827c2938adaf0eb67dc8d",
|
||||
"version" : "1.7.2"
|
||||
"revision" : "164dfbcf1f78e2ddc719ab9d85c50d1157fa8d7d",
|
||||
"version" : "1.14.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -294,8 +330,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-openapi-runtime",
|
||||
"state" : {
|
||||
"revision" : "8f33cc5dfe81169fb167da73584b9c72c3e8bc23",
|
||||
"version" : "1.8.2"
|
||||
"revision" : "ad7a252e215870ea2de9cf8605ff9336b004183a",
|
||||
"version" : "1.13.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -303,8 +339,44 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-openapi-urlsession",
|
||||
"state" : {
|
||||
"revision" : "6fac6f7c428d5feea2639b5f5c8b06ddfb79434b",
|
||||
"version" : "1.1.0"
|
||||
"revision" : "c97e0f0187d95542b4a254f5bb4dc67f43bf73c9",
|
||||
"version" : "1.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-rcodesign",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/xtool-org/swift-rcodesign",
|
||||
"state" : {
|
||||
"revision" : "08650ab9d3bf95a0c585581b8bd63eb7b8315264",
|
||||
"version" : "0.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-service-context",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-service-context.git",
|
||||
"state" : {
|
||||
"revision" : "853ba3d9ce78851b9cc20108e8bd4f13f7fa546c",
|
||||
"version" : "1.5.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-service-lifecycle",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/swift-server/swift-service-lifecycle",
|
||||
"state" : {
|
||||
"revision" : "a18ee16b8039866fd919bdb4e8e906882d4ecc75",
|
||||
"version" : "2.13.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-subprocess",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/swiftlang/swift-subprocess",
|
||||
"state" : {
|
||||
"revision" : "dbe21bd7dfd4ffef8c32588918542a8abfa1b54c",
|
||||
"version" : "1.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -312,26 +384,17 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/swiftlang/swift-syntax",
|
||||
"state" : {
|
||||
"revision" : "f99ae8aa18f0cf0d53481901f88a0991dc3bd4a2",
|
||||
"version" : "601.0.1"
|
||||
"revision" : "050f1a346fbbac0ca2cfb15a95274f7bd1cf0ccf",
|
||||
"version" : "604.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-system",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-system",
|
||||
"location" : "https://github.com/apple/swift-system.git",
|
||||
"state" : {
|
||||
"revision" : "a34201439c74b53f0fd71ef11741af7e7caf01e1",
|
||||
"version" : "1.4.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swiftcli",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/jakeheis/SwiftCLI.git",
|
||||
"state" : {
|
||||
"revision" : "2e949055d9797c1a6bddcda0e58dada16cc8e970",
|
||||
"version" : "6.0.3"
|
||||
"revision" : "869129b7bf4ecc57b97d0193ad29690ca2134750",
|
||||
"version" : "1.8.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -339,8 +402,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/xtool-org/SwiftyMobileDevice",
|
||||
"state" : {
|
||||
"revision" : "5ee5f680d065519dd6ac56c96435a7db0d599ade",
|
||||
"version" : "1.4.0"
|
||||
"revision" : "1f6e4cc614a31953bda5d1092a747cfdea90916f",
|
||||
"version" : "1.7.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -348,17 +411,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/saagarjha/unxip",
|
||||
"state" : {
|
||||
"revision" : "d6f0009109f7502f8f5b3f23dcd5b43cf5b29b32",
|
||||
"version" : "3.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "version",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/mxcl/Version",
|
||||
"state" : {
|
||||
"revision" : "303a0f916772545e1e8667d3104f83be708a723c",
|
||||
"version" : "2.1.0"
|
||||
"revision" : "6c3990517fcc4c1db6952fccf4c562fb14097601",
|
||||
"version" : "3.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -366,17 +420,17 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/websocket-kit.git",
|
||||
"state" : {
|
||||
"revision" : "014ccd52891b8c098d7e1033d5e72ed76fef7a86",
|
||||
"version" : "2.16.0"
|
||||
"revision" : "90bbbdab3ede12c803cfbe91646f291c092517a3",
|
||||
"version" : "2.16.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "xcodegen",
|
||||
"identity" : "xcode-project-format",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/yonaskolb/XcodeGen",
|
||||
"location" : "https://github.com/apple/xcode-project-format.git",
|
||||
"state" : {
|
||||
"revision" : "7193eb447a6f60061f069e07bc1efd32d73c0e19",
|
||||
"version" : "2.43.0"
|
||||
"revision" : "c132630aabf40f6d6c3f7bb004595d2e5a28ea42",
|
||||
"version" : "0.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -384,17 +438,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/tuist/XcodeProj.git",
|
||||
"state" : {
|
||||
"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"
|
||||
"revision" : "b505c06bb190b9306b29d5d96e3284e139af3cc8",
|
||||
"version" : "9.17.6"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -402,8 +447,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/xtool-org/xtool-core",
|
||||
"state" : {
|
||||
"revision" : "63c644eef014f7faff53daaebe8bad37c31fbbe5",
|
||||
"version" : "1.3.0"
|
||||
"revision" : "154d7213c12e3f21d50793f50ec7bfb89cfd3918",
|
||||
"version" : "1.5.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -411,17 +456,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/jpsim/Yams",
|
||||
"state" : {
|
||||
"revision" : "b4b8042411dc7bbb696300a34a4bf3ba1b7ad19b",
|
||||
"version" : "5.3.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "zsign",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/xtool-org/zsign",
|
||||
"state" : {
|
||||
"revision" : "e9853fd3be36ea1a61fa9d4b7f71f4b4d8244369",
|
||||
"version" : "1.4.0"
|
||||
"revision" : "a27b21e0c81c5bf42049b897a62aaf387e80f279",
|
||||
"version" : "6.2.2"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,16 +1,39 @@
|
||||
// swift-tools-version:6.0
|
||||
// swift-tools-version:6.2
|
||||
|
||||
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
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
|
||||
let hasUncommittedChanges = Context.gitInformation?.hasUncommittedChanges ?? false
|
||||
|
||||
let cSettings: [CSetting] = [
|
||||
.define("_GNU_SOURCE", .when(platforms: [.linux])),
|
||||
]
|
||||
|
||||
let swiftSettings: [SwiftSetting] = {
|
||||
var settings: [SwiftSetting] = []
|
||||
if Context.environment["XTL_CI"] == "1" {
|
||||
settings.append(.treatAllWarnings(as: .error))
|
||||
}
|
||||
return settings
|
||||
}()
|
||||
|
||||
let package = Package(
|
||||
name: "xtool",
|
||||
platforms: [
|
||||
.iOS(.v15),
|
||||
.macOS(.v12),
|
||||
.iOS(.v17),
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
@@ -27,20 +50,23 @@ let package = Package(
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
.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/xtool-org/xtool-core", .upToNextMinor(from: "1.5.1")),
|
||||
.package(url: "https://github.com/xtool-org/SwiftyMobileDevice", .upToNextMinor(from: "1.7.0")),
|
||||
.package(url: "https://github.com/xtool-org/swift-rcodesign", .upToNextMinor(from: "0.2.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-crypto", from: "5.0.0"),
|
||||
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.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/apple/swift-collections", from: "1.7.1"),
|
||||
.package(url: "https://github.com/apple/xcode-project-format.git", .upToNextMinor(from: "0.1.0")),
|
||||
|
||||
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
|
||||
.package(url: "https://github.com/swiftlang/swift-subprocess", 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"),
|
||||
@@ -48,46 +74,89 @@ let package = Package(
|
||||
|
||||
.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/pointfreeco/swift-custom-dump", from: "1.3.3"),
|
||||
// we don't use this but need the explicit dependency to keep the lockfile stable.
|
||||
// TODO: remove once https://github.com/pointfreeco/combine-schedulers/issues/120 is fixed
|
||||
.package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.14.0"),
|
||||
|
||||
.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"),
|
||||
.package(url: "https://github.com/attaswift/BigInt", from: "6.0.0"),
|
||||
.package(url: "https://github.com/jpsim/Yams", from: "6.0.0"),
|
||||
.package(url: "https://github.com/saagarjha/unxip", from: "3.2.0"),
|
||||
|
||||
// TODO: just depend on tuist/XcodeProj instead
|
||||
.package(url: "https://github.com/yonaskolb/XcodeGen", from: "2.43.0"),
|
||||
// NB: this should only be imported from XcodeProjects
|
||||
.package(url: "https://github.com/tuist/XcodeProj.git", from: "9.17.5"),
|
||||
],
|
||||
targets: [
|
||||
.systemLibrary(name: "XADI"),
|
||||
.target(
|
||||
name: "CXKit",
|
||||
dependencies: [
|
||||
.product(name: "OpenSSL", package: "xtool-core")
|
||||
],
|
||||
cSettings: cSettings
|
||||
cSettings: cSettings + [
|
||||
.define("XTOOL_HAS_UNCOMMITTED_CHANGES", to: hasUncommittedChanges ? "1" : "0"),
|
||||
] + (
|
||||
xtoolVersion
|
||||
.map { [.define("XTOOL_VERSION", to: "\"\($0)\"")] }
|
||||
?? []
|
||||
)
|
||||
),
|
||||
.target(
|
||||
name: "DeveloperAPI",
|
||||
dependencies: [
|
||||
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
|
||||
],
|
||||
exclude: ["openapi-generator-config.yaml", "openapi-overlay.yaml"]
|
||||
exclude: ["openapi-generator-config.yaml", "patch.js"],
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
// common utilities shared across xtool targets
|
||||
.target(
|
||||
name: "XUtils",
|
||||
dependencies: [
|
||||
"CXKit",
|
||||
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
|
||||
.product(name: "Dependencies", package: "swift-dependencies"),
|
||||
.product(name: "SystemPackage", package: "swift-system"),
|
||||
.product(
|
||||
name: "Subprocess",
|
||||
package: "swift-subprocess",
|
||||
condition: .when(platforms: [.linux, .macOS])
|
||||
),
|
||||
],
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.systemLibrary(
|
||||
name: "CLZMA",
|
||||
pkgConfig: "liblzma",
|
||||
providers: [
|
||||
.apt(["liblzma-dev"]),
|
||||
]
|
||||
),
|
||||
// Apple Archive (.aar) and Apple Encrypted Archive (.aea) support
|
||||
.target(
|
||||
name: "XAppleArchive",
|
||||
dependencies: [
|
||||
"XUtils",
|
||||
.target(name: "CLZMA", condition: .when(platforms: [.linux])),
|
||||
.product(name: "Crypto", package: "swift-crypto"),
|
||||
.product(name: "Dependencies", package: "swift-dependencies"),
|
||||
.product(name: "X509", package: "swift-certificates"),
|
||||
],
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.target(
|
||||
name: "XKit",
|
||||
dependencies: [
|
||||
"DeveloperAPI",
|
||||
"CXKit",
|
||||
.byName(name: "XADI", condition: .when(platforms: [.linux])),
|
||||
"XUtils",
|
||||
.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: "xtool-core"),
|
||||
.product(name: "RCodesign", package: "swift-rcodesign"),
|
||||
.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: "CryptoExtras", package: "swift-crypto"),
|
||||
.product(name: "X509", package: "swift-certificates"),
|
||||
.product(name: "BigInt", package: "BigInt"),
|
||||
.product(name: "HTTPTypes", package: "swift-http-types"),
|
||||
@@ -109,48 +178,74 @@ let package = Package(
|
||||
condition: .when(platforms: [.linux])
|
||||
),
|
||||
],
|
||||
cSettings: cSettings
|
||||
cSettings: cSettings,
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.testTarget(
|
||||
name: "XToolTests",
|
||||
dependencies: [
|
||||
"XKit",
|
||||
"XToolSupport",
|
||||
]
|
||||
"XCLIUtils",
|
||||
"PackLib",
|
||||
.product(name: "Crypto", package: "swift-crypto"),
|
||||
.product(name: "X509", package: "swift-certificates"),
|
||||
.product(name: "CustomDump", package: "swift-custom-dump"),
|
||||
],
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.testTarget(
|
||||
name: "XKitTests",
|
||||
name: "XAppleArchiveTests",
|
||||
dependencies: [
|
||||
"XKit",
|
||||
.product(name: "SuperutilsTestSupport", package: "xtool-core")
|
||||
"XAppleArchive",
|
||||
"XUtils",
|
||||
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
|
||||
.product(name: "Crypto", package: "swift-crypto"),
|
||||
],
|
||||
exclude: [
|
||||
"config/config-template.json",
|
||||
exclude: ["Fixtures"],
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.target(
|
||||
name: "XCLIUtils",
|
||||
dependencies: [
|
||||
"XUtils",
|
||||
.product(name: "Dependencies", package: "swift-dependencies"),
|
||||
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
|
||||
],
|
||||
resources: [
|
||||
.copy("config/config.json"),
|
||||
.copy("config/test.app"),
|
||||
]
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.target(
|
||||
name: "XToolSupport",
|
||||
dependencies: [
|
||||
"SwiftyMobileDevice",
|
||||
"XKit",
|
||||
"XCLIUtils",
|
||||
"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: "Dependencies", package: "swift-dependencies"),
|
||||
.product(name: "libunxip", package: "unxip"),
|
||||
],
|
||||
cSettings: cSettings
|
||||
cSettings: cSettings,
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.target(
|
||||
name: "XcodeProjects",
|
||||
dependencies: [
|
||||
.product(name: "XcodeProj", package: "XcodeProj"),
|
||||
.product(name: "XcodeProjectFormat", package: "xcode-project-format"),
|
||||
],
|
||||
),
|
||||
.target(
|
||||
name: "PackLib",
|
||||
dependencies: [
|
||||
"XUtils",
|
||||
"XcodeProjects",
|
||||
.product(name: "Superutils", package: "xtool-core"),
|
||||
.product(name: "Yams", package: "Yams"),
|
||||
.product(name: "XcodeGenKit", package: "XcodeGen", condition: .when(platforms: [.macOS])),
|
||||
]
|
||||
.product(name: "XcodeProjectFormat", package: "xcode-project-format"),
|
||||
],
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
.executableTarget(
|
||||
name: "xtool",
|
||||
@@ -159,10 +254,8 @@ let package = Package(
|
||||
"XKit",
|
||||
"XToolSupport",
|
||||
],
|
||||
cSettings: cSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "XToolDocs"
|
||||
cSettings: cSettings,
|
||||
swiftSettings: swiftSettings,
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ xtool is a cross-platform (Linux/WSL/macOS) tool that replicates Xcode functiona
|
||||
|
||||
### Screenshot
|
||||
|
||||

|
||||

|
||||
|
||||
### Command line interface
|
||||
|
||||
@@ -57,7 +57,9 @@ DEVICE SUBCOMMANDS:
|
||||
|
||||
### Library
|
||||
|
||||
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.
|
||||
You can consume xtool itself as a Swift Package, to enable your own app to interact with Apple Developer Services, iOS devices, and more. You can use this by adding `XKit` or `XToolSupport` as a SwiftPM dependency.
|
||||
|
||||
Note: while we aim to uphold semver semantics on the CLI interface (breaking change = major version bump), the Swift interface does not offer the same guarantees.
|
||||
|
||||
```swift
|
||||
// package dependency:
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module CLZMA [system] {
|
||||
header "shim.h"
|
||||
link "lzma"
|
||||
export *
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <lzma.h>
|
||||
@@ -0,0 +1,4 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
const char * _Nonnull xtl_version(void);
|
||||
bool xtl_has_uncommitted_changes(void);
|
||||
@@ -18,6 +18,8 @@ struct mobileprovision {
|
||||
|
||||
static mobileprovision_t mobileprovision_create(PKCS7 *raw) {
|
||||
mobileprovision_t profile = malloc(sizeof(struct mobileprovision));
|
||||
if (!profile) return NULL;
|
||||
|
||||
profile->raw = raw;
|
||||
return profile;
|
||||
}
|
||||
@@ -41,6 +43,12 @@ void *mobileprovision_copy_data(mobileprovision_t profile, size_t *len) {
|
||||
if (data_len < 0) return NULL;
|
||||
*len = data_len;
|
||||
void *ret = malloc(data_len);
|
||||
|
||||
if (!ret) {
|
||||
OPENSSL_free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(ret, data, data_len);
|
||||
OPENSSL_free(data);
|
||||
return ret;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "version.h"
|
||||
#include <stddef.h>
|
||||
|
||||
const char *xtl_version(void) {
|
||||
#ifdef XTOOL_VERSION
|
||||
return XTOOL_VERSION;
|
||||
#else
|
||||
return "unversioned";
|
||||
#endif
|
||||
}
|
||||
|
||||
bool xtl_has_uncommitted_changes(void) {
|
||||
#ifndef XTOOL_VERSION
|
||||
return true;
|
||||
#else
|
||||
#ifdef XTOOL_HAS_UNCOMMITTED_CHANGES
|
||||
return XTOOL_HAS_UNCOMMITTED_CHANGES != 0;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||