7
votes

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?

1
Try xcrun --sdk iphonesimulator8.0 swift perhaps?Javier Soto
@JavierSoto perfect! thanks so much.Brandon Williams
Great! I turned it into an answer.Javier Soto

1 Answers

7
votes

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