I have a run script in Xcode that I have written in Swift. In the build settings I have a run script whose shell is set to /bin/sh
and the contents is the single line ./my-script.swift
. That file contains only the lines:
#!/usr/bin/xcrun swift
import Foundation
If I build for the simulator, everything works just fine. If I build for the device I get a ton of errors along the lines of:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:11:10: Could not build module 'Darwin'
:0: Could not build Objective-C module 'CoreFoundation'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/usr/include/sys/cdefs.h:680:2: Unsupported architecture
Any ideas why this is?
It's using the iOS device SDK by default (iPhoneOS
). Try to invoke xcrun by specifying either the iphonesimulator
or macosx
SDKs like this:
#!/usr/bin/xcrun --sdk iphonesimulator swift
#!/usr/bin/xcrun --sdk macosx swift
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With