7

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?

2
  • Try xcrun --sdk iphonesimulator8.0 swift perhaps? Commented May 4, 2015 at 22:13
  • Great! I turned it into an answer. Commented May 4, 2015 at 22:26

1 Answer 1

7

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.