加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Xcode用Swift运行脚本

发布时间:2020-12-14 19:44:11 所属栏目:百科 来源:网络整理
导读:我在 Xcode中有一个运行脚本,我在 Swift中编写过.在构建设置中,我有一个运行脚本,其shell设置为/ bin / sh,内容是单行./my-script.swift.该文件只包含以下行: #!/usr/bin/xcrun swiftimport Foundation 如果我为模拟器构建,一切正常.如果我为设备构建,我会
我在 Xcode中有一个运行脚本,我在 Swift中编写过.在构建设置中,我有一个运行脚本,其shell设置为/ bin / sh,内容是单行./my-script.swift.该文件只包含以下行:

#!/usr/bin/xcrun swift
import Foundation

如果我为模拟器构建,一切正常.如果我为设备构建,我会遇到大量错误:

/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

任何想法为什么会这样?

解决方法

它默认使用iOS设备SDK(iPhoneOS).尝试通过指定iphonesimulator或macosx SDK来调用xcrun,如下所示:

#!/usr/bin/xcrun --sdk iphonesimulator swift

#!/usr/bin/xcrun --sdk macosx swift

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读