How to duplicate a project target in XCode4 - iphone

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"

Related

Where is Info.plist in Xcode 13? (missing, not inside project navigator)

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.

Error : Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'UserDefinedLocalization-Info.plist'

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.

How can I change the name of my iOS project?

How can I change a name of my project in the Xcode?
Newer Versions of Xcode
According to the Xcode documentation says that you can select your project in the lefthand panel and then open the properties inspector. By editing the project name, you'll be prompted to renamed targets etc.
Original Answer
I'm not sure exactly what you are asking, so I've given two parts to my answer.
To change the display name of your project, (under the icon on the home screen) you should edit your Info.plist file in the Resources group of your project. Change the Bundle Display Name key. Make sure that you save the plist file and that you've deleted the old app from the simulator. Then, clean your build and then you can build it again to the simulator.
To change the name of your project, target and executable, click on Project -> Rename... in Xcode.
It's simple. Just press enter on name of project. Rename your project as desired. This will prompt changes to be done in entire Project. Click on Rename.
Ap iOS app under construction has at least 6 "names". They can all be different and can be set in different places.
Project name.
Target name.
Product name (which will become the .app bundle file name, should have no spaces).
Bundle display name (in the info.plist, displayed under the icon, spaces allowed).
Bundle ID suffix.
App name you give iTunes Connect.
Depending on what you change, you may need to delete the app from your device/simulator, and reinstall/build-and-run, to quickly see the changes.
Ah, I figured it out already. You need to change the active target.
If you want to change Project Name, Target name, -Info.plist name & -Prefix.pch name then,
- Select Project in Xcode (.xcodeproj file)
- Selecte file inspector
- In identity section change project name which u want to update & press enter
- After scanning whole project it will ask to change the file names i.e target, plist & pch file
- Select check boxes as per your need
In Xcode try the Project | Rename menu command.
See here.
1) Expand the "Resources" folder
2) Click on the "yourappname-info.plist"
3) Expand the "Information Property List"
4) You can change the "Bundle Display Name" to anything you want to display on the iPhone Home Screen.
if only change display name under app icon in device main screen you just need change "Bundle display name" key of target at tab info.
#Mosche This question should be updated for XCode 4.
Seems one has to use sed in .xcodeproj directory:
find . -type f -exec sed -i -e 's/OldProjectName/NewProjectName/g' {} \;

iPhone & iPad - two icons and two plists?

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.

Can an Xcode project with multiple targets have different Settings.bundle's for each target?

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.