Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a pod that relies on another pod

Trying to build a Cocoapod library which is dependant of other published Cocoapod library I own, got the project in XCode to build OK, but running pod lib lint command for checking pod validity fails with error: include of non-modular header inside framework module on the header files of the library (pod) I'm depending on. All source is Obj-C not Swift.

I did try the following, according to the recommendations found here

  • Setting the header files of the dependant library as public instead of project
  • Setting CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES for each target
  • verifying that the relevant headers in build phases are under public.

but problem persists, I cannot publish the pod nor test it.

Update when I comment out the s.dependency 'OldPodIDependOn' line in my podspec file of my new pod then error disappears but the dependent headers are not found. if I do not include the pod I depend on in the Podfile under the ./Example folder, like so:

target 'NewPod', :exclusive => true do
  pod "NewPod", :path => "../"
  pod "OldPodIDependOn", :path => "../../OldPodIDependOn/"
end

then project will just not build in XCode since the OldPodIDependOn files are not part of the project. Got a bit of a chicken-or-the-egg problem.

Update 2 Also tried removing the :path => "../../OldPodIDependOn/" component to reference the pod that has been published instead of a local one - doesn't help.

Worth mentioning that this pod will include a UI hence a storyboard will be included and referenced, I added s.resources = 'Pod/Classes/UI/NewPod.storyboard' line to the podspec file, and removed the storyboard from the pod target compile sources (otherwise xcode won't build). I don't think that this has something to do with the problem but worth mentioning, maybe I'm doing something wrong in there.

What am I doing wrong? Any help will be greatly appreciated!

like image 702
mindbomb Avatar asked Mar 28 '15 02:03

mindbomb


People also ask

How do you make a CocoaPod in Swift?

Implement the pod In the project navigator, right click on the SwiftyLab target and select New File... Choose Swift File as the new file template, click on Next … Name the file as SwiftyLib , make sure this file belongs to the SwiftyLib target and save it in the SwiftyLib folder as shown in the screenshot below.


3 Answers

To finally solve this issue I had to discard the workspace that pob lib create created - there was no way around it, I tried all possible combinations / recommendations / code modifications to get rid of the "non-modular header inside framework" errors but nothing seemed to work. pod lib lint ALWAYS failed.

I created my own static library xcode project from scratch, then run pod update on it after adding the dependent pod to the Podfile, then created a .podspec file for this lib and added the dependant pod header files to the "Copy files" build phase of the static lib target + libPods.a file to the "Link Binary with libs" build phase. Poof! no more "non modular header" errors from pod lib lint, even though I am practically doing the exact same thing. Lesson learnt is that pod lib create is not recommended for ALL cocoapod cases.

like image 62
mindbomb Avatar answered Oct 07 '22 06:10

mindbomb


I had the same issue, and I used

pod lib lint MyPod.podspec --allow-warnings --use-libraries

When adding the --use-libraries option, it worked.

like image 45
Adib Contractor Avatar answered Oct 07 '22 08:10

Adib Contractor


In general error: include of non-modular header inside framework module implies that one of the header files inside the resulting framework ( CocoaPods lints for both frameworks and libraries now ) is not stored inside the framework, or classed as a public header.

This can usually be worked around moving external imports into the implementation files, see this Modified to support using framework #353.

like image 30
orta Avatar answered Oct 07 '22 08:10

orta