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

当前回答

如果你得到一个这样的错误:

“YourFrameworkTests”包无法加载,因为它已经加载了 损坏或缺少必要的资源。尝试重新安装bundle。 (dlopen_preflight(/一些/道路/…/ YourFrameworkTests.xctest / YourFrameworkTests): 库未加载:@rpath/SomeOther.framework/SomeOther引用 来自:/一些/道路/…)

并在框架中使用CocoaPods,然后尝试编辑Podfile并删除继承!:search_paths从Test目标,并再次运行pod install。

详情请见https://github.com/CocoaPods/CocoaPods/issues/8868。

其他回答

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

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

希望这能帮助到其他人。

在iOS 15和React Native 0.66上测试

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

@executable_path/Frameworks

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

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

当Xcode要求你重置certs时,你重置它。应用程序可以在实际设备上运行,而不会因错误消息而崩溃。一旦在一个swift项目中解决了这个问题。其他swift项目也解决了这个问题。

我已经为此奋斗了大约半天,我发现在配置门户中一次又一次地重置certs并没有帮助。

换了新mac后,我也遇到了同样的问题,几个小时后,我尝试了问题中所有建议的答案,但没有一个对我有效。

我的解决方案是安装这个丢失的证书。 http://developer.apple.com/certificationauthority/AppleWWDRCA.cer

在这里找到了答案。 https://stackoverflow.com/a/14495100/976628

我也有同样的问题

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

// MARK: -核心数据堆栈

 lazy var persistentContainer: NSPersistentContainer = {
            /*
             The persistent container for the application. This implementation
             creates and returns a container, having loaded the store for the
             application to it. This property is optional since there are legitimate
             error conditions that could cause the creation of the store to fail.
            */
            let mom = NSManagedObjectModel.mergedModel(from: [Bundle(for: Self.self)])!
            
            let container = NSPersistentContainer(name: "Test", managedObjectModel: mom)
            container.loadPersistentStores(completionHandler: { (storeDescription, error) in
                if let error = error as NSError? {
                    // Replace this implementation with code to handle the error appropriately.
                    // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
                     
                    /*
                     Typical reasons for an error here include:
                     * The parent directory does not exist, cannot be created, or disallows writing.
                     * The persistent store is not accessible, due to permissions or data protection when the device is locked.
                     * The device is out of space.
                     * The store could not be migrated to the current model version.
                     Check the error message to determine what the actual problem was.
                     */
                    fatalError("Unresolved error \(error), \(error.userInfo)")
                }
            })
            return container
        }()