dyld: Library not loaded: @rpath/libswiftCore.dylib

I am trying to run a Swift app on my iPhone 4s. It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. I have iOS 8 and the official release of Xcode 6.

I have tried

  • Restarting Xcode, iPhone, computer
  • Cleaning & rebuilding
  • Revoking and creating new certificate/provision profile
  • Runpath Search Paths is $(inherited) @executable_path/Frameworks
  • Embedded Content Contains Swift Code is 'Yes'
  • Code Signing Identity is developer
  • Below is the error in entirety

    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
    

    For me none of the previous solutions worked. We discovered that there is an "Always Embed Swift Standard Libraries" flag in the Build Settings that needs to be set to YES. It was NO by default!

    Build Settings > Always Embed Swift Standard Libraries

    After setting this, clean the project before building again.

    For keen readers some explanation The most important part is:

    set the Embedded Content Contains Swift Code (EMBEDDED_CONTENT_CONTAINS_SWIFT) build setting to YES in your app as shown in Figure 2. This build setting, which specifies whether a target's product has embedded content with Swift code, tells Xcode to embed Swift standard libraries in your app when set to YES.

    在这里输入图像描述

    The flag was formerly called Embedded Content Contains Swift Code


    Surprisingly enough, all i did was "Clean" my project (shift+cmd+K) and it worked. Did seem to be related to the certificate though.


    I started getting this error when I removed:

    @executable_path/Frameworks
    

    from Runpath Search Paths in my build settings. Replacing it fixed everything up again (thank goodness for source control!)

    I don't know how it got there, but it appears to be needed for a binary to find its embedded Swift runtime.

    链接地址: http://www.djcxy.com/p/49918.html

    上一篇: Xcode 7.2找不到匹配的配置文件

    下一篇: dyld:库未加载:@ rpath / libswiftCore.dylib