xcodecocoapodspost-installpodspec

CocoaPods: How can I specify that certain items should not be added to Build Phases in a podspec?


Working on Cat2Cat and a couple other items which have little executables, I'd like to make sure that those executables are not included in the Build Phases so as to avoid the warning: no rule to process file warnings I'm getting on the executables.

I'm having trouble figuring out how to make this work since I'm a bit crap with Ruby. It looks like it'd probably have to be some kind of post_install script to remove the file from the target, but I'm a bit unclear as to what one can do with a post_install script is documented.

I've taken a look at the Podspec Syntax Reference, but it doesn't seem to be too helpful for this sort of thing.

Anybody either a) Got some code already doing this you can share as an example or b) Got any suggestions as to where I can figure out how the hell to do this?

Thanks!


Solution

  • For files you want to keep in the Pods subdirectory but not have Xcode build, add them to the preserve_paths key in the podspec file. In particular, for Cat2Cat, change

    s.source_files = 'CocoaPod/*'
    

    (which has no actual source code or anything to build, just files to have around) to

    s.preserve_paths = 'CocoaPod/*'
    

    Apparently, when Cocoapods installs a pod, it downloads everything, then deletes the files that don't match the various paths/patterns of files that the podspec says to use for something (source_files, resources, etc.) and preserve_paths is the way to keep files around without having them get "used" for something like a build phase.

    Caveat: This doesn't seem to work when referencing a local file system copy of a pod.