Deleted a file manually: How can I fix Xcode project file? - iphone

I'm developing an iOS 4 with latest iOS SDK and XCode 4.2.
I don't know how, but I have found that one of my ViewController.xib has been moved to en.lproj folder.
I've moved this file out of this folder, and added it again to project.
But now, when I compile I get a waring saying that I en.lproj/ViewController.xib is missing from working copy.
How can I fix this?

you may be having a soft link of en.lproj/ViewController.xib in project group . It will be red in color after building . You just delete them from the group.

Select your ViewController.xib file in Xcode's list of files & groups along the left side of your project window and then open up file inspector and that's where you can change the path.
Here is how I do it:
I hope this helps you out!

This is not a direct answer to your question, but I'd still say this.
Use something like git or svn to avoid such mistakes. The new XCode in fact gives an option for git while creating a new project.
If you are already using Code Revision Control System, just look for the commit that did this change and revert it. (I am using git language here)

Related

classes .m and .h not updated

kinda awkward asking this. But I cant seem to find the solution, because I dont know how/what to search in google. It goes something like this. In my project folder, whenever I click my Project.xcodeproj the latest code I have edited there was right or what I meant is when opened in XCODE it is updated.
Problem:
For example, when I try to unzip my latest project from the latest zipped project( for back-up purposes ) when I open the folder( back up ) then click for example View1Controller.m the codes in it arent updated the way they are in the XCODE though if I click the xcodeproj part. It is updated in the XCODE.
Hope someone could help me with this, and explain some good ways/solution for my prob. Thanks.
I assume that you are zipping old projects and saving them to avoid using git - I'm no git lover but for sure its a better solution.
The problem with trying to use Xcode to view old and new projects at the same time is (IMHO) is that Xcode seems to get confused about what file is in what project - if you have a new one and old one open.
open the old file in TextEdit, it should be exactly what you think it should be
in Xcode, have the current project open, look at some files. close the project, and open the older project. look at the files, they should be correct [if they are not, close and reopen Xcode between project openings, but I suspect this is not necessary]
if you really need to see the files from the old project while viewing the new ones, then in the Finder rename the file - put a "O" prefix on the file, then open that file (with the modified name) in Xcode
My experience is dated on this issue to older releases, but I do strongly recall having this kind of problem in the past.

Restore Project Settings in XCode

How can I restore Xcode project settings? I can't see few settings (like Targeted Device Family, iPhone OS Deployment Target, etc.) after I gave my Macbook to my friend. :(
I also saw that the info.plist file was not in the project, I recovered it via TimeMachine though, the Base SDK is also missing. :( She messed all things up, I don't know why she went in there. Anyways, is there any way to restore the settings?
Unfortunately, the snapshot that I have is also very old. :(
No way to restore them. You can set the base sdk on the project info screen.
Project > Edit Project Settings > Base SDK, Check the same for your Target.
Is this issue occurring for a specific project, or all projects? If you create a new project, what happens?
I forget the exact syntax, but different versions of XCode handle project files slightly differently. A new SDK (and version of XCode) couldn't read my project file right (same symptoms you explain).
In my case, there were 2 different SDK settings in the project file due to 2 separate versions of XCode editing the file (this could be very likely if you restored from backup and had upgraded SDKs in the interim).
Look for something like:
SDKROOT = iphoneos4.2;
Or really, just look around the text that contains the build settings (all of your build settings are stored in the file in flat text) -- you may see something related to SDKs where there are 2 lines very similar right next to each other. That'd probably be your problem. If you don't know which to delete, try both and then re-set the setting using the interface.
Of course in any case, you should back up your project file (project.pbxproj) before trying any of this.

Is there a way I can compare code in an old Xcode project with a new Xcode project?

I have a developer who has been working on an old Xcode project for me. Is there a simple way I can compare files in his new Xcode project to the ones in the new Xcode project to quickly see which changes he's done and how the old code has changed? He's be procrastinating and finally i have twisted his arm to send me the new Xcode project. He claims that the old code was rubbish, including the old coder too, so I'd like to see if he's actually done any changes to the old guy's project or is just plain and simple, 'a talker'.
Sure, use the "diff" command (from a terminal window).
If the two projects are in folders "old-project" and "new-project", respectively, you would do something like:
diff -r old-project new-project
The "-r" will recursively compare corresponding files in subdirectories.
ps. this should also be a wake-up call to you that's it's time to put your project into some kind of version control system (such as svn). If you had your project in source control, there would not be any question about exactly what had been changed, when, and by whom.
you can use FileMerge. it is under Developer/Applications/Utilities/FileMerge

XCode CoreData files not found/opening

I am using the Xcode 3.1.4 that means SDK 3.1.2
The problem is that I cannot open .xcdatamodel (Core Data) file and I don't even get the Data Model option in Design Menu bar.
When ever I double click and try to open the file,
XCode gives me an error saying that it cannot find the file at (my project's path).Perhaps it was moved or deleted? , but the file exists at the same path.
Please help me out as I haven't upgraded my system to Snow Leopard so cant use SDK 3.2
Regards
jAmi
I think definitely one thing you can check is to ctrl-click on your file, select get info, and see if the path name is in red. If it's in red, it doesn't hurt to click choose and relink it.
Hope this helps.
It's been a while since the question, but in case anyone searches for this: I have found that Clean or Clean All Targets will fix this issue.
Aggravating, but putting Cmd-Shift-K on your list of remembered shortcuts is worthwhile.

Build Error - missing required architecture i386 in file

I'm getting this error when building my iPhone application:
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library
/Frameworks/UIKit.framework/UIKit, missing required architecture i386 in file
It goes the same for all the frameworks in my app. It's very weird since this was not happening earlier.
This happens when you add a framework to your project and unintentionally copy the framework into your project directory.
The fix is to check your project directory (where you store your project on disk) for any iphone SDK *.Framework files and delete them.
Project will build fine afterwards.
I had this same problem, and the solution turned out to be an easy fix. Backup then open project.pbxproj (located inside your project file bundle) in TextMate or TextEdit and search for the section titled "/* Begin XCBuildConfiguration section */". Look for a key named FRAMEWORK_SEARCH_PATHS and delete it and it's contents (once per build configuration, so I removed it in two places). Here is an example of what I deleted:
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks\"",);
My project now build for both the iPhone device and the iPhoneSimulator.
What has happened here is that Xcode has mysteriously added a "Framework Search Paths" entry that points to a particular iPhone device SDK. For example, mine was recently set to:
$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks
This leads the compiler to find frameworks of the incorrect architecture. Removing any values under the "Framework Search Paths" key in your target's build settings will resolve the issue.
I just wanted to mention that in XCode if you go to "Edit Project Settings"
and find "Search Paths" There is a field for "Framework Search Paths". Updating this should fix the problem, without having to hack the project file!
Cheers!
Jesse
Check that you didn't copy the framework into your project when you added it. If you copied it, it can't find the original paths. To fix this problem. Delete the AVFoundation framework from your frameworks folder in your project, then add it again, but this time, make sure you don't have copy check marked.
This fixed it for me!
I fixed it in a different way.The reason why i was getting this error was that i added security.framework twice in my project.I was not able to see security framework in xcode ,i opened the project in finder and found this framework which i deleted and problem solved.
If your app is meant to run on the device, make sure you are not trying to run in it on the simulator. May sound obvious, but check anyway.
Though it is possible that something got deleted, it has been my experience that something gets screwed up in the project file. I have yet to pin down what that "something" is. I've had similar issues when the SDK installation is just fine. There are a couple of options.
First, add all of your files to a new project. This seems to usually work. Kind of a pain, though.
Second, you can right-click project in XCode/Get Info/Build/Library Search Paths. Add new paths similar to /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib. Add appropriate versions of that string for each version (2.2.1, etc) and platform (simulator or iPhoneOS). Perform a similar action for Framework Search Paths if frameworks are your problem.
Third, which is more work but more reliable, is to open project.pbxproj from within MyProject.xcodeproj (Textmate is good for this). Look for "/* Begin XCBuildConfiguration section */", then "LIBRARY_SEARCH_PATHS" and "FRAMEWORK_SEARCH_PATHS". Add or modify the paths as appropriate, and save the file.
In any case, a pain in the butt, and I'd sure like to pin-point the cause because I've had this happen a couple of times. Project builds fine, then just up and refuses to do so with what seems to be little reason.
"Edit Project Settings" and find "Search Paths" There is a field for "Framework Search Paths". delete all!!
It just happened here to me as well. Thanks to a great partner we found the answer. Your Xcode may be pointing to the simulator ..change it to a IOS device instead ..built smooth after ....
Run the file command on the framework from Terminal:
file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library /Frameworks/UIKit.framework/UIKit
You should get back a message telling you which architectures the UIKit binary is compatible with. If you don't see "i386" listed, then you've somehow managed to remove the i386 version of UIKit, which will mean that you can't build for the simulator.To fix that, you'll have to re-install the SDK.
If you get some other error, hopefully it'll help you figure out what the actual problem is.
I just want to let you know that In my case, I was having the same problem, I realized that I had an older Xcode folder called Xcode3.1.3 I just rename it because it was an older version and that did the magic for me.
Check your library search paths in your target settings. Sometimes goofy libraries get entered in there and this will give you a similar error.
You can remove all entries in this section.
I'd just experienced something slightly different, because I work on my own library (WM_GSRecognizerLib), but the error is the same.
What'd happen: due to some updates, the path targeting the lib to include (.a) was from the "Debug-iphoneos" folder (where it is generated). Compiling for Generic iOS Devices worked fine, but not for simulator, complaining for the missing i386 architecture.
What I did for this issue, is to also include the binaries from the "Debug-iphonesimulator" folder.
It can help for this topic, because the explanation is here: devices require binaries for arm64/armv7/armv7s, while simulator does need i386.
My solution was to set on simulator target debug YES, just look on git status to see the new line added as architecture only on .project. if you don't set this the build will run to all architectures and will show some missing architecture like i386 or other.
NOTE THAT obviously the main issue is to use some framework that implements some kind of specific architecture.
I too got the same error am using xcode version 4.0.2 so what i did was selected the xcode project file and from their i selected the Target option their i could see the app of my project so i clicked on it and went to the build settings option.
Their in the search option i typed Framework search path, and deleted all the settings and then clicked the build button and that worked for me just fine,
Thanks and Regards