Image path for icons and launching images in the info plist

I would like to add a few different resources. Folders contain different application icons in one project.

then configure 5 different applications in the target projects. For each of them I created a different info.plist. How can I specify different icon files and run image files for each application?

I would have 5 different folders containing icon images, e.g. app1 / icon.png app2 / icon.png

I tried adding the path to plist, but it seems that it cannot get the files.

if I tried to add icon files in the "Goals and Summary" tab, it just copies them to the root folder and overwrites the previous ones.

I can quickly fix it by adding a prefix to the images, for example app1_icon.png, app2_icon.png

I am sure there is a better way to do this.

+4
source share
2 answers

How to add a separate icon and other files to several iOS TARGET applications in one Xcode project


So, you have several iOS apps that share a common code base in Xcode. Perhaps you are creating Lite / Pro, Free / Paid, or unique versions of similar applications. You already understood how to duplicate TARGETS, and you hoped to understand how to specify separate .plist files for each of them. You also figured out how to use the compiler directives (i.e. #define MACROS) specified in Build Options> Preprocessor Macros to enable and disable slightly different behavior in various target applications.

Now you are trying to specify icon files for each goal and run into difficulties . You will have the same problems if you try to use different "Default" launch images or other resources in which you want each of the targets to use different image resource files with the same set of file names.

Here is what you need to do:

  • Create a directory for each of your goals, such as "App-A" and "App-B", into which you can place identically named sets of files consisting of icons and whatever.

  • Make Xcode groups in the project hierarchy with the same names as the names of the various target directories. This is not required, but makes my life easier, as you will see in step 9.

  • Add your badges and other images to these groups. Yes, they can (and should) have the same name from Target to Target. For example, you can have "icon-57.png" in both applications and applications-B.
    Hint. Before adding files to each group, install Xcode to create the Target associated with that group. For example, if you intend to add an image to application-B, in the upper left corner of the Xcode interface, next to the "Run" and "Stop" buttons, select "App-B> My iPhone" in the options menu. This will associate your membership with the image with the correct Target and help you in the next steps. This tip is not required.

  • Now for the important part, as suggested in the comment above @rckoenes. You must set a target membership for each of the files you added. Click on each target, select "Generate Phases" and crush "Copy Package Resources". You must add images suitable for this target and delete the images used by another object or targets. If you followed the “prompt” in the previous step, it may already be configured correctly for you. However, in the next steps, this list is likely to be corrupted, and you will have to go back here and configure it again.

  • Now you have finished the common resource images that are used in all applications. You may have used this method for an image or button in your project, which should look different in each target. Now it will be so.

  • The default icons and background images * are different stories because of the Summary Goal panel, which allows you to fill these resources with drag and drop. The following steps will help you with this.

  • For each of your goals, drag and drop the image files into the image holders on the Summary screen. Of course, they must be the right size. Xcode will ask for your permission to copy these files to the root directory of your project. Allow this, you will delete them later. During subsequent passes, Xcode will ask for permission to overwrite the files already in the root directory. Again, allow this.

  • In Xcode, delete all newly copied images and startup image files that appeared in the root of your project. Allow Xcode to move them to the trash.

  • Finally, all that creating, moving, and copying files can lead to chaos with your targeted membership. Return to the instructions above in step 4 and clear all your memberships. You can easily display images included in one target from objects of the wrong target, because the path is displayed after the file name. This is just one of the reasons we should be careful when creating directories and groups with the appropriate target names, as recommended in steps 1 and 2.

Each of your applications will now display the correct application icon and startup background image.

If your application was previously installed without an application icon or an incorrect icon, you may need to uninstall the application and reinstall it to see the new icon.


The following illustration can help visualize several goals:
Targets

+2
source

Including images on target.

So app1 includes app1/icon.png , but not others, and app2 includes app2/icon.png .

0
source

Source: https://habr.com/ru/post/1494694/


All Articles