Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p> Here is a way to enable compiling with <strong><em>gcc 4.2</em></strong> in <strong><em>xcode 4.2</em></strong>. This is mostly done via command line so when you see lines starting with: <code>[ 15:30 jon@MacBookPro / ]$</code>, you need to open up <em>Terminal.app</em> and run the command that starts after the <code>$</code>.</p> <blockquote> <p>No files or directories are <em>removed</em> or <em>deleted</em> in this process, so it is easy to undo if you need to compile with LLVM in the future.</p> </blockquote> <ol> <li><p>Download - but do <strong>not</strong> install <em>yet</em> - <a href="https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.1_for_lion/xcode_4.1_for_lion.dmg" rel="nofollow noreferrer">xcode_4.1_for_lion.dmg</a> or <a href="https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.1_for_snow_leopard_21110/xcode_4.1_for_snow_leopard.dmg" rel="nofollow noreferrer">xcode_4.1_for_snow_leopard.dmg</a></p></li> <li><p>Now, follow these steps to install Xcode 4.1 into <code>/Developer-4.1</code>:</p> <ol> <li><p>Backup the working <code>/Developer</code> directory (where Xcode 4.2 is installed)</li></p> <pre class="lang-bsh prettyprint-override"><code>[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2 </code></pre></li> <li><p>Run the Xcode 4.1 installer using the default install location (<code>/Developer</code>)</p></li> <li><p>Move the new Xcode 4.1 installation to <code>/Developer-4.1</code>:</p> <pre class="lang-bsh prettyprint-override"><code>[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1 </code></pre></li> <li><p>Move the Xcode 4.2 developer directory back to <code>/Developer</code>:</p> <pre class="lang-bsh prettyprint-override"><code>[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer </code></pre></li> </ol></li> <li><p>Edit the Xcode 4.2 <code>GCC 4.2.xcspec</code> file to get gcc 4.2 to show in the list of compiler options <sup>[1]</sup>:</p> <pre class="lang-bsh prettyprint-override"><code>[ 15:30 jon@MacBookPro / ]$ sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2 (Plausible Blocks).xcplugin/Contents/Resources/GCC 4.2.xcspec" </code></pre> <ul> <li><p>Change lines <strong>41</strong> and <strong>42</strong> from this:</p> <pre class="lang-bsh prettyprint-override"><code>ShowInCompilerSelectionPopup = NO; IsNoLongerSupported = YES; </code></pre></li> <li><p>To This:</p> <pre class="lang-bsh prettyprint-override"><code>ShowInCompilerSelectionPopup = YES; IsNoLongerSupported = NO; </code></pre></li> </ul></li> <li><p>Backup the Xcode 4.2 iOS/Simulator Framework <code>usr</code> directories:</p> <pre class="lang-bsh prettyprint-override"><code>[ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr.backup [ 15:30 jon@MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneSimulator.platform/Developer/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr.backup </code></pre></li> <li><p>Copy Xcode 4.1 iOS/Simulator Framework <code>usr</code> directories to Xcode 4.2:</p> <pre class="lang-bsh prettyprint-override"><code>[ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr </code></pre></li> <li><p>Copy the <code>gcc</code> and <code>info</code> iOS SDK library directories from Xcode 4.1 to Xcode 4.2 <sup>[2]</sup>:</p> <pre class="lang-bsh prettyprint-override"><code>[ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/gcc /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc [ 15:30 jon@MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/info /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/info </code></pre></li> <li><p><strong>Compile using gcc-4.2!</strong></p> <p><img src="https://i.stack.imgur.com/sIfUc.png" alt="Screenshot of CGG 4.2 in xcode 4.2"></p></li> </ol> <p><strong><a href="http://blog.hozbox.com/2011/11/08/how-to-use-gcc-4-2-with-xcode-4-2/" rel="nofollow noreferrer">This is a blog post I've written with a little more info about this process. Feel free to leave a comment on the blog if you run into any issues or have any questions.</a></strong></p> <hr> <p><sup>[1]</sup> If opening from a command line (using something like <code>vi</code>, <code>emacs</code>, <code>nano</code>, etc) make sure to either enclose the path in quotes <kbd>"/long path/with spaces/in it/file.xcspec"</kbd> or escape the spaces <kbd>/some/long\ path/with\ spaces/in\ it/file.xcspec</kbd><br/></p> <p><sup>[2]</sup> This is necessary because the iPhoneOS.platform SDK has its own seperate <code>/usr/lib</code> directories but the iPhoneSimulator.platform SDK does not</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload