niklassaers
niklassaers

Reputation: 8830

Resources in custom iOS frameworks

I have made an empty single-view application in Xcode 6 (FWTest) and added a Cocoa Touch Framework (FWTestKit) as a target and asked it to embed in FWTest. Then I add an image (photo.png) to the framework, that I expect to be in Frameworks/FWTestKit.framework/Versions/A/Resources/photo.png when I build & archive my app. However, I find it in Frameworks/FWTestKit.framework/photo.png

How can I make it at least be in a Resources folder? Preferably a versioned folder so I can ship different versions of my framework?

When I add this framework to another app, do I need to do anything special to make sure the resources are bundled along with it, so that when I reference a resource from within my framework I can be sure it'll be available also when used in another app?

Cheers

Nik

Upvotes: 5

Views: 1390

Answers (2)

ares777
ares777

Reputation: 3628

step1 If the desired structure is]![step2You should add your photo.png into separate folder (let's call it "gica" ). Then drag folder into project, check Copy items if needed and create folder reference. Then (important) in build phases, drag photo.png again in Copy Bundle Resources, keeping Copy items if needed and create folder references. After you compile you should have now desired folder structure [It is keeping gica/photo.png].enter image description here

Upvotes: 5

MadNik
MadNik

Reputation: 7793

I think you need to revise the architecture about versioning. Anyway if you still need to place the image inside the folder. Try creating a run script.

In your build phases instead of adding your images to copy bundle resource phase. You can create a shell script to copy your images to desired folder. Please note build phases are run in the order they placed. My point is you can customise xCode Build process through your own shell scripts.

Upvotes: 0

Related Questions