我正在试着在我的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

当前回答

在我的例子中,我的一个测试目标是工作的,但另一个不是。它给出了上面的错误与一个丢失的库或其他。我比较了两个测试目标的设置,发现其中一个缺少“测试主机”的配置,所以我从工作测试目标中复制了它,它修复了我破碎的测试目标!

其他回答

我认为苹果在试图引用Swift库libswiftCore.dylib时,已经在Swift应用程序崩溃下总结了它

引自技术问答QA1886:

Swift app crashes when trying to reference Swift library libswiftCore.dylib. Q: What can I do about the libswiftCore.dylib loading error in my device's console that happens when I try to run my Swift language app? A: To correct this problem, you will need to sign your app using code signing certificates with the Subject Organizational Unit (OU) set to your Team ID. All Enterprise and standard iOS developer certificates that are created after iOS 8 was released have the new Team ID field in the proper place to allow Swift language apps to run. Usually this error appears in the device's console log with a message similar to one of the following:

[....] [deny-mmap] mapped file has no team identifier and is not a platform binary:
/private/var/mobile/Containers/Bundle/Application/5D8FB2F7-1083-4564-94B2-0CB7DC75C9D1/YourAppNameHere.app/Frameworks/libswiftCore.dylib

Dyld Error Message:
  Library not loaded: @rpath/libswiftCore.dylib

Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000120021088
Triggered by Thread: 0

Referenced from: /private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/TestApp
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x1001D8000, size=0x00194000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/Frameworks/libswiftCore.dylib
Dyld Version: 353.5

The new certificates are needed when building an archive and packaging your app. Even if you have one of the new certificates, just resigning an existing swift app archive won’t work. If it was built with a pre-iOS 8 certificate, you will need to build another archive. Important: Please use caution if you need to revoke and setup up a new Enterprise Distribution certificate. If you are an in-house Enterprise developer you will need to be careful that you do not revoke a distribution certificate that was used to sign an app any one of your Enterprise employees is still using as any apps that were signed with that enterprise distribution certificate will stop working immediately. The above only applies to Enterprise Distribution certificates. Development certs are safe to revoke for enterprise/standard iOS developers.

正如AirSign人员所说,问题的根源在于内部证书的主题字段中缺少OU属性。

主题:UID=269J2W3P2L, CN=iPhone分布:公司名称,OU=269J2W3P2L, O=公司名称,C=FR

我有一个企业发展证书,创建一个新的解决了这个问题。

对于设备,您还需要将动态框架添加到项目的General选项卡中的Embedded binaries部分。

我使用的是Xcode 7.2。如果您尝试了以上所有方法,但错误仍然发生,请尝试从密钥链访问中删除旧证书!好不容易才解决这个问题。

有很多答案,但我的答案可能会帮助别人。

我也有同样的问题,我的应用程序在模拟器上工作正常,但在设备上崩溃了,因为我的午餐应用程序,并给出如上所述的错误。我已经尝试了所有的答案和解决方案。在我的情况下,我的项目我有多个目标,我从目标A创建了重复的目标B,目标B工作正常,而目标A崩溃了。我为每个目标使用不同的图像资产。在搜索和做谷歌之后,我发现了一些可能对某人有帮助的东西。

当我改变两个应用程序的启动图像资产的名称时,应用程序停止崩溃。例如,目标A启动映像资产名称LaunchImage A。目标B午餐映像资产名称LaunchImage B,并在每个目标的General Tab中正确分配。我的应用程序运行良好。

对我来说,以上的方法都没用。

通过在项目中创建一个空的swift文件,我设法摆脱了这个问题。在那之后,做一个干净的构建,一切都正常工作!

希望这能帮助到其他人。

在iOS 15和React Native 0.66上测试