Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pod handling in cocoa touch framework - Got error on Device

I've googled about 2-3 hours and tried out several things but I'm not able to get this working:

What I like to achieve

The goal is to split UI code and business logic. The business logic should be capusled in a seperate framework. A Cocooa Touch Framework. So the business logic can be reused in a WatchKit App for example.

How I tried to do that

  1. Create a new Xcode Project -> Choose Single View Application.
  2. Add a new Target -> Choose Cocoa Touch Framework.
  3. Run pod init.
  4. Add some pods in the Podfile for each target.
  5. Run pod install.
  6. Implement some code in the UI and Framework

This runs perfectly on the simulator. As soon I will run it on the device the following error appears in the debugger:

dyld: Library not loaded: @rpath/SwiftAddressBook.framework/SwiftAddressBook Referenced from: /private/var/mobile/Containers/Bundle/Application/48E58889-78D4-4D71-B8DA-154ADEB98894/Pod Error Framework.app/Frameworks/PodErrorKit.framework/PodErrorKit Reason: image not found

I do not know how to solve that. Any suggestions?

I'm using:

  • cocoapods 0.38.2
  • Xcode 6.4 (6E35b)
  • Deployment Target iOS 8

I've uploaded the Project (just a fake project, but the same error) to github. You can view it here.

like image 662
aofs Avatar asked Aug 17 '15 12:08

aofs


People also ask

What is cocoa pods in Xcode?

Cocoapods is an application level dependency manager that runs on objective-c, swift, and any other programming languages that run on Objective-C. It focuses on source-based distribution of third party code and allows automatic integration to your Xcode projects.

Does CocoaPods support XCFramework?

Publicly host the XCFramework While you can host your binary anywhere and publish that via SPM, CocoaPods is a bit more strict and requires you to keep the built binaries with the Podspec. In this case, it's best to keep the XCFramework in your git repository and push it along.


1 Answers

The fix is here https://github.com/keithyipkw/pod-cocoa-touch-framework

SwiftAddressBook.framework is dynamic so you need to embedded it into you app just like PodErrorKit. The details is in my commit. The simulators cheat by somehow being able to find the frameworks outside the app (next to it in the derived data).

I could not compile your project because of missing Pods.framework. I could not find the target so I removed it.

like image 72
keithyip Avatar answered Oct 05 '22 23:10

keithyip