Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 549
Daniel S Avatar asked Jul 10 '17 15:07

Daniel S


People also ask

How do I specify pod version?

<Specifying pod versions Later on in the project you may want to freeze to a specific version of a Pod, in which case you can specify that version number. Besides no version, or a specific one, it is also possible to use logical operators: '> 0.1' Any version higher than 0.1. '>= 0.1' Version 0.1 and any higher version.

How does cocoa pod work?

Cocoapods uses workspace to automate the build process and manage implicit dependencies. Cocoapods setup all necessary info into your consumer project(like Search pats, etc). When you build the consumer project Xcode pull pods and assemble all together.

How do I create a Podfile lock?

Podfile. lock is used to make sure that every members of the team has the same versions of pods installed on the project. This file is generated after you run the command: pod install. It gets updated when you run pod install or pod update.

How do I add CocoaPods to my path?

To install the pods, do one of the following: Place the caret at the code line where you add the pod, press ⌥ ⏎ , select Install, and press ⏎ . Click Install pods in the top-left corner of the editor window. From the main menu, select Tools | CocoaPods | Install.


2 Answers

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.

like image 139
Daniel S Avatar answered Sep 30 '22 17:09

Daniel S


Great Daniel, Above answer is correct:)

Earlier we had to manually select the Pod target then clean and build but start facing really issue when integrating CI. I spent hours to find out why its creating another target for resoruce_bundle but not for resources (contains custom font). Finally it worked now.

 sp.source_files  = "POD_PATH/**/*.{swift,xib}","POD_PATH/Font/open-sans/*.{ttf,txt,xib}"

 sp.resources = 'POD_PATH/Assets.xcassets'
like image 35
Pandey_Laxman Avatar answered Sep 30 '22 15:09

Pandey_Laxman