Cocoapods: Unclear how to add source files to Xcode when creating a pod

Created on 4 Jan 2015  路  3Comments  路  Source: CocoaPods/CocoaPods

Hi,

I'm trying to create a new CocoaPod, my very first actually. I'm following http://guides.cocoapods.org/making/using-pod-lib-create.html but it is unclear to me how I should go about adding new source files to my pod. The guide says conflicting things like:

Pod - This is where you place your library's classes

Then it says:

Development Pods
Development Pods are different from normal CocoaPods in that they are symlinked files, so making edits to them will change the original files, so you can work on your library from inside Xcode. Your demo & tests will need to include references to headers using the #import format.

[!] Note: Due to a current Development Pods implementation detail, when you add new/existing files to Pod/Classes or Pod/Assets or update your podspec, you should run pod install or pod update.
[!] Note: Whenever you update your podspec鈥檚 version, you must run pod update or pod update POD_NAME instead of pod install.

So do I add my classes to Pod/Classes? If so, how? The directory Pod/Classes is not part of the Example project, so how do I add classes? Normal procedure is to right click on a project or group in Xcode and click New File ... But the Pod/Classes is not a group in the Example project, in fact, it's not even under the same directory subtree, so I don't know how well Xcode will play with this.

So which project do I add my classes to - Example or Pods? If it's Example, how should I include the classes since they're supposed to be in Pod/Classes which isn't even under the subtree for the Example project? If I'm supposed to add the classes to the Pods project, then where, under Development Pods/MyPodName?

Or do I just do

cd Pod/Classes
touch Foo.m Foo.h

? That would be really awkward because I'd lose the benefit of Xcode generating the class files from a template.

I'm really eager to get started but I don't understand at all how to add classes to my pod.

If you can give me details I'd be happy to update the cocoa pods guides with a more newbie-friendly version of "How to Add Classes". :-)

Most helpful comment

Thank this helped me too ! +1
It should definitely be more clear how to do it, and best if normal xcode/appcode way, thanks.

All 3 comments

Create your source files however you like, and (in Finder) place them at the location specified by source_files in your podspec. For most of my pods, this is outside the example project's folder. Then you run pod install for your example project and the pod files will be symlinked to your project as a development pod.

For now ^

Now https://github.com/CocoaPods/CocoaPods/pull/2647 is merged, you can right click on the folder and it will add it correctly. And it will get the correct ARC settings. It's not in public release though yet. So there's no need for a bunch of the recommendations. Updating the pod lib create for swift is on my TODO, and this will come with it.

Thank this helped me too ! +1
It should definitely be more clear how to do it, and best if normal xcode/appcode way, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steffendsommer picture steffendsommer  路  3Comments

Mingmingmew picture Mingmingmew  路  3Comments

tlandsmancars picture tlandsmancars  路  3Comments

Curtis-Halbrook picture Curtis-Halbrook  路  3Comments

pronebird picture pronebird  路  3Comments