如何在Swift中编写构建预操作脚本?

时间:2015-07-30 16:15:59

标签: xcode swift

我已成功从终端执行Swift代码,也从Xcode机器人的前/后触发器中成功执行。但我正在努力为构建预操作编写Swift脚本。有没有人管理过这个?

这就是我的预行动:

enter image description here

当我从终端(xcodebuild -scheme UAT build)构建时,我看到以下错误:

/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:11:10: note: while building module 'Darwin' imported from /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:11:  
#include <sys/types.h>  
^  
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "sys/cdefs.h"
^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/usr/include/sys/cdefs.h:707:2: error: Unsupported architecture
#error Unsupported architecture
^

更新
如果我只是打印一些东西而不导入Foundation模块那么它就可以了。即print("Hello")。但我显然不能使用NSProcessInfo

1 个答案:

答案 0 :(得分:3)

问题是,在构建iOS项目时,--sdk的{​​{1}}选项设置为xcrun。您需要明确说明iPhoneOS

示例:

Edit scheme success