Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode4

xcode5

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?

like image 897
svlasov Avatar asked Aug 13 '13 12:08

svlasov


2 Answers

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.

like image 114
svlasov Avatar answered Oct 12 '22 12:10

svlasov


Assuming you don't have any Xcode 5 projects yet, how about manually:

  1. Find an existing XCode 4 project (*.xcodeproj) with the Finder
  2. Do a Get Info of the file
  3. Change Open with: to your desired version of Xcode
  4. Click on Change All
  5. 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.

like image 44
Peter M Avatar answered Oct 12 '22 11:10

Peter M