4

I have an Xcode project (foo) which builds a static library (libfoo.a) with some important pre/post build steps. Traditionally, when I use this library in another project I add foo.xcodeproj as a subproject in my main project, and then hookup the build dependency settings in the main project.

I'm looking to make this easier with CocoaPods, but I'm not sure it's designed for this. Am I supposed to copy the build settings out of the foo project into a pod spec, so that CocoaPods can build it the way it wants? What about my pre/post build steps?

There is info on creating Pods for closed source pre-compiled libraries like the TestFlightSDK, but I don't want to precompile my library.

brianpartridge
  • 763
  • 8
  • 19

4 Answers4

0

With Cocoapods you don't need to be concerned about the target, per se. It makes a new project with all the source files from your library and creates a single libPods.a which includes all Pod dependencies.

If you create a Podspec with the correct source_files and public_header_files, it should just work.

yaakov
  • 5,552
  • 35
  • 48
  • Yeah, I understand how it works with the libPods.a etc. My concern is that there are more steps to the build process than just compilation of source files with some compiler flags (code generation for example). I want my full build process to run, not just the compilation. – brianpartridge Mar 24 '13 at 01:33
0

Using the pre_install hook (0.17 docs with a minor change in syntax) you can perform any build action that you need.

The usage of this hook is not encouraged in the master repo, however for private specs it is supported.

Fabio
  • 3,466
  • 1
  • 20
  • 15
  • Out of curiosity, what where you expecting as a clean implementation? – Fabio Mar 26 '13 at 11:27
  • Ideally, I could specify an xcodeproj file and a target, and the Pods project would pull it in as a subproject and set that target as a dependency. That way, when libPods.a builds, it builds and statically links in my target's result. All my build steps would run, and no additional work is required from the project maintainer. – brianpartridge Mar 27 '13 at 00:29
  • What are you suppose to write in the hook? – huggie Aug 22 '13 at 07:02
0

Could use the prepare_command hook(documentation) and in it alter your Xcode project using the ruby gem xcodeproj(xcodeproj site) which is used by CocoaPods. I'm not sure, but is probably possible to add build scripts with it.

Not sure whether this is accepted or not for podspecs in the public repo.

Niklas Berglund
  • 3,563
  • 4
  • 32
  • 32
0

Seems like there's already answer for you: Create podspec to ship static library

There are both ways revealed (As an .a + headers library, or as a .framwerork)

Think .framework is a preferred way to share.

Community
  • 1
  • 1
Oleg Shanyuk
  • 1,296
  • 2
  • 15
  • 26