How do I rename a project in Xcode? - iphone

i have a finished application written with objective c and I would like to rename the file. how do i do that?

Recent versions of Xcode have a "Rename..." item in the Project menu.

Renaming a project has changed in Xcode 4+. (Kris Markel's answer above is for Xcode 3.2.x )
Follow these steps to rename your application in Xcode 4.0 or later:
In Xcode, select your target under "Targets" in the project editor, then choose View > Utilities > Show File Inspector.
Xcode opens the file inspector pane. Enter your application's new name in the Project Name field as shown in Figure 1, then hit the return key on your keyboard.
Xcode displays a project-rename dialog that contains all the items that can be renamed in your project. Leave your application selected in the dialog and deselect all other items as shown in Figure 2, then click Rename to perform the rename operation.
Source: iOS Developer Library Technical Q&A QA1625

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.

XCode doesn't recognise Core ML model files

I download Core ML model files from Apple's web page but my mac and XCode don't recognise them. Here is what I see when I add them to my project navigator:
What am I doing wrong?
I had this problem and noticed that XCode 9 Beta 4 has a bug in which every time you drag a mlmodel to your project it does not get added to the target even though you selected your target to add.
The solution is to click the file and tick the "Add to target" box located in the utilities tab. (XCode's right panel)

Settings bundle - New items not showing up in Xcode

I am a newbie to iOS Development. Learnt a chapter 2 days back about using settings bundle in my apps. The tutorial also showed me how to add new plist files and images into the settings bundle by ctrl+click opening the bundle in Finder.
But the newly added items do not show up in Xcode project organizer list. Is that how it works or do we have an alternative?
[Update at 1:53PM EST by Deepu]
Thank you guys for the replies. Actually I figured out something weird. When I added objects to the settings bundle from Finder, they did not initially show up on Xcode. I closed everything and then reopened Xcode and saw them in the bundle inside Xcode. So I guess the error was on my part expecting the objects to be added in Xcode as soon as I added them to the File system via Finder.
Sorry for the trouble and thanks for the advises.
It has to be there maybe inside any folder. When I add a file I usually add first a group (right click Add group) then there is a new folder so in the folder (example images) I right click and add a file.
It should be there, if not then right click on any folder/file in your xcode, tap on Show or Reveal in Finder, then it will take you to a place where all of your project files are placed, drag and drop from there into your project. It will not automatically pull into your project if you will add them in a folder on your disk. You will have to drag and drop into your project.
Let me know if you have any questions.
Reno Jones

Can't Open XIB in Xcode

I get this message from Xcode when I try to edit the xib for one of my apps.
_The document "ViewController_iPhone.xib" could not be opened. This version of Xcode does no support Auto Layout for iOS documents. Edit
this document with a newer version of Xcode.
I have Xcode version "4.4"
You may have this problem if the XIB file was originally created in Xcode version 4.5+ (current preview version as of now is 4.5). Auto Layout is a new feature that wasn't supported previously with older versions of Xcode.
Go to the developer portal and download 4.5 Preview Xcode and try that out.
Simple Solution:
Right click on .xib file -> open as "Source Code".
Find & delete object (some int/Hex) from xib source code.
Save File.
Again right click & open xib as "Interface Builder".
It will open your corrupt .xib file & u will not loss whole update in project.

How to change Xcode Project name

I have developed my app in Xcode for iPhone, in start I have just named it without secnec now I want to change my app name I have replace my old app name with new one as I have found the name in my app, but its still giving me one error...
Desktop/New name/old name_Prefix.pch: No such file or directory
when I have change oldname_prefix.pch with newname_prefix.pch ..
For Xcode 4 or later:
Open a project
Select Project Navigator
Highlight project name
Single click on project name
For Xcode 3:
Open a project > Menu > Project > Rename ...
There is no need to change the name of the project in order to change the display name of the application (which is what you see on the home screen of the iOS device, in iTunes, etc.). Simply change the "Bundle display name" in your info.plist from the default "${PRODUCT_NAME}" to whatever you want it to be. The name of your project is invisible to users, they only see the "Bundle display name."
click on you project in project explorer and again click on your project on right side and there you can see project name as shown in the figure
On the left side expand Targets
Double click on your target and then select build tab in the newly opened window
on the top right there is a search box. Type - "Product Name"
Now look below, under packaging section, you will see Product Name
Change it and clean rebuild, your new app name should be changed by now.
Goto
youname-Info.plist
Change Both
Bundle name and Bundle display name to your preferred file name.
Done.
For changing application name only (that will display along with app icon) in xcode 4 or later:
Click on your project file icon from Groups & Files panel, choose Target -> Build Settings -> Packaging -> Product Name.
Click on the row, a pop-up will come, type your new app name here.
For changing Project name only (that will display along with project icon) in xcode 4 or later:
Click on your project file icon from Groups & Files panel, choose Project(above targets) from right pane, just see at the far right pane(it will be visible only if you have enabled "Hide or show utilities").Look for project name.Edit it to new name you want to give your project.
Delete your app from simulator/device, clean and run.Changes should reflect.
That's it
ohho's answer is perfect:
For Xcode 4 or later:
Open a project
Select Project Navigator
Highlight project name
Single click on project name
BUT, if you only do this, once you try to debug on a new device, you will find an error:
file not found: /Users/someuser/Library/Developer/Xcode/DerivedData/OLDNAME-akbwbarcniqxytctbebckkelkbxs/Build/Products/Debug-iphonesimulator/OLDNAME.app/OLDNAME
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Then you need to do one more step:
Select target on the left panel
Choose the oldnameTests in Targets
Select the Build Settings Panel
Search for "TEST_HOST" and change the old value to the new.
Good Luck and Have Fun
Here is Apple's step by step visual guide to change name of Xcode project.
To change name of workspace just rename it.
in xcode 4.4, you have to click on the project at the top of the navigator (left panel). Then click twice on the target in the second column to highlight the target name. Then you can change the product name. You will also need to modify the archive name when you go to create an archive. To do this, you must edit the scheme, click on Release, and then change the archive name.
I am using xcode 4.3.1 and tried to change product name as Quakeboy said above in the bundle setting, but it led to reading error. I was stuck in this error for an hour and now it is working well. I simply made the product name blank then retype the older name that I had before. building succeeded again!
Note to anyone who like to change project name : you don't have to change the project file name the bundle display name will be display to users so just don't hang out with this issue too much. can be wasting time.
It creates an organizational nightmare to have project names that don't match the bundled name. But when I use the "click on project name and answer yes to let xcode rename all of the references" technique, all of the nested folders for the project on my hard drive still have the old project name. Why aren't they renamed to match?
If I change those folder names, I'm pretty sure it will mess up all of the project links. I am not going to take the chance, unless someone can suggest a way around this.
Select the project in the Project Navigator (Command+1) and open the File Inspector in the right sidebar (Command+option+1).
There, change the Project Name.
Xcode 3.2.5:
In top menu bar, Project>Rename...
I tried by changing the Project name in Project Navigator, but you need to follow through with the all the step outlined here!!!.
I did not follow the second step and this broke my app, had to rework a older version which took two days, see my SO post here.
I tried ohho's answer and it didn't work but found another solution. You can open your Info.plist file and go where it says' "Bundle Name" and change to your new name that will be shown in your launcher. I hope this wrks
Simple step
1.Select the project target left side on top of all folders and files
2.Single click on the project again it will allow you to change the name
3.type as u want the name of the project and the name of the app
4.Press enter. it will ask to change every where accept it
5.same procedure do on the folder as well all place the name will be changed. i did it today
Just in case this helps someone, I have a shell script (xcmv.sh) with the following:
#!/usr/bin/env bash
mv $1 $2
mv $1.xcodeproj $2.xcodeproj
mv $1.xcworkspace $2.xcworkspace
LC_ALL=C find ./ -type f -not -path "./.git*" -exec sed -i '' "s/${1}/${2}/g" {} +
I then drag this file into the project directory and do:
sh xcmv.sh Starter MyProject
This changes the project name, the workspace name, plus any and all references to the old name in the project files, code files, plist, and so on.
As the sample indicates, I often use it to rename one of my various "starter" projects to the desired project name.
Note the git directory (if it exists) is ignored.
This video shows a developer renaming an Xcode 6 project. First single-click the project name to change it, then make sure to also set the host application for your test build target.
https://www.youtube.com/watch?v=ZHr1vjkTxC0