我正在试着在我的iPhone 4s上运行Swift应用程序。它在模拟器上运行良好,我的朋友也可以在他的iPhone 4s上成功运行。我有iOS 8和官方发布的Xcode 6。

我试过了

重启Xcode, iPhone,电脑 清洁和重建 撤销并创建新的证书/供应配置文件 运行路径搜索路径是$(inherited) @executable_path/Frameworks 包含Swift代码的嵌入内容是“是” 代码签名身份是开发人员

下面是完整的错误

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at
address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib

当前回答

对我来说,尝试了所有的方法都没有成功,有效的方法是从打包部分中删除@executable_path/Frameworks(不知道它最初是如何出现在那里的)

其他回答

我开始得到这个错误时,我删除:

@executable_path/Frameworks

从跑道搜索路径在我的构建设置。替换它使一切重新恢复正常(感谢源代码控制!)

我不知道它是如何到达那里的,但它似乎是二进制文件找到其嵌入式Swift运行时所需要的。

假设项目P正在导入自定义库L,那么必须将L添加进去

P ->构建阶段->嵌入框架-> +。这对我很有用。

我认为直接从Xcode生成证书是一个错误。要解析(至少在Xcode 6.1 / 6A1052d中):

go to the Apple Developer website where certificates are managed: https://developer.apple.com/account/ios/certificate/certificateList.action select your certificate(s) (which should show "Managed by Xcode" under "Status") and "Revoke" it follow instructions here to manually generate a new certificate: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW32 go to Xcode > Preferences > Accounts > [your Apple ID] > double-click your team name > hit refresh button to update certificates and provisioning profiles

我使用的是Xcode 8.3.3和Xcode 9.2。我的解决方案是使用Xcode Select将默认Xcode从8切换到9:

——打印路径

$ sudo xcode-select -switch /Applications/Xcode-9.2.app

编辑:实际上,Xcode 9.2使用了来自Xcode 8.3.3的派生数据,这似乎对这里有所帮助。不是解决办法,但至少能让我继续工作。

对我来说,之前的解决方案都没用。我们发现在构建设置中有一个“总是嵌入Swift标准库”的标志,需要设置为YES。默认是NO !

构建设置>总是嵌入Swift标准库

设置好后,在再次构建之前清理项目。

给热心的读者一些解释 最重要的部分是:

将嵌入式内容包含Swift代码(EMBEDDED_CONTENT_CONTAINS_SWIFT)构建设置设置为YES,如图2所示。这个构建设置指定了目标产品是否嵌入了Swift代码的内容,当设置为YES时,告诉Xcode将Swift标准库嵌入到你的应用程序中。

该标志以前被称为嵌入式内容包含Swift代码