I'm having multiple Swift Packages which produce cross-platform libraries (iOS, macOS).
I'm trying to build those packages (as a part of CI), and got the following observation:
When running swift build
:
swift build
[1/1] Build complete!
Then, when specifying iOS Simulator
specifcially:
xcodebuild -showsdks
iOS SDKs:
iOS 15.0 -sdk iphoneos15.0
iOS Simulator SDKs:
Simulator - iOS 15.0 -sdk iphonesimulator15.0
macOS SDKs:
macOS 12.0 -sdk macosx12.0
swift build --sdk iphonesimulator15.0
clang: warning: no such sysroot directory: '/Users/louis/Code/json/iphonesimulator15.0' [-Wmissing-sysroot]
In file included from /Users/louis/Code/json/_SwiftPackageManagerFile.cpp:5:
In file included from /Users/louis/Code/json/single_include/nlohmann/json.hpp:37:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:60:
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string.h:60:15: fatal error: 'string.h' file not found
#include_next <string.h>
And getting exactly the same error when I try a different SDK, e.g.:
swift build --sdk macosx12.0
How can swift build
succeed, but whenever I specify an SDK it fails? What is the default SDK?
Note: the packages I'm working with are C++ packages.
This worked:
swift build -Xswiftc "-sdk" -Xswiftc "$(xcrun --sdk iphonesimulator --show-sdk-path)" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios14.0-simulator"