How to open project files with Xcode 4 by default while having Xcode 5 installed alongside - xcode4

Xcode 4 is still my main IDE for iOS development. To try the upcoming iOS 7 I installed Xcode 5 Developer Preview and now all the files that were used to open in Xcode 4 now open in Xcode 5.
How can I revert Xcode 4 to be default editor again without uninstalling Xcode 5?

After reading about LaunchServices in OS X I have finally found the solution, thanks for the hint #peter-m.
To modify files association for certain app one can use lsregister tool. So to re-register the app there is -f parameter, and to unregister -u. Everything can be in fact done with just one command:
$ lsregister -f /Applications/Xcode.app
Or if you want to unregister Xcode 5 and not touch manually set associations earlier:
$ lsregister -u /Applications/Xcode5-DP5.app
lsregister is located in /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/, so add it to your $PATH
Re-login to OS X for changes to apply.

Assuming you don't have any Xcode 5 projects yet, how about manually:
Find an existing XCode 4 project (*.xcodeproj) with the Finder
Do a Get Info of the file
Change Open with: to your desired version of Xcode
Click on Change All
Repeat for all types of files that you want to open with XCode 4
Or if you want to try something more automatic take a look at: programmatically-script-atically-changing-the-default-open-with-setting
Based on the comment below, the problem seems to be with command line builds picking the wrong version of Xcode. In that case I suggest looking at: xcode-build-and-archive-from-command-line, especially the Reid's comment to his own answer which says:
Works fine in Xcode 4.4, and I'm sure it was fine in 4.3 as well. Make sure you have selected the correct Xcode release by using:
xcode-select <path to Xcode.app>
So perhaps the correct solution is based around understanding:
xcode-select -- Manages the path to the Xcode folder for Xcode BSD tools.

Related

How to run and use Xcode 3 and Xcode 4 under OS X 10.7 Lion?

I am looking for a full guide on how to trick Xcode3 to run under Lion.
I am aware that Apple does not support this, but this doesn't meant it's impossible, it's just not supported.
This is how I upgraded my dev environment to Lion. I am only doing it this way because I'm in a crunch and have some issues with Xcode 4.
I'm just sharing what I did and the issues I encountered, not recommending anything:
I made sure I could build & launch my Apps in 10.6.8 using Xcode 3.2.x.
I upgraded my development machine to Lion 10.7.1.
I can build all my SW products with Xcode 3.2.x.
BUT, the debugger seems unhappy with some things... Though I can step and break, I can't evaluate some expressions. For example, the twist pane won't display contents of complex structures.
I'm wondering if others have debugger issues with the 3.2.x Xcode (GDB) on Lion?
Thanks,
Rick
First you have to obtain the Xcode 3.2.6 install to work. The installer is not going to work on Lion so you have two alternatives:
Run it from another partition where you have 10.6
Path the installer in order to make it run on Lion by following this guide
Also here are some other things you may have to clean inside the xcode projects:
Remove lines like ARCHS = arm7 because it will fail to build for Simulator. Best is to let Xcode use defaults (all supported archs).
Check for SDKROOT = ..., it should be only iphoneos, macosx or undefined (not ""). Keep in mind that the SDK you are building against is not necessary the minimum required SDK for running the application. It's ok if SDKROOT is missing from Xcode project files but it's not ok if it does contain a path or "".
Remove any GCC_VERSION = ...

Which version of Xcode does xcodebuild use?

I have installed both Xcode 3.2 and Xcode 4.0.2 on the same machine, which uses Hudson for automated CI (continuous integration) builds. When I say that both were installed, what I mean by that is that I can use both Xcode 3 and Xcode 4 simultaneously or interchangeably. They both exist on the machine, as I did a custom install for Xcode 4 without overwriting Xcode 3 (supposedly).
Do command line calls to 'xcodebuild' invoke Xcode 3 or Xcode 4?
Does that question even make sense? Someone who may or may not be knowledgable on the topic is requesting that some projects be built with 3 and some with 4.
If so, how do I force it to use 3 or 4?
alternatively, is there a separate location where Xcode 3's 'xcodebuild' is stored vs. where Xcode4's 'xcodebuild' is stored? If there is, I can just use a different path in my build script.
You can find out what version is xcodebuild using with xcode-select -print-path. Also, change to a different version using xcode-select -switch <path>
Also, to determine which XCode environment is being used, use the command xcodebuild -version.
Outside the terminal, you can view and change this in Xcode.
Open Preferences, then select the Locations tab. Near the bottom, an entry titled Command Line Tools labels a dropdown, whose selection corresponds to the version of Xcode used in xcodebuild.
You may open this dropdown to select another version of Xcode that you have installed in your /Applications or ~/Applications folder.
Interestingly, this panel only says what this pop-up menu does and that it's analogous to xcode-select if you've selected a different version of Xcode than the one it's running in.
In case you need it, I also have a screenshot from what this used to look like in Xcode 8.

How do I specify an installation location for Xcode 4.1 from the Mac App Store?

I just installed Lion, and downloaded Xcode 4.1 from the Mac App Store. I like having my Xcodes installed in /Developer directories that have their Xcode versions appended (e.g. /Developer-xcode3.2.6). Downloading Xcode 4.1 from the Mac App Store just gives me an installer app, which does not allow me to specify an installation location, as Xcode installers did in the past. When I ran the installer, it asked me to move old Xcode 3 installs out of /Developer, so is just renaming the /Developer directory sufficient? Will that break stuff?
Locate the 'Xcode Install' package. Show package contents. Inside the Resources folder you will find Xcode.mpkg. Install as usual.
renaming the folder should be enough but, yes, it may break stuff if you continue to use xcode 3. “it may” because you will still have a “/Developer” folder which will contain tools xcode use. if they (the tools) don't change too much between xc3 & 4, you shouldn't have any problem.
but stick with xcode4 and you won't have any problem at all.

xcode4 documentation for iOS 4.3 Library

I installed xcode4 and in Organizer - Documentation I can see iOS 4.3 Library, Mac OS X 10.6 Library and Xcode 4.0 Developer Library. However, when I'm offline, I cannot access the iOS library documentation, I'm getting Error Loading URL You are not connected to internet. For the other 2 libraries it works.
Anyone knows why it happens like that? There's no "get" button anymore in XCode > Preferences > Documentation.
open the link feed://developer.apple.com/rss/com.apple.adc.documentation.AppleiPhone4_3.atom
find the properly file for your iOS
after finishing download copy the xar file to path /Developer/Documentation/DocSets/ and unzip
it "sudo xar -xf *.xar" and unzip *.docset "sudo chown -R -P devdocs"
For some reason the iOS 4.3 Library is downloaded later. When you are online go into Preferences for Xcode and select Documentation. You will see that library is likely disabled but ready to be downloaded. If that is the case there will be a "Get" button on the right side which you can use to start the download which may take a while.
Once it is downloaded you will be able to use that documentation library when you are offline.
I was trying to get the documentation offline but could not find the "get" button.So I had to go to Preferences->Downloads->Documentation->Check and install now and then the new libraries showed up.Its better to check the "Check for and install updates automatically"
Arguably simpler than any of these is to manually add the RSS feed for the documentation - at the bottom of the documentation download list is a + / - set of controls. Click + and paste in feed://developer.apple.com/rss/com.apple.adc.documentation.AppleiPhone4_3.atom and it'll automatically select the right one and start downloading (and notify you of updates, though I doubt there will be any more)

Xcode 4 (final version) error when building

I can't seem to find the answer.
I've just used Xcode 4 final version and built an existing project that was built ok with Xcode 3, but got this error:
ld: library not found for -lSystem.B
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
But another project was built OK with Xcode 4.
I installed Xcode 4 by choosing the default options.
Do I miss to include a library or framework somewhere?
Could somebody please help. Thank you.
Here's my solution for Xcode 4.0.2 with SDK 4.3 environment, but I believe it should also work on other setups.
libSystem.B.dylib is not present
under
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib,
however it is present for lower SDK
versions (e.g. iPhoneOS4.2.sdk)
most of the cases
libSystem.B.dylib is just a
symbolic link to libSystem.dylib
so in
iPhoneSimulator4.3.sdk/usr/lib
I've applied following command sudo
ln -s libSystem.dylib
libSystem.B.dylib and my simulator
builds started to work again :)
NOTE: libSystem.B.dylib is used by Flurry and Urban Airship so you better don't delete the reference in project file (of course Urban Airship does not work under Simulator, but I think Flurry does. libSystem.B.dylib may also be required by other libraries you included to your project.
UPDATE: solution still works for iOS5 Simulator after upgrading to Xcode 4.3
UPDATE, March 9th, 2k12: for Xcode installations via App Store, prefix above path with /Applications/Xcode.app/Contents or the path where you've installed Xcode.app.
Solved.
Turns out that there was a reference to libSystemB in my project (Don't know why it's there). After deleting the reference, it built well.
Thanks anyway guys!
-weak_library /usr/lib/libSystem.B.dylib breaks the iOS Simulator.
Use -weak-lSystem instead.
The quote belongs to gparker on the official dev forums.
-weak_library /usr/lib/libSystem.B.dylib breaks the iOS Simulator. Use -weak-lSystem instead.
nicktmro got it right, especially when you are developing cocos2d projects using xcode 4.x
I have the same problem since months and always kept making the symbolic link as described here everytime i updated xCode. Today I found a nice new way to fix this:
In your targets Build Phases go to 'Link Binary With Libraries' and search for:
libz.dylib
Set from 'Required' to 'Optional'
BUILD
BE HAPPY

Resources