我正在试着在我的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文件(void.swift)。当我添加这个文件时,它要求我创建一个桥接。我答应了。这是所有!它开始起作用了。 背景:我的项目是写在obj c.和我添加了FBSDK pods到我的项目。在那之后,我开始得到这个错误。

其他回答

没有一个解决方案对我有效。重启手机解决了这个问题。这很奇怪,但很有效。

对我来说什么都没用,然后我做了下面这些步骤:

我从podfile中删除了flipper的使用情况。在我看来是这样的: use_flipper !({Flipper-Folly”= >“2.5.3”,“鳍”= >“0.87.0”,“Flipper-RSocket ' = > ' 1.3.1 '}) 我在我的项目中添加了一个swift文件来创建一个桥接头。

当升级Xcode(并随后升级到新版本的Swift)时,如果你的项目使用了用旧版本/以前版本的Swift构建/编译的框架,也会导致此错误消息。

在这种情况下,重新构建框架并重新添加它将解决问题。

我在Xcode 13+上创建版本时也遇到了同样的问题。不得不把时间浪费在解决这个问题上。最后,我能够解决以下步骤的问题。

我在构建设置中的运行路径搜索路径中添加了一个新的发布条目->链接。

/usr/lib/swift

添加了这个功能后,我可以运行我的应用程序而不会崩溃!

我也有同样的问题

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

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