Cocoapods: dyld: Library not loaded, Reason: image not found

Created on 13 May 2016  路  15Comments  路  Source: CocoaPods/CocoaPods

What did you do?

  • Create a new project (ios, swift)
  • Add a framework target and link with app as embedded binary
  • Install any pod with framework project as target
  • Import and use pod inside framework project
  • Import and use framework inside app project
  • Run the app in simulator or on device

    What did you expected to happen?

Pod should be usable inside the framework, app should not crash.

What happened instead?

Pod can be used inside the framework, but the app crashes immediately after launch with the following message (EXC_BREAKPOINT)

dyld: Library not loaded: @rpath/RandomKit.framework/RandomKit
  Referenced from: [some path]/Build/Products/Debug-iphonesimulator/PodsTestFramework.framework/PodsTestFramework
  Reason: image not found

Please see my demo project.

CocoaPods Environment

Stack

   CocoaPods : 1.0.0
        Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
    RubyGems : 2.0.14.1
        Host : Mac OS X 10.11.4 (15E65)
       Xcode : 7.3.1 (7D1014)
         Git : git version 2.7.4 (Apple Git-66)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 44dde03a3843e26e66eb37bf453a7a95879dce38

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.0
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.0.0
cocoapods-try         : 1.0.0

Podfile

use_frameworks!

target 'PodsTestFramework' do
    platform :ios, '8.0'

    pod 'RandomKit'
end

Project that demonstrates the issue

https://dl.dropboxusercontent.com/u/34628949/PodsTest.zip

All 15 comments

Integrating into frameworks is currently unsupported.

Oh, didn't know that... Is there a roadmap for that feature?

No, it's not on our upcoming roadmap, though we should add a warning as soon as possible that this doesn't happen in the build process

Too bad :(
I think that would be helpful, maybe a warning/error during install/update process.
I will close this issue.

By the way, can I put this somehow on a feature request list? ;)

@tfonfara a PR adding a warning would be a great start ;)

@segiddins I'd love to contribute, unfortunately I'm not familiar with ruby :(

I run into the same issue it usued to worked before right?

Update: I found a way to integrate Cocoapods with frameworks. The only thing we have to do is to link the pods we use in the framework target also in the app target that embeds the framework:

use_frameworks!

target 'PodsTestApp' do
    platform :ios, '8.0'

    pod 'RandomKit'
end

target 'PodsTestFramework' do
    platform :ios, '8.0'

    pod 'RandomKit'
end

This was added in 1.1.x - BTW you could make that Podfile:

use_frameworks!

abstract_target 'My Pods' do
    platform :ios, '8.0'
    target 'PodsTestApp'
    target 'PodsTestFramework'

    pod 'RandomKit'
end

Currently I use that style which one is the "preferred one"?

use_frameworks!

def framework_pods
    pod 'RandomKit'
end

target 'PodsTestApp' do
    platform :ios, '8.0'

    framework_pods
    pod 'WhateverPod'
end

target 'PodsTestFramework' do
    platform :ios, '8.0'

    framework_pods
end

There is no preferred one, both work fine 馃憤 - https://github.com/CocoaPods/CocoaPods/issues/6256#issuecomment-264097242 has an example similar

Tkx! 馃憤

This was helpful. Thanks.

I didn't understand how you solve it, it was not meant to be clear.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gerchicov-bp picture gerchicov-bp  路  3Comments

sonu5 picture sonu5  路  3Comments

soleares picture soleares  路  3Comments

dawnnnnn picture dawnnnnn  路  3Comments

marzapower picture marzapower  路  3Comments