Always compiling for iOS when running package from Xcode?

So this is a bit odd. I have a run script phase that runs an executable package to generate some code.

This works just fine in Xcode 11.3.1, (and when run directly from Terminal), but in Xcode 11.4 it fails with this:

**PackageName**:1:1: manifest parse error(s):
/<unknown>:1:1: using sysroot for 'iPhoneOS' but targeting 'MacOSX'
/<unknown>:1:1: unable to load standard library for target 'x86_64-apple-macosx10.10'

It's really unclear what's actually going wrong. If there was a problem with the manifest, it wouldn't expect it work from the Terminal. It also seems like it's trying to build it for iOS, but I don't know why that would be a side effect created by building it from Xcode.

For reference, the actual command being used is:
swift run --package-path $clone_dir **TargetName** -s $resources_dir -o $identifier_export_directory -v

I've tried various configuration changes to no effect. I'm not even sure if it's my bug or Xcode's :disappointed:

1 Like

I had the same problem, here are some solutions: Swift build fails inside xcode build script

1 Like

Yes! Prepending with /usr/bin/xcrun --sdk macosx worked. Seems odd that it's necessary but at least I don't expect that to break if/when that's fixed.

Thanks @GalCohen and @somu !

1 Like