├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE.md ├── README.md ├── build.sh ├── layout ├── info.json └── toolset.json ├── templates └── swift-sdk.json └── versions.json /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - '*' 5 | 6 | jobs: 7 | build: 8 | runs-on: macos-15 9 | permissions: 10 | contents: write 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v4 14 | - uses: maxim-lobanov/setup-xcode@v1 15 | with: 16 | xcode-version: '16.3' 17 | - name: Build 18 | run: | 19 | brew install rsync 20 | ./build.sh auto x86_64 21 | ./build.sh auto aarch64 22 | env: 23 | DARWIN_SDK_VERSION: ${{ github.ref_name }} 24 | - name: Release 25 | uses: softprops/action-gh-release@v2 26 | with: 27 | draft: true 28 | files: | 29 | output/darwin-linux-x86_64.artifactbundle.zip 30 | output/darwin-linux-aarch64.artifactbundle.zip 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /output 3 | /staging 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Kabir Oberai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # swift-sdk-darwin 2 | 3 | **DEPRECATED:** This repository has been superseded by [xtool](https://github.com/xtool-org/xtool). 4 | 5 | ## Building 6 | 7 | Prerequisites: 8 | - macOS 9 | - Xcode 10 | - [rsync](https://rsync.samba.org) 11 | - The system version of rsync will suffice on macOS < 15.4. However, 15.4 replaces rsync with openrsync which seems to not fully support `--relative`. If you're on macOS 15.4+, you may need to `brew install rsync`. 12 | - Linux 13 | - [rsync](https://rsync.samba.org) 14 | - [unxip](https://github.com/saagarjha/unxip) 15 | 16 | Steps: 17 | 1. Download and install/extract [Xcode](https://developer.apple.com/download/all/?q=Xcode) 16.0 or higher 18 | - Use `unxip` to extract Xcode if you're on Linux. 19 | 2. Run `./build.sh [developer dir]`. 20 | - **developer dir**: this should be the path to `Xcode.app/Contents/Developer`. On macOS, you can omit this argument (or pass `auto`) to let the script infer it. 21 | 22 | Find the output at `output/darwin-linux-$(arch).artifactbundle`. 23 | 24 | ## Installing 25 | 26 | Prerequisites: 27 | - Swift 6.0 toolchain () 28 | - `darwin.artifactbundle` built for your host OS (see **Building**) 29 | 30 | ``` 31 | swift sdk install output/darwin-linux-$(arch).artifactbundle 32 | ``` 33 | 34 | ## Usage 35 | 36 | ``` 37 | swift build --swift-sdk arm64-apple-ios 38 | ``` 39 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DARWIN_TOOLS_VERSION="1.0.1" 4 | 5 | set -e 6 | 7 | if [[ ($# -gt 2) || $1 == -h || $1 == --help ]]; then 8 | echo "Usage: $0 [/path/to/Xcode.app/Contents/Developer|auto] [x86_64|aarch64|auto]" 9 | exit 1 10 | fi 11 | 12 | dev_dir="${1:-auto}" 13 | if [[ "${dev_dir}" == auto ]]; then 14 | if type -p xcode-select &>/dev/null; then 15 | dev_dir="$(xcode-select -p)" 16 | else 17 | echo "error: Path to Xcode.app was not supplied; can't infer since we aren't on macOS." 18 | exit 1 19 | fi 20 | fi 21 | 22 | target_arch="${2:-auto}" 23 | if [[ "${target_arch}" == auto ]]; then 24 | target_arch="$(arch)" 25 | fi 26 | case "$target_arch" in 27 | x86_64) ;; 28 | aarch64) ;; 29 | arm64) target_arch=aarch64 ;; 30 | *) 31 | echo "error: Unrecognized architecture '${target_arch}'. Please specify x86_64 or aarch64." 32 | exit 1 33 | ;; 34 | esac 35 | 36 | echo "Building for ${target_arch} using Xcode at ${dev_dir}..." 37 | 38 | if [[ "$(uname -s)" == Darwin ]]; then 39 | sed_inplace=(-i '') 40 | else 41 | sed_inplace=(-i) 42 | fi 43 | 44 | cd "$(dirname "$0")" 45 | root="$PWD" 46 | 47 | rm -rf staging 48 | mkdir -p staging output 49 | 50 | echo "Making base..." 51 | bundle="staging/darwin.artifactbundle" 52 | rm -rf "$bundle" 53 | cp -a layout "$bundle" 54 | 55 | # we need to include the version numbers in the SDK names; ld uses these when emitting LC_BUILD_VERSION. 56 | MacOSX_SDK="$(basename "$dev_dir"/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.*.sdk)" 57 | iPhoneOS_SDK="$(basename "$dev_dir"/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.*.sdk)" 58 | iPhoneSimulator_SDK="$(basename "$dev_dir"/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.*.sdk)" 59 | sed \ 60 | -e 's/$MacOSX_SDK/'"$MacOSX_SDK"'/g' \ 61 | -e 's/$iPhoneOS_SDK/'"$iPhoneOS_SDK"'/g' \ 62 | -e 's/$iPhoneSimulator_SDK/'"$iPhoneSimulator_SDK"'/g' \ 63 | templates/swift-sdk.json > "$bundle/swift-sdk.json" 64 | echo "${DARWIN_SDK_VERSION:-develop}" > "$bundle/darwin-sdk-version.txt" 65 | 66 | echo "SDKs:" 67 | echo " MacOSX: $MacOSX_SDK" 68 | echo " iPhoneOS: $iPhoneOS_SDK" 69 | echo " iPhoneSimulator: $iPhoneSimulator_SDK" 70 | 71 | echo "Installing toolset..." 72 | mkdir -p "$bundle/toolset" 73 | curl -#L "https://github.com/kabiroberai/darwin-tools-linux-llvm/releases/download/v${DARWIN_TOOLS_VERSION}/toolset-${target_arch}.tar.gz" \ 74 | | tar xzf - -C "$bundle/toolset" 75 | 76 | echo "Installing Developer directories..." 77 | mkdir -p "$bundle/Developer" 78 | rsync -aW --relative \ 79 | "$dev_dir/./"Toolchains/XcodeDefault.xctoolchain/usr/lib/{swift,swift_static,clang} \ 80 | "$dev_dir/./"Platforms/{iPhoneOS,MacOSX,iPhoneSimulator}.platform/Developer/{SDKs,Library/{Private,}Frameworks,usr/lib} \ 81 | --exclude "Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/*/prebuilt-modules" \ 82 | "$bundle/Developer/" 83 | 84 | # XCTest and Testing.framework are located in *.platform/Developer/{Library/Frameworks,usr/lib} rather than inside 85 | # the SDK. These search paths are explicitly included when building tests, which presumably ensures that normal 86 | # applications don't accidentally link against them in production. 87 | # 88 | # SwiftPM makes no such affordances outside of macOS, so we add the usr/lib path as include/library search paths 89 | # in the SDK config, and symlink the frameworks into the SDKs (since there's no frameworkSearchPaths option). 90 | # While this drops a safeguard it's better than not having the testing libs at all. 91 | for platform in iPhoneOS MacOSX iPhoneSimulator; do 92 | ln -s ../../../../../Library/{Frameworks/{Testing,XCTest,XCUIAutomation},PrivateFrameworks/XCTestCore}.framework \ 93 | "${bundle}/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}.sdk/System/Library/Frameworks/" 94 | done 95 | 96 | echo "Packaging..." 97 | # We need to zip-then-move to avoid appending to an existing zip file. 98 | (cd "$(dirname "$bundle")" && zip -yqr "$root/staging/darwin.artifactbundle.zip.tmp" "$(basename "$bundle")") 99 | outfile="$root/output/darwin-linux-${target_arch}.artifactbundle.zip" 100 | mv -f "$root/staging/darwin.artifactbundle.zip.tmp" "$outfile" 101 | rm -rf staging 102 | 103 | if type -p shasum &>/dev/null; then 104 | shasum -a 256 "$outfile" | cut -d' ' -f1 > "$outfile".sha256 105 | echo "SHA256: $(<"$outfile".sha256)" 106 | fi 107 | 108 | echo "Done!" 109 | -------------------------------------------------------------------------------- /layout/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0", 3 | "artifacts": { 4 | "darwin": { 5 | "type": "swiftSDK", 6 | "version": "0.0.1", 7 | "variants": [ 8 | { 9 | "path": ".", 10 | "supportedTriples": ["aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu"] 11 | } 12 | ] 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /layout/toolset.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0", 3 | "rootPath": "toolset/bin", 4 | "linker": { 5 | "path": "ld64.lld" 6 | }, 7 | "swiftCompiler": { 8 | "extraCLIOptions": [ 9 | "-use-ld=lld" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /templates/swift-sdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "4.0", 3 | "targetTriples": { 4 | "arm64-apple-ios": { 5 | "sdkRootPath": "Developer/Platforms/iPhoneOS.platform/Developer/SDKs/$iPhoneOS_SDK", 6 | "includeSearchPaths": ["Developer/Platforms/iPhoneOS.platform/Developer/usr/lib"], 7 | "librarySearchPaths": ["Developer/Platforms/iPhoneOS.platform/Developer/usr/lib"], 8 | "swiftResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift", 9 | "swiftStaticResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static", 10 | "toolsetPaths": ["toolset.json"] 11 | }, 12 | "arm64-apple-ios-simulator": { 13 | "sdkRootPath": "Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/$iPhoneSimulator_SDK", 14 | "includeSearchPaths": ["Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib"], 15 | "librarySearchPaths": ["Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib"], 16 | "swiftResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift", 17 | "swiftStaticResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static", 18 | "toolsetPaths": ["toolset.json"] 19 | }, 20 | "x86_64-apple-ios-simulator": { 21 | "sdkRootPath": "Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/$iPhoneSimulator_SDK", 22 | "includeSearchPaths": ["Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib"], 23 | "librarySearchPaths": ["Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib"], 24 | "swiftResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift", 25 | "swiftStaticResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static", 26 | "toolsetPaths": ["toolset.json"] 27 | }, 28 | "arm64-apple-macosx": { 29 | "sdkRootPath": "Developer/Platforms/MacOSX.platform/Developer/SDKs/$MacOSX_SDK", 30 | "includeSearchPaths": ["Developer/Platforms/MacOSX.platform/Developer/usr/lib"], 31 | "librarySearchPaths": ["Developer/Platforms/MacOSX.platform/Developer/usr/lib"], 32 | "swiftResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift", 33 | "swiftStaticResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static", 34 | "toolsetPaths": ["toolset.json"] 35 | }, 36 | "x86_64-apple-macosx": { 37 | "sdkRootPath": "Developer/Platforms/MacOSX.platform/Developer/SDKs/$MacOSX_SDK", 38 | "includeSearchPaths": ["Developer/Platforms/MacOSX.platform/Developer/usr/lib"], 39 | "librarySearchPaths": ["Developer/Platforms/MacOSX.platform/Developer/usr/lib"], 40 | "swiftResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift", 41 | "swiftStaticResourcesPath": "Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static", 42 | "toolsetPaths": ["toolset.json"] 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "current": "1.4.0", 3 | "metadata": { 4 | "1.1.0": { 5 | "arm64Checksum": "b640b7c7a133b0cd3e9f6ee49ac5b8b990b2625467f1fd81bf27646c1fa87001", 6 | "x64Checksum": "7f659126ecb7513e7a973706c5f2aa8b7204906c149d9ffb5c57efd675b11635", 7 | "compilerRange": ["6.0", "6.1"] 8 | }, 9 | "1.2.0": { 10 | "arm64Checksum": "ef7a844430664354979711d05c59e36792388cda781fb7051397c0def7203973", 11 | "x64Checksum": "2bab437c2d1ca11478d33f7e5ad35ef7f416a9c2457b4c6d8556c0770932db78", 12 | "compilerRange": ["6.0", "6.1"] 13 | }, 14 | "1.3.0": { 15 | "arm64Checksum": "a445b2f0c7188ad94e730cb321fa00cc0c56b413a7252fe8cd8d7dfac0fb1dfd", 16 | "x64Checksum": "c619600e0da0ee7e2298018a0e059cd33a049c9822c208b6b791e72aefef0b87", 17 | "compilerRange": ["6.0", "6.1"] 18 | }, 19 | "1.3.1": { 20 | "arm64Checksum": "75696c64d8dbddb125a4d3294db8f0010d10f3d524866b6ad758c871846f3835", 21 | "x64Checksum": "f25dbeb34c62f55400724724efd030337357063758f9c003b7b06d0b5ec216d7", 22 | "compilerRange": ["6.0", "6.1"] 23 | }, 24 | "1.4.0": { 25 | "arm64Checksum": "228b8231abd7012b2c285aa3c6ea8e98b9c1fda73b39c1d9c7e00309b6dace5a", 26 | "x64Checksum": "4734ed495d90aac5fee25e6c00cc48fd54ac5bff83fecc9607cb2d78397353c5", 27 | "compilerRange": ["6.1", "6.2"] 28 | } 29 | } 30 | } 31 | --------------------------------------------------------------------------------