Using Emacs with Xcode 4? - emacs

I want to get rid of the slow code editor of Xcode 4 and use Emacs instead. In Xcode 3 I can do this from the file types preferences, but I can't find that in Xcode 4.
How can I change the editor in Xcode 4?
If for some reason Apple went crazy and removed this feature from Xcode, is there a way to edit the xcodeproj from within Emacs (add/remove files), as well as build and use the iPhone Simulator?

In answer to your questions:
Yes, Apple went crazy and removed the ability to associate an alternative editor so you won't be able to automatically use Emacs as an editor within Xcode4 as you did under Xcode3. You will have to setup your project in Xcode4 and (separately) use Emacs to edit source files in the project.
You can use the "xcodebuild" command line tool to build your Xcode4 project from within Emacs. Just Google or search through SO earlier messages for some tips on how people do this.
To install your app on the simulator and run it from the command line, read the replies to this post.

Related

Tool for comparing Xcode project files

I've been given the Xcode project files for version 1 and 2 of a iOS app. Version 1 is working, version 2 is buggy with more features. The original programmer is no longer available. No versioning system was used.
Is there a tool to compare the different projects - so I can see what code was added between version 1 & 2?
You can compare two Xcode project using FileMerge tool available with Xcode.
Below are steps for comparison in Xcode 6.1
Right click on Xcode icon -> Select 'Open Developer Tool' -> Select 'FileMerge' option
This will open window as show below :
Select two Xcode project which is to be compared by clicking Left and Right button
Click on 'Compare' button. This will create list of file that are added, removed or altered
by comparing two Xcode project.
I'm pretty sure that nearly everything in an xcode project is stored in text files so you should be able to use standard diff tools to compare the projects. This, of course, excludes resources such as images, audio, etc.
FileMerge is an app that comes with Apple's Developer tools. It does diffs and merges. It can be run through the terminal with the the opendiff command.

Xcode crashes on opening xib files

I have problems with xcode and can't open xib files. Everytime I click on the xib file, xcode crashes. This happens on the xcode3.2 as well as the xcode4.
Is there anything I can do to it? I have un-installed and re-installed but still not working.
Any help would really be appreciable.
If it helps, I am using xcode4 and bought it from the app store.
My problem was custom fonts in XIB file. I had to install missing fonts on my computer and problem was solved.
The solution to this problem was to re-install my operating system. Basically, I had to re-install Lion and after that everything worked fine. I think the problem had something to do with some library files that were missing.
NOTE: If you have this problem then re-installing your OS might not be the only solution as easier solutions may present themselves. Some of the answers on this question could be of help and in other cases, a simple google or stackoverflow search could be of great aid. You could also try the Xcode mailing list. I would advice resorting to re-installing your OS only if you have tried 'everything' and no one is able to help, hence your plan-Z.
I had this same problem in Xcode 4.3 today. It is definitely a bug in Xcode and it has something to do with opening xib files saved with older versions of Xcode. To work around it, I did the following, some of which may not be necessary, but I'll list it all here just in case:
quit Xcode
copied my xib file foo.xib to foo2.xib
svn rm foo.xib
svn commit
svn update (now foo.xib is not on disk)
open my xcode project, foo.xib shows up in red since it can't find the file. delete foo.xib from the project.
drag foo2.xib from the finder into my project
click on foo2.xib -- for me it opened just fine
At this point I'm pretty sure it's either a subversion conflict with xcode or xcode is keeping a stale reference to a filename around. But now that I have the file open, I do the following:
Show the right-hand-side IDE settings pane (where you can set NIB options).
Click the top left icon in the right-pane (tooltip says "Show the File Inspector").
There is a section called "Interface Builder Document" and under there is a "Document Versioning" popup/combo box. My file shows Xcode 4.2.1, so I changed it to Xcode 4.3.
At this point I also fiddled with a few other settings in my nib, for example changing the title of a Window. The point of this was to make sure the nib would be re-saved.
Now in the left-hand pane that lists the project files, I clicked on "foo2.xib" and renamed it to "foo.xib" -- Xcode automatically adds it back to the subversion repository.
And everything just magically worked after that.
I will point out that I went through and changed all of my nib files after that to save as "Xcode 4.3" under the Document Versioning pane.
I sent a crash report and the nib contents to apple in a bug report but if anyone wants to see what actually happened I pasted it here:
http://pastebin.com/sC0pBUfu
I hope this helps someone, it took me about four hours to sort this out. Recreating nib files doesn't work, its a problem with the filename and IDE-version saved into the nib file I suspect.
Just Install one xcode at a time. Means use Xcode 4 or Xcode 3.2 alone. This may solve your problem. Try that.
Edited with new suggestion from http://www.cocoabuilder.com/archive/xcode/305032-xcode-help.html :
If you have entirely uninstalled and then reinstalled XCode, and by
uninstalled I mean running
sudo /Developer/Library/uninstall-devtools -mode=all
and then trashing /Developer and then reinstalled and it's STILL not
working then from the error I have to think you have a corrupted OSX
or a stray library.
I googled and found a couple of people who succeeded by reinstalled
SnowLeopard (and then upgrading it all the way to latest patch level,
then reinstalling XCode), and there were a few people who had found
stray libraries in /usr/local/include and /usr/local/lib, so you might
want to go look for odd files there, or perhaps TEMPORARILY rename
them and try reinstalling XCode, I'm not sure how much of what's in
there you really need. The particular post I found they guy had
installed ImageMagic and he had removed those libraries from
/usr/local/lib and was working again.
At this point I'd be looking beyond XCode itself and assuming my
system was corrupt.
There's more suggestions on Google, just put in CFXMLNodeGetInfoPtr
and there are loads of posts, more asking than answering.
and Don't use the App Store version. Use the one on Apple.com/Developer for iOS SDK's.
Create a new XIB. Click once. If not:
Don't just open the xib, right click Open As : Source. See if you can see anything, if it still crashes:
Does not seem to a Xcode.pbxproject error
Well, one way can be..:
type interface builder in spotlight
open it.
go to your project and drag & drop your xib to the interface builder on the dock.
It will open.
This problem may be because of multiple versions of xcode on different locations on your mac.
Can't open any xib file for iOS? In your crash log,
Details: Interface Builder encountered an error communicating with the iOS Simulator. "Interface Builder Cocoa Touch Tool" (5963) failed to launch and exited with status (null), signal 5. Please check Console.app for crash reports for "Interface Builder Cocoa Touch Tool" for further information.
Have you checked your console log using Console.app? Anyway, it sounds like that your Xcode environment is corrupted.
sudo /Developer/Library/uninstall-devtools -mode=all
If you put any files into /Developer, back it up.
sudo rm -rf /Developer
reboot.
install Xcode.
Its an XCode bug.
Creating a new .storyboard and opening it before opening .xib will fix the crash, at least temporarily.

moving back from Xcode 4 to Xcode 3.2.6

I tried Xcode 4 a bit. Found it frustrating and am currently returning to Xcode 3.2.6. But now my project can't find any of its frameworks. How do I fix that?
I had similar issue when I moved from 3.2.5 to 3.2.6.. all framework became red, not found error.
I tried restarting xcode, changing base sdk, etc, and didn't seem to fix it :(
To fix this, I had to do below (from some thread online, can't find the source now).
1) go to your project directory/proj.xcodeproj (proj is your project name)
2) open up project.pbxproj file, using any text editor
3) search for "SDKROOT =", and modify it to point to your framework directory.
For me, I had to edit them to: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/
Save your pbxproj file before you modify it, as just in case.
have fun!
Try changing the Base SDK project option to something else than it is now, restarting XCode (might not be necessary) and changing the aforementioned option back again.
It happened to me before (in Xcode 3) a few times while moving project between different Xcode versions (even with the same iOS SDK).

Property List Editor after installing Xcode 4

I cannot find where it is after I installing Xcode 4. Does any one know where it is ?
Edit:
I had installed another app for editing XML file. It is named XMLEditor and located here. Because I need to edit a plist file with an extension which is not end with .plist, so finally I googled another solutions about XML editor.
In XCode 4 the property list editor is integrated. It should appear in the XCode application.
I put together a frankenstien version of the Property List Editor a while ago. Its totally self contained and should work as a stand alone app.
Find it here:
https://www.dropbox.com/s/k6knivza9dramb5/Stand%20Alone%20Property%20List%20Editor.app.zip
I found in xcode 4 when you create a new plist file, the editor opens as blank. If you right click in the blank editor space, you can "add row". Begin from there.
I wish I'd seen this before installing Xcode 4 - the Property List Editor.app was so nice and lightweight and fast - now having to launch Xcode.app just to edit a plist file ... ugh.
I'm going to dig it back out of my old Xcode 3 DMG ... this is just not cool.
You can install the Snow Leopard Property List Editor application on Mac OS X 10.7 Lion by following this tutorial:
http://sveinbjorn.org/install_property_list_editor_app_on_mac_os_x_lion
The application continues to work just fine in Lion, as long as you also install the now-deprecated framework it relies on. It's just that Apple isn't including it, presumably because they want us to use bloated XCode 4.

There is no SDK with the name or path "iphoneos4.0"

I download a sample of UICatalog and run it.When I compile it ,it shows the failed message:There is no SDK with the name or path "iphoneos4.0".I find the "Base SDK" of UICatalog's Targets is iphone Device 4.0(missing).How can I solve this question and run it.
Thank you!
Select the root level of the project, in "Groups & Files". It's blue. Then hit command-I to get its Info.
Pick "Build" from the segmented controller at the top of the info window. In the first section of that panel you'll see Base SDK as one of the first few lines of options. Select the latest version of the SDK you find in there, and close the window to save your options.
Build-and-run the project, and you should be good to go.
EDIT, because I see from the comments that people are finding this answer who have a slightly different question than the OP's, so here's one other thing to try. It could also be you have "iOS Device" selected as your build target. If so, and if what you really want is for it to launch into the simulator, select "Simulator" instead.
After loading the project into XCode..
Under Groups and Files
right click on UICatalog<-(or your demo project name) and select Get Info
in Base SDK select IOS Simulator 4.1
Close and save info pane
expand Targets exposing UICatalog<-(or demo project name)
right click on UICatalog and select Get Info
in Base SDK select IOS Simulator 4.1
Combo box in UICatalog project pane (upper left corner) should switch to "Device - 4.1 | Debug" instead of "No Base SDK"
if you Build and Run at this point you might get another error. If so, open the UICatalog combo and switch from Device to Simulator
The "official link" mentioned above states…
"Note: Targets can override build settings defined at the Project level. "
..but should probably read "will" instead of "can"
Ok, I've solved it.
In Groups & Files go to Targets and select your target.
Press Ctrl+I (or open the info in some other way)
Set the Base SDK of your target
(The Base SDK should also be set at the project)
Steve nailed it. This is an Xcode bug. I loaded the NavBar sample and Xcode didn't even offer the simulator as an option, and it complained about the missing SDK even though it was set correctly in the project and wasn't set at all on the target.
Do what Steve said:
"The only way I could resolve it (in fact, the only way I could get the option of running in the simulator at all) was to change from debug to release and back. The dropdown still shows Base SDK Missing but if you click it, the simulator options are there and it builds."
My problem was that in the sample code another xcodeproj was embedded. So I looked after that file with Finder, opened it with Xcode and than the same as Dan said: Project -> Edit Project Settings -> Under "Architectures" set Base SDK to "iPhone Simulator x.x" (the latest one you have installed)
I had the same issue with another Apple sample app. The only way I could resolve it (in fact, the only way I could get the option of running in the simulator at all) was to change from debug to release and back. The dropdown still shows Base SDK Missing but if you click it, the simulator options are there and it builds.
I think that's a bug.
Many answers here, none seem to be complete enough about this, and it's all a mess. But they are all helpful. Here, I just want to compile all helpful pieces in one answer. Thanks to Larry (who have almost everything compiled into steps already), Steve, Dan Ray, dkk, geowar and lqf.
This picture from apple is a little decieving and outdated (talking about iOS SDK 4.0 and we're currently at 4.1) but it does show where you should change the project settings. Just select iPhone Simulator 4.0 if it was previously on iPhone Device 4.0.
Other than that, they say "Targets can override build settings defined at the Project level". So, yeah, also go ahead, open Targets and set all of their Base SDK back to default by pressing delete on it. If they were bolded, they'll become regular indicating a default value, which should be iPhone Simulator 4.0 if you did the first step right.
Just realize there are many places where Base SDK can be wrong:
Under Project Info
Under Target Info
Under different configurations for both Project and Target
And that under Target it should be set to default, which is value from Project.
There's still something about the overview combo sometimes having and sometimes not having more than 1 option such as "Device" and "Simulator" that I just couldn't understand yet, but this is another potential configuration place for Base SDK being wrong.
You have to make sure that you change to the "iPhone Simulator" under the project settings in the appropriate configuration (i.e. if you are building a debug build you have to change to the simulator under the debug configuration).
For some reason I was getting this error when I did change the simulator but realized that I was doing a debug build but changed to the simulator under the release configuration and not the debug configuration.
dkk's answer is what made things work for me. I had to change the Base SDK on the target and not just the project. Perhaps you have to do both.
I got a similar error after upgrading my iPhone to iOS4.2.1(8C148a). The situation is as following.
I was using Xcode 3.2.4, but it does not support iOS4.2.1. So I downloaded Xcode_3.2.5_and_ios-sdk_4.2_final.dmg which is 3.78GB requiring 9.53GB to install. Then I ran my ap with Xcode 3.2.5. That is where I got the above error message.
Now it is ok. I solve this based on Geowar's answer:
For the official answer:
http://developer.apple.com/library/ios/#qa/qa2010/qa1701.html
Please be noted that if you have done as Geowar said and the message is still there. Try to close Xcode 3.2.5 and restart it. That is how it works for me.
Another thing is that if you have just upgraded to iOS4.2.1 like me. When you try to load the a/p from Xcode 3.2.5 the first time. Xcode 3.2.5 may still give you "No provision iOS device connected". Please try to go to organizer and click on your iPhone under DEVICES on the left bar. Wait for a while to let Xcode in sync with your iPhone with iOS4.2.1. Then it will work. At least it work for me.
Jesse
Ok, so I struggled through this too. Based on some of the answers above and from the apple development forum, I was able to figure out what worked for me.
In XCODE, if you notice that the pull down at the top left of the window says "BASE SDK MISSING", you are going to get this error "There is no SDK with the name or path “iphoneos4.0”". To fix the problem:
double click on Group & Files in the upper part of the left pane of xcode. This will open a window
go to the Build tab of the new window
click on the row that says "BaseSDK" and select "Latest iOS (currently set to iOS 3.2)
The Configurations pull down near the top should now say "All Configurations". If not, set it.
close the window.
Now if you try to build, you will get a different error, something like: Code Sign error: The identity 'iPhone Developer: x Xxxxx' doesn't match any identity in any profile ...
So, now what you need to do in xcode is to click on the pull down in the upper left corner (the pull down that had the original BASE SDK MISSING indication, but probably has something different now), and make sure that both "Simulator" and "Debug" are checked as options in the pull-down.
now you should be good to go.
I just went Project -> Edit Project Settings -> Build -> then change the Base SDK to iPhone 4 simulator or I'm assuming whichever SDK you want to use.
I never had to specify the build for a given target, although my program was created on a mac that was already configured to use the iPhone 4.0 simulator.. so perhaps the targets were set for the simulator SDK and the project itself wasn't? Either way... just glad it works.
I was having the same problem and what I did to solve it was:
Go to Menu Project
Go to Set Active SdK
Select the option SIMULATOR instead of DEVICE
Build and Run and the ERROR has gonne!
I hope it works for you guys... =)
I just had a situation where I changed the Base SDK to 4.2 on my project after updating to Xcode 3.2.5, but I kept on getting the "There is no SDK..." error. I finally opened the project file (MyProject.xcodeproj/project.pbxproj) in a text editor and looked around. There was no mention of 4.0 anywhere, only 4.2. BUT when I then saved that file, it all started working in Xcode. Perhaps some permission on the file or something else. Have no idea really, but it worked.
I got this error when one of my configurations still referenced an old (iOS) SDK. Note that the error shouldn't have come up when I tried to build a totally different configuration (with correct Base SDK setting), so this smells like an XCode bug to me.
People suggesting that you don't set the base SDK in at target-level have probably never created projects which contain targets for different platforms all in one project file (in my case Mac and iOS targets, so setting the base SDK once in the project file is nonsense advice).