I am a newbie. I bumped into a few problems in the course of developing iOS swift app. with your explanation, I will learn how to use the best practices.
here my questions I wanted to know the reasons and use the simple ways to solve:
I accidentally deleted the main.storyboard file. However, I got back up. I thought to start fresh. I delete the project and created a new one with exact same name. I deleted the new main storyboard file in it and copy the old main story file as well as the other files into Top level folder (App folder). I rebuilt it and it run.
here my questions:
I see other samples, I notice the Main storyboard file is inside Base.lproj folder. But in my project, the main storyboard file is not in it when open in Xcode v7.3. I open the App Folder in DeskTop, I dont see main storyboard file in Base.lproj. But this file is in App Folder. is this ok?
I run it a couple of time, I don't see Tests folder like ProjectNameTests as well. Is this ok?
If I manually move the main storyboard file into Base.lproj, it will have compiling issue.
is this way of restoring files ok? Copy the old files into the Top level folder ok?
What will be the correct ways to handle if I have backup for project.
Apprciate your help on this matter.
Thanks
Related
I recently got a new hard drive and reinstalled Mac OS X on it. I copied my entire folder with all my Xcode projects over. However when I tried booting up one by clicking the project file, Xcode opens up with only the project file present. All of the files with actual code on them are not appearing.
I tried to add files but even that would leave most of the files with code on them greyed out in the finder.
Question, what is the proper way of transferring these projects specifically in Xcode 7? I have not been able to find anything concrete.
So, the only way I know of to do this efficiently is to load up the project file XML in your favorite editor and go manually fixup the paths. I don't recommend this.
Unfortunately, the way to do it through the UI is for each file, you need to open the Utilities Bar on the right, select the file, then update the path via the little folder icon in the Identity and Type section. Here's an illustration:
Then repeat for every file in your project. Sorry.
i had this same issue i mean you could always manually transfer code through word documents or notes, but for me i had copied the entire project folder and the document transferred just fine just make sure you transfer all of the files with it and not just the one file for the project itself
delete the xcode application and reinstall it from the Mac App Store.
I'm trying to localize an iOS app. According to all the tutorials, one of the first steps is to add localizations to the info pane of the project editor. When I get there, "use base internationalization" isn't checked by default. When I click it, the window "choose files and reference language..." comes up as expected, but it doesn't list any files--i.e. there are no choices for files to localize.
The app builds/runs fine. My storyboard is named "main.storyboard" and is in the project's main folder, so I'm not sure why xCode wouldn't recognize the file.
Of note, the project has gone through a re-naming, and I've been through a couple abortive attempts to localize after adding a language without the base, with the idea of adding the base later. But it looks like that takes me off track, and I had to undo those attempts; in the process, I manually deleted the .lproj folders that had been created.
Any ideas on what the problem is?
Important: Before you do any actions, keep backup of your project folder.
When you select use base internationalization, Xcode will look for User Interface files (Storyboard, Xibs) inside any *.lproj folders in your project. But in your case it won't find any *.lproj folder.
Steps to fix:
Create a "en.lproj" folder next to the storyboard using the Finder.
Then move one UI file like the main.storyboard (or other UI file) into the new folder.
On Xcode, relocate the storyboard file. One way to do it is to remove the old reference to the storyboard file. (will be in red) and re-add it to Xcode.
Now you will see that this file has "English" localization selected.
Retry now the 'use base internationalization' button and it should suggest you to move the main.storyboard to the Base.lproj which it will create for you.
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.
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.
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.