21

I've been reading all the issues about the error:

dyld: Library not loaded: @rpath/Bolts.framework/Bolts Referenced from: /private/var/mobile/Containers/Bundle/Application/1542F906-CCE1-4181-AC7C-B5E3EE50E7D7/eBikeMotion.app/eBikeMotion Reason: no suitable image found. Did find:

Which makes my application unable to run in a real device (but it runs without any problem in the simulator. Until certain point I thought that it was an issue with the frameworks I was installing, but after installing manually the original one that was throwing the error, Alamofire, and the next Framework throwing the error was the next one in alphabetical order (Bolts, as you can see in the code snippet) So I've reached the conclusion that is indeed CocoaPods which is producing these errors. I've got the last version (0.37) with a clean install, Iv'e tried to create a new project, I've tried all the proposed solutions to this issue without any luck, so I have to open an issue, with the hope that someone can help me.

Regards.

Jorge Revuelta
  • 822
  • 1
  • 8
  • 16

7 Answers7

41

After reinstalling the whole system and don't finding a solution, I've found that some of the Build Phases mandatory for CocoaPods to run properly were missing.

The solution for this problem goes for the next steps:

  1. Deintegrate the cocoapods project (you can install the tool with sudo gem install cocoapods-deintegrate).

cocoapods-deintegrate on Github

  1. Modify your Podfile:

    You should define your target linking with link_with 'ProjectName'.

    You should define the target for your pods: target 'ProjectName' do [pods here] end.

  2. Make an install with pod install

  3. After doing this, go to XCode and check the following settings:

    Into project settings, under "Configurations" check that in Debug and Release you've got a Configuration set named Pods-ProjectName.[debug|release]

    Into your target, under "Build Phases" you should have three new phases that should be named: Check Pods Manifest, Embed Pods Frameworks and Copy Pods Resources.

  4. Make a clean, then build, then run into your device.

That's it.

Adrian
  • 16,233
  • 18
  • 112
  • 180
Jorge Revuelta
  • 822
  • 1
  • 8
  • 16
24

In my case, I followed the above answer by @Jorge, but it didn't resolve the problem. The exact error was a bit different because the missing file was @rpath Pods.framework/Pods. I finally resolved it with help from CocoaPods issue #3586:

Go to target > General > Linked Frameworks and Libraries section set both Pods.framework and Pods_target.framework to Optional.

Still trying to figure out exactly why.... this answer has some info: what-does-it-mean-to-weak-link-a-framework

Community
  • 1
  • 1
Suz
  • 3,744
  • 3
  • 23
  • 26
  • 2
    In Xcode 7beta3 onwards, the Enable Bitcode option is set to true by default. And then you will still get the warning `-weak_framework is treated as -framework when ENABLE_BITCODE=YES`, in other words, marking a framework as Optional is ignored, so running on device still fails. For now I've disabled Bitcode, but it will be a problem later on. – mluisbrown Aug 05 '15 at 23:22
  • After one hour, this was the only solution that helped me! Thanks @suz – Mário Carvalho Feb 12 '16 at 15:34
  • 1
    This gets me one step farther -- the executable starts -- but fails with `dyld: lazy symbol binding failed` when it actually wants to use the framework. – Raphael Feb 16 '17 at 10:59
  • I tried this but I am still getting the error. Especially with GTMSessionFetcher – thenakulchawla Feb 18 '20 at 14:52
11

I had to fix two issues:

  1. Go to each target then Build Phases then Link Binary With Libraries and select Pods.framework. Set it to Optional.

  2. Cocoapods did not create the needed run scripts for my second target. My first target had all scripts. The second not. So I copied all missing run scripts from the first to the second target. You need to tap on the small "+" sign on the top left, add a run script and paste the script from the other target. I've done that for Check Pods Manifest.lock, Copy Pods Resources and Embed Pods Frameworks.

Then it did run on the device. Finally.

Raphael
  • 3,846
  • 1
  • 28
  • 28
  • Had the same problem here with version 0.38.2. Seems like it's still an issue... in my case it did not create the `Embed Pods Frameworks` script for two of my targets. – Zaphod Sep 03 '15 at 05:59
  • Almost a day spent on this and the one thing I was missing was the Embed Pods Frameworks script. You saved my day before going to sleep – mdonati Apr 19 '17 at 00:27
2

Had same issue adding pods to WatchKit Extension. Linking main target with Watch app is not the best option at all. Found out that cocoapod 0.37.2 hasn't added 'Embed Pods Frameworks' script into build phase.

Script: "${SRCROOT}/Pods/Target Support Files/Pods-ExtensionName/Pods-ExtensionName-frameworks.sh"

badeleux
  • 592
  • 5
  • 15
1

In order to have cocoapods generate the build phases Check Pods Manifest, Embed Pods Frameworks and Copy Pods Resources:

1 - Go to build phases and remove any custom modifications. I had to remove everything under the Link Binary With Libraries phase.

2 - Do a pod deintegrate (Or just remove the files yourself)

3 - Run a new pod install

This worked for me. Without the first step, it never did.

Siamaster
  • 941
  • 12
  • 19
0

To Resolve this you need to change status in Link Binary with Libraries in build phase for pod_projectName.framework and Bolt.framework

I got the same error in my project.

get error in CommonCrypto.framework

Resolved error by changing Required to Optional

Bhavesh Patel
  • 596
  • 4
  • 17
0

The easiest thing to do would be to ensure that your Protobuf.framework is a dependency in your target's scheme inside the Build step.

This tells Xcode to compile the Protobuf.framework created by your pod install/update whenever it builds your target.

Dino Alves
  • 113
  • 10