Reputation: 2329
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.
Upvotes: 0
Views: 317
Reputation: 27506
Have a look at the screenshot of a project that has two targets:
And at folder structure:
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:
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"];
Upvotes: 1