dyld:庫未加載:@ rpath / libswiftCore.dylib

本文翻譯自:dyld: Library not loaded: @rpath/libswiftCore.dylib

I am trying to run a Swift app on my iPhone 4s. 我正在嘗試在iPhone 4s上運行Swift應用程序。 It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. 它在模擬器上運行良好,我的朋友可以在他的iPhone 4s上成功運行它。 I have iOS 8 and the official release of Xcode 6. 我有iOS 8和Xcode 6的正式版本。

I have tried 我試過了

  • Restarting Xcode, iPhone, computer 重新啓動Xcode,iPhone,計算機
  • Cleaning & rebuilding 清潔與重建
  • Revoking and creating new certificate/provision profile 吊銷和創建新的證書/設置配置文件
  • Runpath Search Paths is $(inherited) @executable_path/Frameworks 運行路徑搜索路徑爲$(inherited) @executable_path/Frameworks
  • Embedded Content Contains Swift Code is 'Yes' 嵌入式內容包含Swift代碼爲“是”
  • 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

#1樓

參考:https://stackoom.com/question/1lC3Y/dyld-庫未加載-rpath-libswiftCore-dylib


#2樓

For the device, you also need to add the dynamic framework to the Embedded binaries section in the General tab of the project. 對於設備,還需要將動態框架添加到項目的“ General選項卡中的“ Embedded binaries部分。
在此處輸入圖片說明


#3樓

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. 我們發現在“構建設置”中有一個“始終嵌入Swift標準庫”標誌,需要將其設置爲“是”。 It was NO by default! 默認情況下是NO!

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. 將您的應用程序中的“嵌入式內容包含Swift代碼”(EMBEDDED_CONTENT_CONTAINS_SWIFT)構建設置設置爲YES,如圖2所示。此構建設置指定目標產品是否具有包含Swift代碼的嵌入內容,告訴Xcode將Swift標準庫嵌入應用程序設置爲YES時。

在此處輸入圖片說明

The flag was formerly called Embedded Content Contains Swift Code 該標誌以前稱爲Embedded Content Contains Swift Code


#4樓

I think it's a bug when certificates are generated directly from Xcode. 我認爲直接從Xcode生成證書時是一個錯誤。 To resolve (at least in Xcode 6.1 / 6A1052d): 要解決(至少在Xcode 6.1 / 6A1052d中):

  1. go to the Apple Developer website where certificates are managed: https://developer.apple.com/account/ios/certificate/certificateList.action 轉到管理證書的Apple Developer網站: https : //developer.apple.com/account/ios/certificate/certificateList.action
  2. select your certificate(s) (which should show "Managed by Xcode" under "Status") and "Revoke" it 選擇您的證書(應在“狀態”下顯示“由Xcode管理”)並“吊銷”它
  3. follow instructions here to manually generate a new certificate: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW32 請按照此處的說明手動生成新證書: https : //developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31- SW32
  4. go to Xcode > Preferences > Accounts > [your Apple ID] > double-click your team name > hit refresh button to update certificates and provisioning profiles 轉到Xcode>首選項>帳戶> [您的Apple ID]>雙擊您的團隊名稱>點擊刷新按鈕以更新證書和配置文件

#5樓

I started getting this error when I removed: 刪除後,我開始出現此錯誤:

@executable_path/Frameworks

from Runpath Search Paths in my build settings. 從我的構建設置中的運行Runpath Search Paths中。 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. 我不知道它是怎麼到達那裏的,但是似乎二進制文件才需要找到它的嵌入式Swift運行時。


#6樓

In my case, it was just the name of my target : 就我而言,這只是我的目標的名稱:

I renamed it like this : MyApp.something and the same issue appeared. 我將其重命名爲: MyApp.something ,出現了相同的問題。 But I saw in the build Settings window, my product module name has been changed like this MyApp-something . 但是我在構建設置窗口中看到,我的產品模塊名稱已經像MyApp-something這樣更改 So, I removed the dot in my target name ( MyAppSomething ) and the issue was gone. 因此,我刪除了目標名稱( MyAppSomething )中的點,問題就消失了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章