How can add resources like images to source control under Xcode 4 - xcode

Xcode 4 does not automatically add images to the source control (git), also option to add files to source control is disabled in the context menu when I select an image.
Is there something I am doing wrong or will I need to add those files to the repository by some other means.
Thanks

It seems like only way to add those files is from command line via git then Xcode tracks them properly. And I just did that and it works.

Xcode 4 doesn't seem to add any files to the GIT at all with the project navigator "Add files to ..." command, this seems ridiculous.
To demonstrate the problem, simply create an iOS project of any type. Copy a folder of source code into main project folder and then right click the project and select Add Files to . No matter what you select when adding the folder (group/folder) Xcode doesn't add them to the git.
Creating new files within Xcode does add them to the git of course.
Help anyone?

Related

Couldn't load a Xcode project with pods [duplicate]

How do I rename a project in Xcode 5?
What steps do I need to take?
In the past this was always a very tricky manual process.
Well, the answer is very very very Apple simple in Xcode 5!
In the Project Navigator on the left side, click 2 x slowly and the Project file name will be editable.
Type the new name.
A sheet will appear with a warning and will list all the items Xcode 5 believes it should change.
You can probably trust it, but you should inspect it.
The list will include the info.plist and various files, but also all the relevant strings from nib/xib files like MainMenu menus.
Accept the changes and you will get the prompt to save a snapshot of the project.
Always make a snapshot when Xcode asks, it will be useful to restore if something does not work.
Change the project name:-
Click on the target in xcode, on the right in "Identify and Type" under name change the name and press the ENTER button on your keyboard.
A window will appear confirming the change and what it will change. Once you confirm it will make the changes.
Change the root folder name:-
Go to the project directory and rename the root folder,
Open the project and u will find all the file are missing, u need to add all the files of project again
Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor.
4>Search and replace any occurrence of the original folder name with the new folder name.
5>Save the file.
Change the Scheme name:-
rename .xscheme file
If your Project is static framework then make sure your header file has public target membership
I really recommend just opening the folder in a general editor such as Sublime Text, and doing a find/replace across the whole folder. The other methods I found were unstable, particularly when combined with .xcworkspace and cocoapods.
In Xcode 8.0, to rename your project, just go through the following instructions as described in Xcode help:
1- Select your project in the project navigator.
2- In the Identity and Type section of the File inspector, enter a new
name into the Name field.
3- Press Return.
A dialog is displayed, listing the items in your project that can be
renamed. The dialog includes a preview of how the items will appear
after the change.
4- To selectively rename items, disable the checkboxes for any items
you don’t want to rename. To rename only your app, leave the app
selected and deselect all other items.
5- Click Rename.
Source: http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f
Xcode 6 (beta 6 as of now) seems to be not very reliable with renaming projects. For me it didn't rename several of the files and groups. It also doesn't rename the physical folder the project is in. To rename my project to be sure that everything is clean I went the extra length to create a new project with the new name and copy over all the files. The assets are easy to copy but groups have to be recreated. The biggest issue with this however are CoreData data model files. Trying to simply copy this will result in a corrupt model file, even though everything looks like it is alright.
When you re-name the project name in XCode5 then info.plist entry removed from Targets --- > General ---> identity. You just need to mention it again.
In Xcode 7, renaming a project can still break your app. Make sure you backed it up before trying it.
Click on the project icon and find the project name in the inspector pane. If you change it there, Xcode will ask you if you want to rename related files. Might work. But if not, try this brute force approach:
Close Xcode
Using an advanced text editor like Sublime Text or Atom, open the
root folder. It will open the folder structure.
Perform a Global Search and Replace (it's probably cmd + shift + f), and
replace My Wrong App Name with New App. If your project name contained spaces, also search for My_Wrong_App_Name and replace
with
New_App. This changes all file contents.
Now you need to find all
the files inside the project with your old app name. Rename them
all, also the folders.
Important: Open the project file with
right click > Show Package Contents, and rename all files in there.
Reopen your Xcode project or workspace. Compile.
If you use Pods, you need to open the pods project as well and change the files in there.
Here is another great example which works well with xcode 5

How do I rename a project in Xcode 5?

How do I rename a project in Xcode 5?
What steps do I need to take?
In the past this was always a very tricky manual process.
Well, the answer is very very very Apple simple in Xcode 5!
In the Project Navigator on the left side, click 2 x slowly and the Project file name will be editable.
Type the new name.
A sheet will appear with a warning and will list all the items Xcode 5 believes it should change.
You can probably trust it, but you should inspect it.
The list will include the info.plist and various files, but also all the relevant strings from nib/xib files like MainMenu menus.
Accept the changes and you will get the prompt to save a snapshot of the project.
Always make a snapshot when Xcode asks, it will be useful to restore if something does not work.
Change the project name:-
Click on the target in xcode, on the right in "Identify and Type" under name change the name and press the ENTER button on your keyboard.
A window will appear confirming the change and what it will change. Once you confirm it will make the changes.
Change the root folder name:-
Go to the project directory and rename the root folder,
Open the project and u will find all the file are missing, u need to add all the files of project again
Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor.
4>Search and replace any occurrence of the original folder name with the new folder name.
5>Save the file.
Change the Scheme name:-
rename .xscheme file
If your Project is static framework then make sure your header file has public target membership
I really recommend just opening the folder in a general editor such as Sublime Text, and doing a find/replace across the whole folder. The other methods I found were unstable, particularly when combined with .xcworkspace and cocoapods.
In Xcode 8.0, to rename your project, just go through the following instructions as described in Xcode help:
1- Select your project in the project navigator.
2- In the Identity and Type section of the File inspector, enter a new
name into the Name field.
3- Press Return.
A dialog is displayed, listing the items in your project that can be
renamed. The dialog includes a preview of how the items will appear
after the change.
4- To selectively rename items, disable the checkboxes for any items
you don’t want to rename. To rename only your app, leave the app
selected and deselect all other items.
5- Click Rename.
Source: http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f
Xcode 6 (beta 6 as of now) seems to be not very reliable with renaming projects. For me it didn't rename several of the files and groups. It also doesn't rename the physical folder the project is in. To rename my project to be sure that everything is clean I went the extra length to create a new project with the new name and copy over all the files. The assets are easy to copy but groups have to be recreated. The biggest issue with this however are CoreData data model files. Trying to simply copy this will result in a corrupt model file, even though everything looks like it is alright.
When you re-name the project name in XCode5 then info.plist entry removed from Targets --- > General ---> identity. You just need to mention it again.
In Xcode 7, renaming a project can still break your app. Make sure you backed it up before trying it.
Click on the project icon and find the project name in the inspector pane. If you change it there, Xcode will ask you if you want to rename related files. Might work. But if not, try this brute force approach:
Close Xcode
Using an advanced text editor like Sublime Text or Atom, open the
root folder. It will open the folder structure.
Perform a Global Search and Replace (it's probably cmd + shift + f), and
replace My Wrong App Name with New App. If your project name contained spaces, also search for My_Wrong_App_Name and replace
with
New_App. This changes all file contents.
Now you need to find all
the files inside the project with your old app name. Rename them
all, also the folders.
Important: Open the project file with
right click > Show Package Contents, and rename all files in there.
Reopen your Xcode project or workspace. Compile.
If you use Pods, you need to open the pods project as well and change the files in there.
Here is another great example which works well with xcode 5

Duplicate and rename Xcode project & associated folders [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I would like to be able to duplicate an entire Xcode project, rename the project and the associated files without Xcode going mental, and without having to manually re-import all files to the project.
This answer is the culmination of various other StackOverflow posts and tutorials around the internet brought into one place for my future reference, and to help anyone else who may be facing the same issue. All credit is given for other answers at the end.
Duplicating an Xcode Project
In the Finder, duplicate the project folder to the desired location of your new project. Do not rename the .xcodeproj file name or any associated folders at this stage.
In Xcode, rename the project. Select your project from the navigator pane (left pane). In the Utilities pane (right pane) rename your project, Accept the changes Xcode proposes.
In Xcode, rename the schemes in "Manage Schemes", also rename any targets you may have.
If you're not using the default Bundle Identifier which contains the current PRODUCT_NAME at the end (so will update automatically), then change your Bundle Identifier to the new one you will be using for your duplicated project.
Renaming the source folder
So after following the above steps you should have a duplicated and renamed Xcode project that should build and compile successfully, however your source code folder will still be named as it was in the original project. This doesn't cause any compiler issues, but it's not the clearest file structure for people to navigate in SCM, etc. To rename this folder without breaking all your file links, follow these steps:
In the Finder, rename the source folder. This will break your project, because Xcode won't automatically detect the changes. All of your Xcode file listings will lose their links with the actual files, so will all turn red. Note: You may have to do Step 2 first, then come back to this step.
In Xcode, click on the virtual folder which you renamed (this will likely be right at the top, just under your actual .xcodeproject) Rename this to match the name in the Finder, this won't fix anything and strictly isn't a required step but it's nice to have the file names matching.
In Xcode, Select the folder you just renamed in the navigation pane. Then in the Utilities pane (far right) click the icon that looks like dark grey folder, just underneath the 'Location' drop down menu. From here, navigate to your renamed folder in the finder and click 'Choose'. This will automagically re-associate all your files, and they should no longer appear red within the Xcode navigation pane.
In your project / targets build settings, search for the old folder name and manually rename any occurrences you find. Normally there is one for the prefix.pch and one for the Info.plist, but there may be more.
If you are using any third party libraries (Testflight/Hockeyapp/etc) you will also need to search for 'Library Search Paths' and rename any occurrences of the old file name here too.
Repeat this process for any unit test source code folders your project may contain, the process is identical.
This should allow you to duplicate & rename an Xcode project and all associated files without having to manually edit any Xcode files, and risk messing things up.
Credits
Many thanks is given to Nick Lockwood, and Pauly Glott for providing the separate answers to this problem.
Duplicating an Xcode 4 Project
Renaming xcode 4 project and the actual folder
I'm posting this since I have always been struggling when renaming a project in XCode.
Renaming the project is good and simple but this doesn't rename the source folder. Here is a step by step of what I have done that worked great in Xcode 4 and 5 thanks to the links below.
REF links:
Rename Project.
Rename Source Folder and other files.
1- Backup your project.
If you are using git, commit any changes, make a copy of the entire project folder and backup in time machine before making any changes (this step is not required but I highly recommended).
2- Open your project.
3- Slow double click or hit enter on the Project name (blue top icon) and rename it to whatever you like.
NOTE: After you rename the project and press ‘enter’ it will suggest to automatically change all project-name-related entries and
will allow you to de-select some of them if you want. Select all of
them and click ok.
4- Rename the Scheme
a) Click the menu right next to the stop button and select Manage Schemes.
b) Single-slow-click or hit enter on the old name scheme and rename it to whatever you like.
c) Click ok.
5 - Build and run to make sure it works.
NOTES: At this point all of the important project files should be renamed except the comments in the classes created when the project
was created nor the source folder. Next we will rename the folder in
the file system.
6- Close the project.
7- Rename the main and the source folder.
8- Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor.
9- Search and replace any occurrence of the original folder name with the new folder name.
10- Save the file.
11- Open XCode project, test it.
12- Done.
EDIT 10/11/19:
There is a tool to rename projects in Xcode I haven't tried it enough to comment on it.
https://github.com/appculture/xcode-project-renamer
As of XCode 7 this has become much easier.
Apple has documented the process on their site:
https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/RenamingaProject/RenamingaProject.html
Update: XCode 8 link:
http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f
I am using this script after I rename my iOS Project. It helps to change the directories name and make the names in sync.
http://github.com/ytbryan/rename
NOTE: you will need to manually change the scheme's name.
I'm using simple BASH script for renaming.
Usage: ./rename.sh oldName newName
#!/bin/sh
OLDNAME=$1
NEWNAME=$2
export LC_CTYPE=C
export LANG=C
find . -type f ! -path ".*/.*" -exec sed -i '' -e "s/${OLDNAME}/${NEWNAME}/g" {} +
mv "${OLDNAME}.xcodeproj" "${NEWNAME}.xcodeproj"
mv "${OLDNAME}" "${NEWNAME}"
Notes:
This script will ignore all files like .git and .DS_Store
Will not work if old name/new name contains spaces
May not work if you use pods (not tested)
Scheme name will not be changed (anyway project runs and compiles normally)
In the example code for the book "Instant OpenCV for iOS" I have found a bash script that copies a project from a folder to another.
Doing a little research I've found a blog post from what seems to be the original author of the script: http://mohrt.blogspot.it/2009/01/renaming-xcode-project-from-command.html, where you can download the script. I gave it a try and running it from terminal like this
sh renameXcodeProject.sh <name-of-existing-folder> <name-of-folder-to-create>
works fine.
Additional info can be found opening the file with a text editor. Hope that helps
I using Xcode 6+ and I just do:
Copy all files in project folders to new Folders (with new name).
Open *.xcodeproj or *.xcworkspace
Change name of Project.
Click on schema and delete current chema and add new one.
Here is done, but name of window Xcode and *.xcodeproj or *.xcworkspace still <old-name>. Then I do:
pop install
Open <new name>.xcworkspace
One more thing to try!
When I copied all of my files, opened the project, and renamed it, everything changed to my new project name except for the test target! I got a linker error that said I was missing a file called "myOldProjectname.app". Here's what fixed it:
Click on your project settings and select your test target
Click on build settings and search for "test host"
Check those 2 file paths. Chances are that those 2 paths are still pointing at your old project name.
Hope that helps!
For anybody else having issues with storyboard crashes after copying your project, head over to Main.storyboard under Identity Inspector.
Next, check that your current module is the correct renamed module and not the old one.

How to refresh Project Navigator content in Xcode?

I'm not able to refresh file list in Project Navigator. There is no refresh button, and I don't think restarting Xcode should be the solution.
How do you see files that you add externally? I'm on Mac.
How do you see files that you add externally?
Files cannot be added externally. Dumping a source file into the project directory does not add it to the project. To add a file you must add it to the project from within Xcode.
If you have a bunch of files that you need to add then in the Add File dialog you can just select all the files you want at once and add them, without having to repeatedly open the Add File dialog. Just use control clicking to select multiple files.
Close and reopen the project, if necessary.
This may be required if you are using folder references (as one example). In that case, touching the directory might work to refresh what Xcode displays.
For a single file, you can open the external file in Xcode and cmd+s to save it, it will be refreshed in Xcode.
Also, for the quick way you can just chose the external folder in Xcode and cmd+s, it will refresh all your external file in this folder.
File > Add files to "Runner" 👍
I don't think you can refresh the Project navigator to detect files that have been modified outside of Xcode, and that instead you need to manually add or delete files from the Project navigator with "right-click" / two-finger tap.
Some other solutions suggested:
File > Add Files to "Runner"... but that doesn't delete files
Open and close Xcode, but that's not practical. It also did not work for me.
Use cmd+s, but Xcode does not detect files which need to be saved. And so, that also did not work for me.
You can just press "Command + B", for refresh your project in xcode

want to use Xcode 4 for everything, how to add folder in project navigator?

I'd like to move my web dev editing to Xcode 4 (currently using textmate). I have a couple of simple questions that are clearly a lack of experience on my end.
In Xcode's Project Navigator, how do I add a folder to the shown directory tree? Currently, I add via terminal and do File -> Add Files
Is there any way to tell Xcode to see the file system as the file system and not as references?
a less likely thing:
Is there any way to bring up a console within the context of a folder in project navigator (would like to be able to run grep again small portion or something)?
thx
I can answer the first question. Adding a folder of files to a project is the same as adding individual files. Choose File > Add Files in Xcode. When you add a folder of files to a project, you should see something like the following screenshot:
Create groups if you need to access the files in Xcode, such as adding a folder of source code files. Create folder references if you don't need to access the files in Xcode, such as adding a folder of audio files.
You can also add folders to the project navigator by selecting a file or folder in the project navigator, right-clicking, and choosing New Group.
As far as I know, Xcode won't mirror the filesystem as an Xcode tree (anyone correct me id I'm wrong). Wanting to have an identical structure is quite some work. I use to first place the files hierarchically in the file-system, then I mimic the same structure in Xcode.
This requires some attention since Xcode 4.1 not always writes new classes to the place you told him to - they may prefer to land in the highest level of the Xcode project.
I had similar thoughts and started a thread, might be helpful for further reading
Your second question: sorry, can't help you there.

Resources