Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I include a .pch for a specific pod, in cocoapods?

Tags:

cocoapods

In my projet MyProject (I'm using cocoapods), I want to use MyPod.

The classes of MyPod are copied to MyProject, but not the .pch. Hence, the project is not compiling.

So, I have two questions :

  1. How can I add the .pch of MyPod to the imported classes of MyPod?
  2. Is there a way to "include" the .pch of MyPod in the .pch of MyProject (or, to "modify" the latter)

I am sure 1. is possible. I am learning cocoapods right now.


EDIT

As said in the documentation of cocoapods, the prefix_header_contents attribute of a .podspec is "not recommended as Pods should not pollute the prefix header of other libraries or of the user project."

So, is there any other way? Are we supposed to develop libraries without anything in the .pch?

like image 655
Colas Avatar asked Feb 05 '14 12:02

Colas


People also ask

What is Subspec in CocoaPods?

One of the main purposes of subspecs is to enable configuration of a single framework. If you want separate frameworks, you should use a separate podspec for each one.


1 Answers

You have to use the following property:

s.prefix_header_contents

For instance: s.prefix_header_contents = '#import "SomeClass.h"'.

It will add this line of code to the pch file associated to the Pod.

like image 87
Colas Avatar answered Oct 16 '22 07:10

Colas