Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 967 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Xcode10 - dyld: Library not loaded for pod installed in framework

#1
I have a project with target frameworks.

- MainAppTarget
- FrameworkA

FrameworkA is the only one to use a certain pod, hence in my pod file I have something like

target 'MainAppTarget' do
...
end

target 'FrameworkA' do
pod 'PodA'
end

the build succeeds with no problem, but when I run the app on a simulator the app crashes immediately with the following error message:

dyld: Library not loaded: @rpath/PodA.framework/PodA
Referenced from: .../Build/Products/Development-iphonesimulator/FrameworkA.framework/FrameworkA
Reason: image not found

I tried all the usual suspects (delete derived data, clean, pod deintegrate...) nothing worked so far.

Any idea why this would happen, and how I can make it work without having to install all the pods necessarily on both targets?

The app is in Swift 4.2.
Reply

#2
I had similar issue. Just some notes. I was using 'pod Stencil' which imported Pathkit. and suddenly got this error 'Library not loaded'. If you expand the error and split the Reason: tried: string so all the paths are on one line.
Take each path and you can do a Terminal 'ls' on each.

Though the first one should point to the build object for PathKit.

'/Users/USERNAME/Library/Developer/Xcode/DerivedData/APPNAME-gequ....op/Build/Products/Debug/PathKit.framework/Versions/A/PathKit' (no such file),

When I did a 'ls' on first path it was not found.
But if you open it in Finder up to the Debug part

'/Users/USERNAME/Library/Developer/Xcode/DerivedData/APPNAME-gequ....op/Build/Products/Debug/'


Then dig down futher under Version/A PathKit object does exist. It has black icon

I put them side by side the path in the error and path to actual file in XCode and I noticed XCode was looking in

"/Debug/PathKit.framework"

should have been looking in

"/Debug/PathKit/PathKit.framework"

I couldn't fix it but I think it was my folder layout.

I was using a workspace with two subprojects ios and macos in seperate folders with workspace in common parent folder and one Podfile in parent folder.

The Podfile file specified nested projects.

When I took the ios and macos projects out and put them in their own projects and gave them their own podfile the app compiled and ran ok. Library not found disappeared.
Reply

#3
This problem is just on iOS 13.3.1.

You can't fix it, Just you have to downgrade to iOS 13.3 or wait for Xcode new update.
Reply

#4
You have to add **pod 'PodA'** in **FrameworkA** target into **MainAppTarget** also.

target 'MainAppTarget' do
pod 'PodA'
end

target 'FrameworkA' do
pod 'PodA'
end
Reply

#5
>***`At first, check whether your CocoaPod is compatible (supported) or not`***.

Make sure you dragged `FrameworkA` to the `Embedded Binaries` section in your project's General settings tab. Also make sure you have `Embed Frameworks (1 item)` in ***Build Phases*** tab and `FrameworkA` is included there.

>Here's a solution:

**Step One**: Drag and drop `FrameworkA.framework` in your project navigation. Link framework and Library added this library.

**Step Two**: In Xcode go to Project > General > Embedded Binary > Add `FrameworkA.framework`.

**Step Three**: Make sure that in ***Build Phases*** tab `Link Binary with Libraries (1 item)` and `Embed Frameworks (1 item)` do exist.

[![enter image description here][1]][1]

[![enter image description here][2]][2]

P.S. I did it in Xcode 10.2.1 but in Xcode 10.1 it works the same way.


[1]:

[2]:
Reply

#6
The reason the build succeeds is that the `PodA` framework is visible to the `FrameworkA` during compilation (it can link to it), but when the application launches, then it tries to find and load the dynamic framework `PodA` required by the `FrameworkA`, and it looks like the `PodA` is not embedded in the `MainAppTarget`, so the app crashes with the error message you saw.

To fix this, make sure that the `PodA` framework is embedded in the `MainAppTarget`. Specifically, you need to make sure that the final app bundle contains the `PodA.framework` in the `Framewokrs` subfolder. Usually cocoapods copies the frameworks automatically.

Check that the Build Phases for the `MainAppTarget` contains cocoapods's `[CP] Embed Pods Frameworks` and that the scripts' input files contain the path to the `PodA` framework. Something like this (example shows Alamofire pod):

[![enter image description here][1]][1]

I have set up a project with the details you posted, but it looks to me that cocoapods handles this case automatically in the created workspace setup (you can take a look at my demo project here:

[To see links please register here]

). If your setup is different, please let me know of the details and I can help you further with that.


[1]:
Reply

#7
From your error message, there are a few things that should be checked.
>
dyld: Library not loaded: @rpath/PodA.framework/PodA
Referenced from: .../Build/Products/Development-iphonesimulator/FrameworkA.framework/FrameworkA
Reason: image not found

The first thing that seems odd is that the path for the framework that is being loaded (FrameworkA.framework) is not embedded inside an app. Check the "General" tab of the MainAppTarget and make sure the framework is appearing in the "Embedded Binaries" and "Linked Frameworks and Libraries" sections.

Second, `@rpath` is a shorthand for the `runpath` search path list, which tells `dyld` where to look for needed libraries.

Here's an example project on Github with a main app that uses one Cocoapod, and a dynamic framework that the main app depends on that uses a different Cocoapod:

[To see links please register here]


Build settings that you should check on all of the targets that are involved (including the framework targets built by the Pods project):

- Runpath Search Paths (`LD_RUNPATH_SEARCH_PATHS`)
- In the example project, these are determined by the cocoapod, but each one is set to `$(inherited) @executable_path/Frameworks @loader_path/Frameworks`
- Dynamic Library Install Name (`LD_DYLIB_INSTALL_NAME`)
- In the example project, this is unchanged from the default `$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)`
- Dynamic Library Install Name Base (`DYLIB_INSTALL_NAME_BASE`)
- In the example project, set to `@rpath` (again determined by the Cocoapod)

Here's a screenshot of the built application bundle showing how it's laid out:
[![Finder window][1]][1]

[1]:


You can use `otool` to get information about how the application is assembled by xcodebuild.

Here's the main app binary:
```
otool -L FrameworkPodTest
FrameworkPodTest:
@rpath/KeychainSwift.framework/KeychainSwift (compatibility version 1.0.0, current version 1.0.0)
@rpath/Lottie.framework/Lottie (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 61000.0.0)
@rpath/Framework.framework/Framework (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1560.10.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics (compatibility version 64.0.0, current version 1245.9.2)
...
```

And the framework binary:
```
otool -L Frameworks/Framework.framework/Framework
Frameworks/Framework.framework/Framework:
@rpath/Framework.framework/Framework (compatibility version 1.0.0, current version 1.0.0)
@rpath/KeychainSwift.framework/KeychainSwift (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1560.10.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
@rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1000.11.42)
@rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 1000.11.42)
...
```
Reply

#8
I too was facing the same problem. All you need to do is set the third party frameworks you are using for e.g:- PodA as Optional instead of Required under Link binary with Libraries in build Phases section. That's all. try it again and it will run as expected.

Note:- You need to add the PodA in the app in which you are using your framework.
There is no other way except create a static framework consisting your PodA and use this newly created static framework inside your dynamic framework.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through