Now, I needed to pass that script the current iOS SDK version being used so it could arrange its own build malarkey, and get all its SDK ducks in a row.
There is no environment variable for that defined by Xcode. Bah. The closest you get is the current deployment target version, which appears in $IPHONEOS_DEPLOYMENT_TARGET.
That seems like rather a large omission.
You do get given $SDKROOT which is a file path to the current SDK. But that's not quite the same thing as a simple version number.
Never, fear, shell gibberish to the rescue. This is what I came up with:
SDK_VERSION=$(echo $SDKROOT | sed -e 's/.*iPhone\(OS\)*\(Simulator\)*\([0-9]*.[0-9]*\).sdk/\3/')
If you know a better way to do this, I'd love to know.