CocoaPods and Nibs

Posted by Grego on June 29, 2015

I had a great time this weekend </sarcasm> dealing with some interesting issues involving CocoaPods and some pod code I wrote that uses separate .xib files. I kept getting the following message in Xcode when I tried to run the app:

Unable to run command 'StripNIB HotMeterView.xib' - this target might include its own product.

As it turns out it’s required to include the nib files in your s.resources in your podspec. After adding the following to my spec, everything worked out just fine:

  s.resources = [ "HotMeter/classes/HotMeterView/HotMeterView.xib" ]

I’m not 100% sure that it has to be an array considering that the sample podspec file generated from the pod spec create command does in fact include a sample s.resource (singular) that points to a single string value, but I figured this way I’ll future-proof myself as well in case I add anything else later. Plus I think in the given context adding an extra array couldn’t hurt.

Side note

On a side note I also managed to break my pod completely at some point during the process, even after the podspec was fixed pod install kept failing with the message:

[!] Unable to satisfy the following requirements:

- `HotMeter (from `../HotMeter/`)` required by `Podfile`

The fix for this was to delete the lock file, Podfile.lock and run pod install to let CocoaPods reinstall the pods again.

References