Search code examples
iosswiftcocoapods

How to specify a cocoa pod asset target


I have created a cocoa pod framework that includes some image assets. These assets are included in the pod spec and I can see the image when I inspect the framework, however I'm unable to access it from my app. When I inspect the assets in the "Development Pods" section I noticed that the target is a bundle called Zapic-Zapic instead of the target Zapic. If I change the target membership to just "Zapic" everything works as expected and I can access the image via the bundle. How do I change the target in my framework so that if I don't need to manually change the target?

enter image description here


Solution

  • After spending hours trying to figure this out i discovered this was being put in a separate bundle because my spec file was defining s.resource_bundles = { 'Zapic' => 'Zapic/ZapicAssets.xcassets'}. This creates a new bundle with just the resources, hence the Zapic-Zapic bundle. Once I changed it to s.resource = 'Zapic/ZapicAssets.xcassets' everything works as expected. It looks like the CocoaPod docs need to be updated now that dynamic frameworks are supported. I discovered this via an open issue on CocoaPods Github. Hopefully this will save someone else from dealing with the same pain I just went through.