Skip to content

Instantly share code, notes, and snippets.

@capnslipp
Last active December 29, 2022 17:58
Show Gist options
  • Save capnslipp/5c3a1f75172b6076568e24e0535780c5 to your computer and use it in GitHub Desktop.
Save capnslipp/5c3a1f75172b6076568e24e0535780c5 to your computer and use it in GitHub Desktop.
Per-platform `swift-build-…` scripts
#!/usr/bin/env bash
arch="$(uname -m)"
sdk_path="$(xcrun --sdk driverkit --show-sdk-path)"
sdk_version="$(xcrun --sdk driverkit --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-driverkit${sdk_version}" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-driverkit${sdk_version}" "$@"
#!/usr/bin/env bash
sdk_path="$(xcrun --sdk iphoneos --show-sdk-path)"
sdk_version="$(xcrun --sdk iphoneos --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "arm64-apple-ios${sdk_version}" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "arm64-apple-ios${sdk_version}" "$@"
#!/usr/bin/env bash
arch="$(uname -m)"
sdk_path="$(xcrun --sdk iphonesimulator --show-sdk-path)"
sdk_version="$(xcrun --sdk iphonesimulator --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-ios${sdk_version}-simulator" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-ios${sdk_version}-simulator" "$@"
#!/usr/bin/env bash
arch="$(uname -m)"
sdk_path="$(xcrun --sdk macosx --show-sdk-path)"
sdk_version="$(xcrun --sdk macosx --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-macosx${sdk_version}" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-macosx${sdk_version}" "$@"
#!/usr/bin/env bash
sdk_path="$(xcrun --sdk appletvos --show-sdk-path)"
sdk_version="$(xcrun --sdk appletvos --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "arm64-apple-tvos${sdk_version}" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "arm64-apple-tvos${sdk_version}" "$@"
#!/usr/bin/env bash
arch="$(uname -m)"
sdk_path="$(xcrun --sdk appletvsimulator --show-sdk-path)"
sdk_version="$(xcrun --sdk appletvsimulator --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-tvos${sdk_version}-simulator" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-tvos${sdk_version}-simulator" "$@"
#!/usr/bin/env bash
sdk_path="$(xcrun --sdk watchos --show-sdk-path)"
sdk_version="$(xcrun --sdk watchos --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "arm64-apple-watchos${sdk_version}" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "arm64-apple-watchos${sdk_version}" "$@"
#!/usr/bin/env bash
arch="$(uname -m)"
sdk_path="$(xcrun --sdk watchsimulator --show-sdk-path)"
sdk_version="$(xcrun --sdk watchsimulator --show-sdk-version)"
echo "Running: " \
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-watchos${sdk_version}-simulator" "$@"
swift build -Xswiftc "-sdk" -Xswiftc "${sdk_path}" -Xswiftc "-target" -Xswiftc "${arch}-apple-watchos${sdk_version}-simulator" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment