Cocoapods: Xcode archive Library not loaded / no suitable image found

Created on 30 Sep 2015  ·  10Comments  ·  Source: CocoaPods/CocoaPods

I know there are a bunch of these topics already, but I can't seem to find a viable solution for my problem:

Configuration:
Xcode 7.0 (7A220)
Cocoapods 0.39.0.beta.4

PodFile looks something like this:

source 'https://github.com/CocoaPods/Specs.git'

link_with 'Project'

platform :ios, '8.0'
inhibit_all_warnings!
use_frameworks!

target :Project do
    pod 'SnapKit'
    pod 'Alamofire', '3.0.0-beta.3'
    pod 'SVProgressHUD'
    pod 'DKChainableAnimationKit', :git => 'https://github.com/Draveness/DKChainableAnimationKit.git', :branch => 'swift-2.0'

    source 'private@git'
    pod ...
end

When I run it in debug mode the app works perfectly on the simulator and iPad Air.
But when I archive it (without any errors or warnings) and install it through MDM (it's an enterprise app)
I get the following message in my device log:

Dyld Error Message:
Dyld Message: Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: /var/mobile/Containers/Bundle/Application/3A591DBB-07D0-421A-B5DE-17EA7483D056/Project.app/Project
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/3A591DBB-07D0-421A-B5DE-17EA7483D056/Project.app/Frameworks/Alamofire.framework/Alamofire: mmap() errno=1 validating first page of '/private/var/mobile/Containers/Bundle/Application/3A591DBB-07D0-421A-B5DE-17EA7483D056/Project.app/Frameworks/Alamofire.framework/Alamofire'
    /private/var/mobile/Containers/Bundle/Application/3A591DBB-07D0-421A-B5DE-17EA7483D056/Project.app/Frameworks/Alamofire.framework/Alamofire: mmap() errno=1 validating first page of '/private/var/mobile/Containers/Bundle/Application/3A591DBB-07D0-421A-B5DE-17EA7483D056/Project.app/Frameworks/Alamofire.framework/Alamofire'
    /private/var/mobile/Containers/Bundle/Application/3A591DBB-07D0-421A-B5DE-17EA7483D056/Project.app/Frame
  Dyld Version: 369.12

Removing / disabling Alamofire has no effect, since the error message will simply pick the next pod (alphabetically)

This is what I tried:

  • Enable Bitcode set to NO
  • Link Frameworks automatically set to NO
  • Make Pods framework weak link (Status optional in build phase)
  • Add Pods framework to "embedded binaries"

(sorry this was not cocoapods related, this can be closed)

UPDATE:
Actually selecting a different code signing identity / provisioning profile seemed to fix it...

UPDATE 2:
Digging a bit deeper in the code signing matter I came across: https://www.airsignapp.com/ios-apps-using-swift-crash-when-signed-with-inhouse-certificate/

Most helpful comment

It turns out that Xcode cache some device specific stuff which can get mixed up if you are running your apps on multiple devices. The simple fix is to delete Xcode cache. The following command clean it up for you

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode

All 10 comments

So can this be closed?

Yeah, sorry for jumping to a conclusion it would be cocoapods to quickly :)

It turns out that Xcode cache some device specific stuff which can get mixed up if you are running your apps on multiple devices. The simple fix is to delete Xcode cache. The following command clean it up for you

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode

Anyone running into this issue currently, we just had the same problem using High Sierra and Xcode 9.1. After attempting every solution from various forums, threads, etc. the solution was to switch code signing profiles. We changed from one team member to another, and the app ran on the test device finally. After testing, we reinstalled the problem user's profile and the app is now working on the device reliably again.

I used 4taras4's method.It works ,but it take time.when the terminal was working,i cannot open xcode. when i do it,it comes "您不能打开应用程序“Xcode”,因为它正在更新。"(You cannot open the application "Xcode" because it is being updated.).so I just close the terminal,and it works then.

For what it's worth, I hit a similar error in XCode 9.0.1. I tried uninstalling and reinstalling all my certs, but when I reinstalled, they seemed to remember the trust setting I had previously. What ended up working for me (it seems) was turning off the 'Always Trust' setting of the "Apple Worldwide Developer Relations Certification Authority" cert followed by a reboot. What a cryptic issue!

used 4taras4's method.It works

used 4taras4's method.It works

nice to hear that

Alternatively you can update your gem cocoa pods to 1.9.0 ( contains support module map for static libs), don't forget to add "use_frameworks! :linkage => :static" provided by cocoa pods 1.9.0
https://github.com/CocoaPods/CocoaPods/issues/9023#issuecomment-593550077

Was this page helpful?
0 / 5 - 0 ratings