Xcode runs a script using Swift

I have a run script in Xcode that I wrote in Swift. In the build settings, I have a run script whose shell is installed in /bin/sh , and the contents are one line ./my-script.swift . This file contains only lines:

 #!/usr/bin/xcrun swift import Foundation 

If I create for the simulator, everything works fine. If I build a device, I get a lot of errors line by line:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:11:10: Failed to create Darwin module

: 0: Failed to build Objective-C "CoreFoundation" module

/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?

+6
source share
1 answer

It uses the default iOS device SDK ( iPhoneOS ). Try calling xcrun, specifying either the iphonesimulator SDK or macosx as follows:

 #!/usr/bin/xcrun --sdk iphonesimulator swift #!/usr/bin/xcrun --sdk macosx swift 
+4
source

Source: https://habr.com/ru/post/986531/


All Articles