I have a product with two targets, one for iPhone and the other for iPad. I will build two separate applications, not universal.
As I will have to have two icon.png files for the application's icon, as they differ in size, as I see I will have to have two info.plist files. right?
I have created two copies of the info.plist file, named iphone-info.plist and ipad-info.plist. I have right clicked each one and assigned them to a specific target.
Now, when I compile I see this error:
Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'iPhone-Info.plist'.
If I remove the target assignment from both info files, the error vanishes.
here are the questions I have:
If I cannot set a target for info.plist, how each target knows which info.plist to use?
Is there another way to make each target have its own icon without using two plists?
thanks for any help.
If you get info on a target, click the "Build" tab, and type "plist" into the search box, you will see that the Info.plist file it expects to build that target with is listed in the Build settings. Change that to point to the file name of each plist file you want for each target.
Setting the target for each plist only adds it to the target build like any other file - to actually tell the app to use a particular plist file as "THE" plist file with relevant info, you also need to set it in the target settings.
Related
Has anyone figured out how to add/edit values in the Info.plist of Xcode 13 yet? I see they moved the Info.plist from the navigator pane... but although I can find it, I'm not sure how to edit it.
It's a "feature."
You don't need it anymore. From the Release Notes:
Projects created from several templates no longer require configuration files such as entitlements and Info.plist files. Configure common fields in the target’s Info tab, and build settings in the project editor. These files are added to the project when additional fields are used. (68254857)
So, instead of inside Info.plist, edit properties like NSCameraUsageDescription here:
Project -> Targets -> Info -> Custom iOS Target Properties
The first time you add/edit, Xcode will automatically generate a new Info.plist file that’s kind of synced1 with Custom iOS Target Properties. Xcode will later merge them for you.
[1]: They’re not fully synced. Some properties like NSCameraUsageDescription will only appear in Custom iOS Target Properties, while Application requires iPhone environment will appear in both. I have no idea how Xcode determines this.
Want Info.plist back, completely?
You might want all of your app's properties in one place. Or maybe you don't trust Xcode with the merging. I spoke with an Apple engineer at WWDC21 about this... here's how to get the classic Info.plist back.
Create a new "Property List" file (File -> New -> File)
Name it Info.plist
Copy and paste the existing values from Project -> Targets -> Info -> Custom iOS Target Properties to Info.plist.
Copy
Paste
Note: Currently you can only select and copy 1 row at a time. If you want to save some time, here are the default contents in XML format. To use this, right-click Info.plist -> Open As -> Source Code, then paste.
Copy the path to Info.plist in the attributes inspector.
Paste the path here:
Project -> Targets -> Build Settings -> Info.plist File
Set Generate Info.plist File to No
Last step. Remove Info.plist from Copy Bundle Resources (select, then press the - button).
Project -> Targets -> Build Phases -> Copy Bundle Resources
Yep, that was a lot. But whether you want classic Info.plist or not is up to you — both are fine and won't change your app.
Xcode 13.3.1, macOS Monterey(12.0.1)
Here is the most simple solution which work for both swiftUI and Storyboard projects, if you are not able to find info.plist and want to add target properties like Privacy - Camera Usage Description and things like we can add in older Xcode version. Here is the solution...
***> Select target of you project on top of the files click on Info on
> top of the right side, now you can see "Custom iOS properties" like
> info.plist, do whatever you want.***
Target > Info
see the image below for reference
Here is a link to a raywenderlich tutorial: https://www.raywenderlich.com/19611194-multiplatform-app-tutorial-swiftui-and-xcode-12
The sample projects uses Xcode 12.0-compatible (objectVersion = 54) project format, created with the Multi Platform app template. I borrowed the plists from this project. Until the sample project is revised, it's nice to have a reference project (structure) for comparison.
This also applies to Xcode 14. To be brief, a few pieces of information about this change:
There is a good write up of the issue here:
https://useyourloaf.com/blog/xcode-13-missing-info.plist/
There is a good YouTube video (found in this page above):
https://youtu.be/mml9ZI81VKA
This issue applies to SwiftUI projects not Storyboard. Once you make
a change to the "standard" info settings, Xcode actually
automatically creates an info.plist file in your project navigator. You can then add more custom settings in the info.plist file.
I've reorganized almost all the files of my project in the physical directory structure so that they are all in one physical directory. But, I can't seem to move the Prefix.pch or Info.Plist files without problems.
My method of moving the other files was to
(1) delete their references in Xcode,
(2) physically move them with Finder to their new physical directory and
(3) in Xcode to add them back into the project.
Are there settings somewhere in my project that have specific knowledge of the physical locations of these two files that I have to update as well?
There are build settings called Prefix header and Info.plist File. You have to change the path to the new path for these settings also.
And to add on, you don't have to delete the reference and add again. After moving the file , you can click on the Xcode reference of the file. Then in the file inspector there is a small rectangle box near the 'location' setting. If you click on this you can specify where the file actually exists.
I want to do the same with you. You can do it like what you want. But after that you need to change the "Build Setting" for the pch and plist file.
I want to create a target with different bundle id for test environment. I tried using the "Duplicate" function to clone a target and change the bundle id and found that the orignal one was changed too. Thanks for any tips!
================== Update =====================
Solve the link error after duplicates the target, it is a xcode bug. The quote character " is changed to \" in search paths(Building setting of the target).
see detail: http://flakasoft.com/developer-tips/xcode-4-bug-duplicating-a-target-results-in-link-error-due-to-missing-paths/
Double check you have the new duplicate target selected when you modify the Bundle Identifier setting on the Info Tab. I just tried this and it worked fine.
So the bundle identifier is on the info tab, which is actually just a view of the info.pList associated with the target.
To change the info.pList on that target, you will need to make a copy of the pList file (newtarget-info.pList), go into the Build Settings tab for the target, scroll down to the Packaging segment and modify the Info.pList File setting to point to your new file.
Then when you click on the info tab you will get the settings from your newtarget-info.pList file.
Figure it out.In XCode4, after duplicate the target, the info.plist file need to be duplicated too.
1. Copy the orignal info.plist file, usually "{APP Name}-Info.plist"
2. Change the setting: "Build Settings"->"Info.plist Files"
When I run the Application then warning display below,
Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'UserDefinedLocalization-Info.plist'.
I had this issue after I rearranged the underlying file structure of my project. Xcode4 has moved things around though and most online help to this problem is Xcode 3 specific, so this is how you solve this in Xcode 4:
Click the project icon in the Project Navigator (the blue root icon)
In your main pane menu you should be able to choose between your project or targets, select the target
Select "Build Phases" in the top menu
Open the "Copy bundle resources" item
Remove your plist file from there (your plist file should not be copied as a part of the bundle)
In xcode, right click the UserDefinedLocalization-Info.plist file, select Get Info. Go to the Targets tab and remove the checkmark in front of your target.
The info.plist is a special file and must be treated in a special way. It's not allowed to add it to the app in the normal way.
I have a settings bundle in an iPhone app which has several subtle variant targets.
The problem is I need to customise some strings in each settings bundle to make them appropriate for each target. It appears that if the Settings bundle is named anything other than Settings.bundle it won't pick up the bundle (understandable, can I specify in a plist somewhere the alternate name?).
If I try and put them in different folders and call them the same thing Xcode gets horribly confused and lets you edit "2 files" that are actually the same single source.
I see no problem. For every target, create a specific folder with files for this target. Now create a group in Xcode for every of those folders and drag each of the new Settings.bundle directories to the corresponding group. When adding the bundles to the project, make sure that every bundle is only built (included) for its target by checking the appropriate box.
AFter you do what MrMage said which is correct.. i had an issue where the Root.plist would not show up under the Settings.Bundle for a specific target.
You have to let xcode know what the setting.bundle file is... click on the settings.bundle that wont show the Root.plist, then go to file inspector
Alter the file Type drop down to be applicationBundle ... now the Root.plist shows up.