Consider the following code to verify the compilation of some swift package (for the Swift Package Manager)
xcodebuild \
-scheme name-Package \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,OS=17.0,name=iPhone 15' \
-configuration Debug
And the equivalent swift build
command:
swift build -Xswiftc -warnings-as-errors -Xswiftc "-sdk" -Xswiftc "$(xcrun --sdk iphonesimulator --show-sdk-path)" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios15.0-simulator"
Questions:
- Would it be possible to make this Xcode/Simulator version independent, so that I won't have to include the version of the SDK in each command? i.e. remove this line from the 1st command:
Simulator,OS=17.0,name=iPhone 15
and remove this one from the 2nd one:x86_64-apple-ios15.0-simulator
- Would it be possible to remove the
scheme
name from the 1st command, i.e.name-Package
, or discover it in some way and paste the scheme containing thePackage
word, so that thexcodebuild
will try to build the whole package and not just some single target in that package.
Motivation: Create a generic build script that can work on any Swift Package repository.
It works as follows:
Package
suffix or the first scheme