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

当前回答

我也有同样的问题

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

// 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
        }()

其他回答

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

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

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

我在试图在一个私人pod上运行单元测试时遇到了这个问题。

每个人建议的我都做了。毫无效果。

我所要做的就是在不同的模拟器上运行单元测试。

我没有尝试重置模拟器的内容和设置,也许这也可以¯_()_/¯

我也有同样的问题

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

// 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
        }()

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

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

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

这些解决方案似乎都不起作用,但当我将全球开发人员证书的权限更改为使用系统默认值时,它就起作用了。我在下面的链接中包含了步骤和截图

我鼓励你在苹果漏洞报告中登录,因为苹果真的应该解决这个巨大的错误: https://stackoverflow.com/a/41401354/559760