Ivan
Ivan

Reputation: 664

dyld: Library not loaded: @rpath/Alamofire.framework/Versions/A/Alamofire Reason: image not found

I'm using CocoaPods v0.36 with my Swift project and the following pods: Alamofire, CocoaLumberjack, SwiftyJSON.

Everything was fine till I used my Developer ID. Compiler started to have problems to compile the project, after some fixes and updates for CocoaPods my project compiles but at runtime I get the following error:

dyld: Library not loaded: @rpath/Alamofire.framework/Versions/A/Alamofire   
Referenced from: /Users/Ivan/Library/Developer/Xcode/DerivedData/myApp-bsxfcnwqpaxnzbhencwzteasshzf/Build/Products/Debug/myApp.app/Contents/MacOS/myApp  
Reason: image not found

I read different posts related to this:

But none seems to solve the issue.

The only clue that I have is that the 3 frameworks are in red, so it seems that are not generated/linked.

enter image description here

Now, I've removed my Developer ID, but the issue is still there. Does anybody have an idea?

Upvotes: 34

Views: 38311

Answers (15)

Mohammad Daihan
Mohammad Daihan

Reputation: 648

First step: add use_frameworks! at the beginning of your podfile.

Second step: Add the bellow code at the end of your podfile. Which means after the end of your target.

dynamic_frameworks = ['Alamofire']
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if !dynamic_frameworks.include?(pod.name)
      puts "Overriding the static_framework? method for #{pod.name}"
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

Third step: run pod install

Upvotes: 0

Mandeep Singh
Mandeep Singh

Reputation: 905

After wasting full day i found the solution. I changed

pod 'Alamofire' or pod 'Alamofire', '~> 5.2'

to

pod 'Alamofire', '~> 5.0.0-rc.3'

And this worked for me.

Upvotes: 0

Behrad Kazemi
Behrad Kazemi

Reputation: 402

I solved the problem in another way. The missing library was used inside of a framework that the application has a dependency on that. Also, In the Podfile the framework's pod target was outside of the application's target, so I moved the framework's target inside it like below:

target 'MyApplication' do
  use_frameworks!
  #blah blah 

  target 'MyFramework' do
    use_frameworks!
    pod 'The crashing library'
    #more blah blah

  end
end

and then I ran the 'pod install' command and Boom! The crash was gone.

Upvotes: 0

Hitesh Surani
Hitesh Surani

Reputation: 13557

I have tried all the above solutions but no luck.

For me, Just run your app using an enrolled account instead of a free apple account.

Note: Free account is not worked in 13.3

Upvotes: 2

Behnam Rakhshani
Behnam Rakhshani

Reputation: 563

in iOS 13.3.1 you can't run your application in your apple device without paid developer account

you can read complete explanation in this link

complete explanation click here

Upvotes: 0

Rishabh Shukla
Rishabh Shukla

Reputation: 501

For iOS 13.3.1 : comment use_frameworks in podfile .

Upvotes: 10

ssp009
ssp009

Reputation: 11

After wasting two days and applying every solutions this worked for me. Hope it helps to you too.

Go to Keychain Access -> Certificates -> Double click on Apple Worldwide Developer Relations Certification Authority -> Click on the dropdown of trust -> When using this certificate -> set to Use System defaults

Upvotes: 1

Vladyslav Panchenko
Vladyslav Panchenko

Reputation: 1607

Try this:

Find your Target --> Build Phases --> Add New Copy Files Phase -->Choose Destination Option,Frameworks --> Click add AFNetworking.framework --> ✓.

Upvotes: 5

Drobs
Drobs

Reputation: 770

None of the other stuff worked for me. So what did solve it for me in the end was a change in the podfile. I changed the code for the target in which it happened to:

target 'UITests' do
inherit! :search_paths
end

After a pod install it finally worked.

Upvotes: 0

Dhaval H. Nena
Dhaval H. Nena

Reputation: 4140

Make sure you have set valid certificate and provisioning profile in XCode!

Upvotes: 2

Ivan
Ivan

Reputation: 664

Solved Below the steps I did:

  • pod deintegrate, pod update, pod install
  • Reimported the three swift library files (generated by cocoapods)
  • Imported the three frameworks only in the Linked Frameworks and Libraries
  • Full clean and a build

Upvotes: 26

Atef
Atef

Reputation: 2902

Solved by Unchecking Copy Only when installing. enter image description here

Upvotes: 2

Qun Li
Qun Li

Reputation: 1316

I solved that trouble just by uncheck the "copy only when installing" on copy frameworks in Build Phases

Upvotes: 1

NSurajit
NSurajit

Reputation: 421

dyld library not loaded @rpath/framework

please make sure that the framework is showing under target->general->embeded binaries and linked framework and libraries section

if not then add by clicking + sign add just add the framework only

done!

Upvotes: 21

bolnad
bolnad

Reputation: 4583

we were running into this issue here at work and one person's project would run while the other would get this strange error.

We did some comparison and realized that error is being generated when in the Xcode project's target, under Build Phases its missing some of the run scripts that Cocoapods is supposed to generate.

Check your project to make sure that these 3 scripts are there

Check Pods Manifest.lock
 Embed Pods Frameworks
 Copy Pods Resources

If they aren't I've attached a screenshot of them so that you can add them manually

enter image description here enter image description here enter image description here

Upvotes: 6

Related Questions