Moving source files in Xcode 4.2 - ios

How can I move source files physically from one folder to another, and tell Xcode 4.2 the new path to those files?

See The Xcode hierarchy is a purely visual organization system. It has no effect on your actual file hierarchy. Xcode leaves the actual file system up to you.
Thus, you could, if you wanted to, have one folder on disk with all your source files, resources, etc. And then, in Xcode, you could have an elaborately organized hierarchy to display your source files.
To get your things done first Make a copy of files in desired directory. Then remove all those files from the Xcode Project. Then add the existing files from new directory and this way you can get Xcode to link to new directory.
Let me know if this helps.
Thanks

Thank you for your solution.
I created aproject X and later on, a view controller with 2 files XViewController.h and XViewController.m inside this project. Those files (by some mistake) were not created inside the physical+xcodevirtual project folder X, but in the root folder that contained X.
When I moved those files from inside Xcode to the X folder, the files seem that they moved there under X and they showed up there in the project hierarchy.
However, this way I ended up with 2 physical copies of them, on at the same level as X physical folder, and another under X.
After adding a property in the XViewController.h and build the project I noticed that my change did not work, and the Xcode reported the error that there was no such property inside the XViewController class and in the .h file.
Using "Show in finder" option I found the real file. Then I copied the updated physical files under X physical folder and delete the files that were in the same directory level as X. That way the Xcode project references to these files became red, implying that the virtual environment had lost the files. So, I completely deleted them from inside Xcode.
Then using File --> "Add Files to X..." menu option I re-connect the "good" physical files to my project X, and this messing problem was solved.

Related

How to properly export Xcode project?

I edited an existing project in Xcode and added a folder in it. In that folder, I placed 2 folders. And created a cocoa touch class in both of them. Now, when I look in to the directory of my project. My classes are not inside the folder, where they're expected.
It should be located in
Screens -> MyView -> View1 & View 2
But instead it is in the Screens folder
On Xcode, it is properly located but when I open the root folder of the project it isn't. How to fix this issue?
Xcode itself does not create any folders for you on your mac.
You have to create the folder structure manually on your mac. Then move the files to the new location.
Next delete them out of Xcode then drag and drop the files from your mac folder to the virtual folders within Xcode.
You will have to create folders manually in your project. Adding files to XCode group does not reflect to your project folder structure. Just remove reference of the existing files from your XCode and then move the required files into your desired folder and add them back to your XCode Project. Hope this will help you.

How to change the name of an Xcode file folder?

(XCODE 5)
I may be wrong in calling it a file folder, but what I'm referring to is the folder that contains all the files that is created after making a new project. In my case, I saved my project onto the desktop, and originally named it something completely different. Now I want to change its name, but before when I changed the name of the folder it didn't work when I tried to build and run my app. The other question I had was how to move it to another location because same thing happened when I moved the project from the desktop.
I was also wondering what A or M or a ? mean beside the files on the left hand panel (inside the project)
In terms of renaming the folder, you're generally fine renaming the top level folder, but it can get messy when renaming one of its one of the subfolders. If you rename the subfolders, side affects include (a) messing up links in the Xcode project; and (b) if you're using version control, losing the connection between the previous change history and the new file. But if you're talking about the top level folder under which everything for the project is included, I've never had problems renaming that.
In terms of the A/M designation, a A means that new file has been added to the project; M means that an existing file has been modified. You'll only see these when your project is under version control (which is a checkbox you can check when creating your project.)

Some files are located outside of "MyApp" directory in my iOS app - why?

I'm now developing my first iOS app, and I found that two of my classes (hence, four files) are located outside of my MyApp/.
So in my filesystem, here's the current situation:
My App
- ClassA.h
- ClassA.m
- ClassB.h
- ClassB.m
MyApp/
MyApp.xcodeproj/
MyAppTests/
Other than the two classes, all of my class files are located in MyApp subdirectory. The other resources, such as Core Data model file or images are saved in the same directory.
However, why are the two classes, and only the two classes, located in the outside of MyApp subdirectory? When I move those files to the supposedly correct location, those files are no more "valid" in Xcode with the color of the file name is converted to red.
So here's my question:
Why are those two files located there?
Do they have any issues if they remain to be located there?
Should I fix this issue and save it correctly? I think I haven't had any issues so far with the Simulator and the actual iPhone...
I use iOS 7 and Xcode 5.
•Why are those two files located there?
A: When you have created these files or imported from external directory, you may have not taken care of the group/folder these files are getting created/imported into. Hence they are inside the main app folder in the file system.
•Do they have any issues if they remain to be located there?
A: No, this is certainly not an issue in the correct functioning of your app, but it is always good to manage your files under groups/folders for better file structure and it is easier to find files when they become large in number.
•Should I fix this issue and save it correctly? I think I haven't had any issues so far with the Simulator and the actual iPhone...
A : This depends on you. If you like to keep your files in folders and like everythin arranged in some pattern, then yes you can divide the app into different folders. When you move the files in a folder, the reference of those in XCODE should change as well, and thats why you see those files in red in XCode. No worries. Just delete the files and add them again. Make sure you uncheck the option "Copy files under detsination group's folder".
Now, you may seem the option of creating New Groups inside XCode. But it is good to be aware that these groups do not create separate folders inside file system. These are just for Xcode refernce. So, a neat way is to create folders outside of XCode, and then import these folders(can be empty) in Xcode. Now when you add any file in these imported folders, even from XCode, it will go inside the correct folder in file system.
I am sorry I am not on my MAC right now, so cannot paste actual images, showing how to do it. Feel free to comment, if I have instead of solving the issue, have rather confused you more:D
You can put your source files wherever you want, as long as Xcode knows where to find them. You can leave them here, or organize it in another way, as you seem to be willing to do.
So, if you want to move these files in your Myapp/ subfolder, just move them there, and when Xcode complains it can't find them, highlight all those files in red in the navigator, and in the "File inspector" pane (right hand side of the window), click on the little Folder icon to browse to the new location. If you selected all files you don't need to do that 4 times, Xcode will find it out by itself.

Moving files around in XCode and IOS 7

I move some files into a subdirectory but now I get linking errors saying files can't be found. Where do I go (like a projects file) to tell XCODE where to look for the new files?
I tried removing everything and adding them back in but I still get missing files even though they are one directory in and added to the project.
Select a file in left panel, open inspector panel on the right and choose a path to file there.
Note: it's more efficient to do that if your files are organized into folders; that way, you only need to change the path to folder and the elements are relative to it.

move an xcode 4.5.1 project to different folder

I have created a rather large application in xcode and wish to move the files somewhere else on my computer.
Could this process be as simple as dragging the project folder to a different place in finder or will something mess up?
Moving the .xcodeproj files will not cause any issues as long as xcode is closed when you migrate the files and you delete the old files.
When xcode is next launched, if you browse and open the proj file from the new directory, all the references will be set to the correct destinations
on a side note it always pays to keep the old files in a .old folder when migrating projects to avoid issues.
As long as the files are kept in their respective folders, next time you run a build in xcode, the references to the new directory the proj file is in will be updated.
As another side note, i just tried to do this and it messed up for me. Typically, any references will switch over, but i had a linker error: ld. it was trying to link to an external library that was contained within the old folder. i had to go to build settings->search paths->library search paths and change that to the new folder location. that worked for me.

Resources