I working on a test script for cross-compiling a library under Xcode:
#!/usr/bin/env bash
PLATFORMS=(iPhoneOS iPhoneSimulator WatchOS WatchSimulator AppleTVOS AppleTVSimulator)
for platform in ${PLATFORMS[@]}
do
make distclean > /dev/null 2>&1
if [ $xcode_supports_platform ]; then
. ./setenv-apple "$platform"
make -f GNUmakefile-cross ...
fi
done
Later versions of Xcode supports iPhoneOS, iPhoneSimulator, WatchOS, WatchSimulator, AppleTVOS, and AppleTVSimulator. Earlier versions of Xcode don't support Watch and TV.
I'm having trouble determining the test for "$xcode_supports_platform". Searching Apple's site has not revealed anything useful, like, say, xcode-select
to determine the default Xcode. And trying to get help from Xcode just launches Xcode instead of providing supported options and commands: /Applications/Xcode.app/Contents/MacOS/Xcode --help
.
How can I determine if Xcode supports a platform?
You could look into the results of
xcodebuild -showsdks
Which will look something like this
OS X SDKs:
OS X 10.11 -sdk macosx10.11
iOS SDKs:
iOS 9.2 -sdk iphoneos9.2
iOS Simulator SDKs:
Simulator - iOS 9.2 -sdk iphonesimulator9.2
tvOS SDKs:
tvOS 9.1 -sdk appletvos9.1
tvOS Simulator SDKs:
Simulator - tvOS 9.1 -sdk appletvsimulator9.1
watchOS SDKs:
watchOS 2.1 -sdk watchos2.1
watchOS Simulator SDKs:
Simulator - watchOS 2.1 -sdk watchsimulator2.1
The presence or non-presence of a platform should tell you what you want to know.