nik nik - 1 year ago 101
Objective-C Question

iPhone Generic bundle for application resources

Have developed an iPhone app which has two different functionality and it using same images and string in some areas in both the project. Here I am using preprocessor macros which are differentiating it during compile time say for example project one and project two.

Here my question is is there any way to pass the images and string in generic way. I mean if I execute the application for project one means it should only take relevant app's images and string it should not bundled with another project i.e. project two's source.

Any idea and suggestion will be greatly appreciated.

sch sch
Answer Source

Have a look at the screenshot of a project that has two targets:

enter image description here

And at folder structure:

enter image description here

You can put shared assets in the Shared folder and add them to both targets like SharedImage.png in the example. For assets that has two different versions, you can put each version on the appropriate folder (Target A or Target B) and use the same name for both versions. For example, when adding the image MyImage.png to Target A, you simply have to check the box Target A like in the following screenshot:

enter image description here

Now, it is easy to use the correct asset for each target and without using preprocessor macros. For example, the following code will use the correct version of MyImage.png whether it is running in Target A or Target B

UIImage *image = [UIImage imageNamed:@"MyImage.png"];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download