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

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

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.

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

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)

Use LLVM compiler by default for all Xcode projects?

I really enjoy switching from gcc to LLVM compiler, but do I have to switch manually every time I start a new project, or is there any way to make LLVM the default compiler?
I'm talking about xcode 3.
Thanks.
To accomplish this you will have to modify the project template within the Developer directory.
Navigate to where your templates are (probably something like: /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/
Once you're there, you can select the project template you wish to modify, and locate it's .xcodeproj file. You can "show package contents" and inside is a project.pbxproj. You can modify this file and edit in the build setting to change the default compiler.
You'll have to find each section that relates to the build settings for each configuration (Debug, Release etc.), search for /* Begin XCBuildConfiguration section */.
Then you'll have to add GCC_VERSION as a key and com.apple.compilers.llvm.clang.1_0 as the value (1_0 in this instance is actually LLVM 1.6 according to Xcode. I also assume that the key-name GCC_VERSION only has GCC in it for legacy reasons, this will probably be updated to COMPILER_VERSION or something in the future).
Save the template and create a new project (You may have to restart Xcode if it was open). The compiler should be set to LLVM now.
However, I don't recommend you do this as LLVM still isn't 100% fit for deploying applications to users.
I don't believe there's an (easy) way to do this. (i.e.: There's no preference pane option for such a thing.) That said, the advice within the existing Setting GCC 4.2 as the default compiler on Mac OS X Leopard question should work #Jasariens answer seems ideal, if the per-project setting is proving tiresome.
However, LLVM isn't quite ready for prime time, so I'd really recommend not using it for the final deployment of apps, etc. (If you're encountering any odd issues, switch back to using GCC and they'll quite possibly go away.)
Incidentally, whilst off-topic, there's some great tips within the Hidden Features of Xcode question as well, so that might be worthy of a browse. :-)
The very easiest way (and smartest, I think) to do it for all future projects is to do the following 5 steps :
go to /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iPhone Base.xctemplate (you can simply Command + o (open) in Xcode then Command + Shift + G (go to folder), then paste this path)
open the file TemplateInfo.plist in Xcode
go to Project > SharedSettings > GCC_VERSION property and change its String value to com.apple.compilers.llvm.clang.1_0 : http://grab.by/a0dV
save the file
test by opening a new iPhone project.
You can do the same for other new project by going to, for example, /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iPad Base.xctemplate for the iPad projects, etc.
That's it.
Have a nice day everybody.
I’ve written a simple script that creates a fresh Xcode project with sane defaults. Might be worth adapting, so that you don’t have to set up every new project by hand.
All answers tell how to change default compiler value for new projects.
This is how to change directly the "iOS default" values in XCode for any projects :
EDIT the file (with sudo)
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSXXXX.sdk/SDKSettings.plist
Restart XCode and done!

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.

Minimizing the use of Xcode - how to quickly build and go from source code?

I realize I have to use Xcode to develop for the iphone, but I'm trying to build apps from raw source code generated outside of Xcode.
For example, I would like to "Build and Go" the apple demo "TheElements" (here). (I use this example because it has no .xib files - so Xcode is not needed for the UI).
It works to just unzip and open the .xcodeproj in there, but what if I had generated this code elsewhere and haven't yet used xcode? I.e., I have a directory of files (the contents of the .zip without the xcodeproj stuff):
./Default.png
./Images/*.png
./Classes/*.{h,m}
./Icon.png
./main.m
./Elements.plist
./Info.plist
./TheElements_Prefix.pch
Can I quickly (automatically?) get this built and running in the simulator?
I guess the question also relates to what information is really stored in the xcodeproj. Ideally, there would be some scriptable method for generating the project.pbxproj file, but sadly can't find this.
You might think of the Xcode project file as a glorified Makefile (if you're coming from the Unix world) or a VC solution file (if you're coming from Windows). It's a description of the dependencies between components and the steps required to build, link, and deploy those components. There is no more fundamental "Build and Go" than that.
On the iPhone, Xcode is required to build a viable application (technically, you could chain up the command line invocations used by Xcode—check the build log—but you'd be pretty crazy to bother). You can use a command line invocation (xcodebuild) instead of using the Xcode GUI app, but you still need a project file.