我们如何将 ppc/ppc64 以及完整的 10.4/10.5 SDK 支持恢复到 Xcode 4?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5333490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can we restore ppc/ppc64 as well as full 10.4/10.5 SDK support to Xcode 4?
提问by Mecki
Since Apple only ships SDK 10.6 with Xcode4, developing PPC applications with Xcode4 became impossible. While it is possible to develop applications with Xcode4 that can also run on 10.5 and maybe even on 10.4 systems (by selecting SDK 10.6, but deployment target 10.5 or 10.4), they will only run on Intel Macs because you need at least SDK 10.5 for building PPC applications.
由于 Apple 仅随 Xcode4 提供 SDK 10.6,因此使用 Xcode4 开发 PPC 应用程序变得不可能。虽然可以使用 Xcode4 开发也可以在 10.5 甚至 10.4 系统上运行的应用程序(通过选择 SDK 10.6,但部署目标为 10.5 或 10.4),但它们只能在 Intel Mac 上运行,因为您至少需要 SDK 10.5构建 PPC 应用程序。
Further there are some rare cases, where you really need to build against an SDK prior to 10.6 for full platform support, e.g. if certain deprecated functionality has vanished completely from the 10.6 SDK, but you'll have to use it and dynamic linking is not always the best option in those cases. Also linking against an earlier SDK sometimes will ease development as functionality you are not supposed to use, as it would cause incompatibility to earlier OS versions, won't be available and any attempt to use it anyhow immediately leads to compiler or linker errors.
此外,在一些罕见的情况下,您确实需要针对 10.6 之前的 SDK 进行构建以获得完整的平台支持,例如,如果某些已弃用的功能已从 10.6 SDK 中完全消失,但您必须使用它并且动态链接不是在这些情况下总是最好的选择。此外,链接较早的 SDK 有时会简化开发,因为您不应该使用功能,因为它会导致与较早的操作系统版本不兼容,将不可用,并且任何尝试以任何方式使用它都会立即导致编译器或链接器错误。
Last but not least Apple has also removed GCC 4.0 support from Xcode4, which may be necessary for certain software to build correctly and Apple has never allowed to compile software with GCC 4.2 when using SDK 10.4, even though I hardly believe that this would really cause any issues, after all software built with GCC 4.2 and SDK 10.6 can also run on Mac OS 10.4 without any issues as long as the deployment target has been set correctly and no functionality that is unavailable under MacOS 10.4 has been used.
最后但并非最不重要的一点是,Apple 还从 Xcode4 中删除了 GCC 4.0 支持,这可能是某些软件正确构建所必需的,而且 Apple 从未允许在使用 SDK 10.4 时使用 GCC 4.2 编译软件,尽管我几乎不相信这真的会导致任何问题,毕竟使用 GCC 4.2 和 SDK 10.6 构建的所有软件也可以在 Mac OS 10.4 上运行而不会出现任何问题,只要部署目标设置正确并且没有使用 MacOS 10.4 下不可用的功能。
Of course you can always have a parallel installation of Xcode3 next to Xcode4, but that means you must forgo all the (great?) new features of Xcode4 and keep working with the outdated Xcode3 IDE. It would certainly be much better if you could also manage all your old projects within the same IDE as your new ones and benefit from any new features available. Not all projects can be made 10.6 or Intel only in the foreseeable future. Further I'm strictly against abolishing support for older platforms earlier than would be really necessary.
当然,您始终可以在 Xcode4 旁边并行安装 Xcode3,但这意味着您必须放弃 Xcode4 的所有(很棒?)新功能并继续使用过时的 Xcode3 IDE。如果您还可以在与新项目相同的 IDE 中管理所有旧项目并从任何可用的新功能中受益,那肯定会好得多。并非所有项目都只能在可预见的未来制作 10.6 或 Intel。此外,我坚决反对在真正需要之前取消对旧平台的支持。
Can we restore this functionality to Xcode4?
我们可以将此功能恢复到 Xcode4 吗?
回答by Mecki
The quick answer is: Yes, we can!
快速回答是:是的,我们可以!
Before I get to the "how it is done" part, here are some notes about my patch/hack/fix. Right from the start the major goals have been:
在我进入“它是如何完成的”部分之前,这里有一些关于我的补丁/黑客/修复的说明。从一开始,主要目标就是:
Keep all modifications to an absolute minimum.
We want to keep the Xcode setups as original as possible.By all means, try to avoid patching or modifying any files.
We want all files to stay untouched and keep their original content.Try to avoid moving or copying files around, unless absolutely necessary.
将所有修改保持在绝对最低限度。
我们希望尽可能保持 Xcode 设置的原始性。无论如何,尽量避免修补或修改任何文件。
我们希望所有文件保持不变并保留其原始内容。除非绝对必要,否则尽量避免移动或复制文件。
I was able to keep all those goals. Almost everything is done by creating symlinks. Only a single existing symlink had to be replaced and we'll back it up before replacement, just in case.
我能够保持所有这些目标。几乎所有的事情都是通过创建符号链接来完成的。只需要替换一个现有的符号链接,我们将在替换前对其进行备份,以防万一。
If you are no expert on terminal operations, I strongly advise you to copy/paste all terminal commands from my reply to your terminal, to avoid typos. Bear in mind that even spacing, quoting and especially capitalization can be important. Copy/paste them line by line, never more than one line at once and hit return after each pasted line to execute the command. Should any operation ever prompt you for a password, this will be the password of the currently logged in administrator user (your keystrokes are not displayed while typing, this is normal, don't worry, just keep typing the password and hit return; re-try if you had a typo and get prompted again).
如果您不是终端操作方面的专家,我强烈建议您将我回复中的所有终端命令复制/粘贴到您的终端,以避免输入错误。请记住,即使是间距、引用,尤其是大写也很重要。一行一行地复制/粘贴它们,一次不要超过一行,并在每一行粘贴后按回车来执行命令。如果有任何操作提示您输入密码,这将是当前登录的管理员用户的密码(键入时不会显示您的击键,这是正常的,不要担心,只需继续输入密码并按回车键即可;重新- 如果您有拼写错误并再次收到提示,请尝试)。
Prerequisite
先决条件
Before we can start, make sure the following conditions are true:
在我们开始之前,请确保以下条件为真:
- You are logged in as an administrator user.
- You have started Terminal.app (Applications/Utilities) and a terminal window is open.
- You have a copy of the Xcode3 (e.g. 3.2.5) and Xcode4 disk image (DMG) or installer available.
- If you already have either Xcode version installed, consider uninstalling it first, so you can start with a fresh/clean setup. Uninstalling Xcode will not remove your preferences, color scheme or key binding customizations. Ideally you'd start with a system that has no Xcode version (neither 3 nor 4) currently installed.
- 您以管理员用户身份登录。
- 您已启动 Terminal.app(应用程序/实用程序)并打开一个终端窗口。
- 您有一份 Xcode3(例如 3.2.5)和 Xcode4 磁盘映像 (DMG) 或安装程序的副本。
- 如果您已经安装了任一 Xcode 版本,请考虑先卸载它,以便您可以从全新/干净的设置开始。卸载 Xcode 不会删除您的首选项、配色方案或键绑定自定义。理想情况下,您将从当前未安装 Xcode 版本(既不是 3 也不是 4)的系统开始。
Step 1: Installing Xcode3
第 1 步:安装 Xcode3
Important: Do not install "System Tools" or "Unix Development" package of Xcode3.
Whether you want to install "Mac OS X 10.4 SDK" and/or "Documentation" is up to you. If that is a Xcode3 with iOS SDKs, whether you install those or not is also up to you.
重要提示:不要安装Xcode3 的“系统工具”或“ Unix 开发”包。
是否要安装“ Mac OS X 10.4 SDK”和/或“文档”取决于您。如果那是带有 iOS SDK 的 Xcode3,则是否安装这些也取决于您。
You are free to choose any destination folder for your installation. For this guide I have chosen "/Xcode3", but feel free to pick a different one. Just make sure to alter all terminal commands accordingly.
您可以自由选择任何目标文件夹进行安装。对于本指南,我选择了“ /Xcode3”,但您可以随意选择一个不同的。只需确保相应地更改所有终端命令即可。
The order of the steps given here is usually not really important, but I strongly advise you to not swap step 1 and step 2. Xcode always installs a couple of files outside of the chosen destination folder and trust me, in the end you want the Xcode4 versions of those files on your disk. By installing Xcode3 before Xcode4, you can be sure that Xcode4 will overwrite those files if necessary. I once swapped steps 1 and 2 and in the end I had some rather strange issues that might have been related to the incorrect order (I cannot say for sure, but after re-installing in the correct order the issues were gone).
此处给出的步骤顺序通常并不重要,但我强烈建议您不要交换第 1 步和第 2 步。Xcode 总是在所选目标文件夹之外安装几个文件,相信我,最终您想要的是磁盘上这些文件的 Xcode4 版本。通过在 Xcode4 之前安装 Xcode3,您可以确保 Xcode4 会在必要时覆盖这些文件。我曾经交换了第 1 步和第 2 步,最后我遇到了一些可能与错误顺序有关的相当奇怪的问题(我不能肯定,但在以正确的顺序重新安装后,问题就消失了)。
Step 2: Installing Xcode4
第 2 步:安装 Xcode4
Chose any packets you like. Installing "System Tools" is advisable, but not strictly necessary (though most people will sooner or later miss that functionality).
选择您喜欢的任何数据包。建议安装“系统工具”,但并非绝对必要(尽管大多数人迟早会错过该功能)。
Again, feel free to pick any target folder you like. For this guide I chose the normal target folder "/Developer", if you take a different one, alter all terminal commands accordingly.
再次,随意选择您喜欢的任何目标文件夹。对于本指南,我选择了普通的目标文件夹“ /Developer”,如果您选择不同的文件夹,请相应地更改所有终端命令。
Step 3: Restoring 10.4/10.5 SDK Support
第 3 步:恢复 10.4/10.5 SDK 支持
Switch to your terminal window and run the following commands:
切换到终端窗口并运行以下命令:
cd /Developer/SDKs sudo ln -s /Xcode3/SDKs/MacOSX10.4u.sdk . sudo ln -s /Xcode3/SDKs/MacOSX10.5.sdk .
Of course only run the command for 10.4u if you also installed SDK 10.4 in step 1.
当然,如果您还在步骤 1 中安装了 SDK 10.4,则仅运行 10.4u 的命令。
This is enough to bring the SDKs 10.5 (and possibly 10.4) back to the selection list in Xcode4. Give it a try if you like. Fire up Xcode4, open a project, try changing the selected SDK. That was easy, huh? Be sure to close Xcode4 again (the application, not just the window) before proceeding with the next step.
这足以将 SDK 10.5(可能还有 10.4)带回到 Xcode4 的选择列表中。喜欢就试试吧。启动 Xcode4,打开一个项目,尝试更改所选的 SDK。那很容易吧?在继续下一步之前,请务必再次关闭 Xcode4(应用程序,而不仅仅是窗口)。
Step 4: Restoring GCC 4.0 Support
第 4 步:恢复 GCC 4.0 支持
If you have not installed MacOS 10.4 SDK or if you don't plan to ever use it, you can safely skip this step and proceed with step 5.
如果您尚未安装 MacOS 10.4 SDK 或者您不打算使用它,您可以安全地跳过此步骤并继续执行步骤 5。
To use SDK 10.4, you'll have to use GCC 4.0, GCC 4.2 won't work. Apple claims that GCC 4.2 is not compatible with SDK 10.4, well, if you ask me, this is a hoax. I have already overwritten this limitations more than once and there was never the tiniest issue because of it. It would be easy to modify SDK 10.4 so that Xcode will allow you to use GCC 4.2 for it, but my goal was to avoid all file modifications, so we just add GCC 4.0 support back to Xcode, which is also a good thing, because some projects really depend on GCC 4.0 (e.g. there are some bugs in GCC 4.2 that prevent valid inline assembly code to compile without errors, while the same code compiles flawlessly on GCC 4.0 and GCC 4.4).
要使用 SDK 10.4,您必须使用 GCC 4.0,GCC 4.2 不起作用。Apple 声称 GCC 4.2 与 SDK 10.4 不兼容,好吧,如果你问我,这是一个骗局。我已经不止一次地覆盖了这个限制,因此从来没有最小的问题。修改 SDK 10.4 很容易,以便 Xcode 允许您使用 GCC 4.2,但我的目标是避免所有文件修改,所以我们只是将 GCC 4.0 支持添加回 Xcode,这也是一件好事,因为有些项目确实依赖于 GCC 4.0(例如,GCC 4.2 中有一些错误会阻止有效的内联汇编代码无错误地编译,而相同的代码可以在 GCC 4.0 和 GCC 4.4 上完美编译)。
Back to terminal:
回到终端:
cd /Developer/usr/bin sudo ln -s /Xcode3/usr/bin/*4.0* . cd /Developer/usr/libexec/gcc/powerpc-apple-darwin10 sudo ln -s /Xcode3/usr/libexec/gcc/powerpc-apple-darwin10/4.0.1 .
Right now we have restored full GCC 4.0 support except for the fact that GCC 4.0 is still not selectable in Xcode4. That is because Xcode4 has no GCC 4.0 compiler plug-in any longer. Fortunately the Xcode3 plug-in also works in Xcode4, only the position has radically changed. Apple now hides those plug-ins deep within a bundle and only plug-ins there seem to work, placing them to their old position seems to have no effect.
现在我们已经恢复了对 GCC 4.0 的完整支持,除了 GCC 4.0 在 Xcode4 中仍然无法选择。那是因为 Xcode4 不再有 GCC 4.0 编译器插件了。好在 Xcode3 插件也适用于 Xcode4,只是位置发生了根本性的变化。Apple 现在将这些插件隐藏在一个包的深处,只有那里的插件似乎可以工作,将它们放在旧位置似乎没有任何效果。
cd /Developer/Library/Xcode/PrivatePlugIns cd Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins sudo ln -s "/Xcode3/Library/Xcode/Plug-ins/GCC 4.0.xcplugin" .
Now fire up Xcode4 again, open a project and try selecting the compiler. You should have GCC 4.0 back on the list. Now you can actually already select SDK 10.4 or 10.5, GCC 4.0 and you should have no issue to build a PPC binary. Just select "Other..." for the "Architecture" build setting and manually enter "ppc", then alter "Valid Architectures" to also include "ppc". We are almost done, except that trying to build a PPC binary using GCC 4.2 and SDK 10.5 will still fail.
现在再次启动 Xcode4,打开一个项目并尝试选择编译器。您应该让 GCC 4.0 重新出现在列表中。现在您实际上已经可以选择 SDK 10.4 或 10.5、GCC 4.0,并且您应该可以毫无问题地构建 PPC 二进制文件。只需为“架构”构建设置选择“其他...”并手动输入“ ppc”,然后更改“有效架构”以包括“ ppc”。我们几乎完成了,除了尝试使用 GCC 4.2 和 SDK 10.5 构建 PPC 二进制文件仍然会失败。
Step 5: Restoring PPC Support for GCC 4.2
第 5 步:恢复 GCC 4.2 的 PPC 支持
Since Apple is only supporting Intel platforms in Xcode4, not all GCC 4.2 tools have been built with PPC support. There is one important tool that has no PPC support, the tool is named "as" and it is the GNU Assembler. To compile ppc/ppc64 binaries with GCC 4.2 we need to use an "as" version with ppc/ppc64 support. This is the one and only file (actually it also a symlink) we have to first move aside (making a backup copy) before we can replace it by a symlink:
由于 Apple 仅在 Xcode4 中支持 Intel 平台,因此并非所有 GCC 4.2 工具都支持 PPC。有一个重要的工具没有 PPC 支持,这个工具被命名为“ as”,它就是 GNU Assembler。要使用 GCC 4.2 编译 ppc/ppc64 二进制文件,我们需要使用支持 ppc/ppc64的“ as”版本。这是唯一一个文件(实际上它也是一个符号链接),我们必须先移到一边(制作备份副本),然后才能用符号链接替换它:
cd /Developer/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1 sudo mv as as.bak sudo ln -s /Xcode3/usr/bin/as .
Step 6: There is No Step 6
第 6 步:没有第 6 步
That's all folks. Considering how easy that was, you can imagine that Apple has certainly not dropped SDK 10.4/10.5 or ppc/ppc64 or GCC 4.0 support because this was a necessity, they dropped all that because they wanted to drop it.
这就是所有的人。考虑到那是多么容易,你可以想象 Apple 肯定没有放弃 SDK 10.4/10.5 或 ppc/ppc64 或 GCC 4.0 支持,因为这是必要的,他们放弃了所有这些,因为他们想放弃它。
I hope this setup works as well for you as it does for me. I have been able to compile all my old projects in Xcode4 without any major changes, except for having to alter a search path here and there.
我希望这个设置对你和我一样有效。我已经能够在 Xcode4 中编译我所有的旧项目而没有任何重大更改,除了必须在这里和那里更改搜索路径。
PS:
It may look strange that I answer my own question here, but since I have found out how to solve this problem all by myself, I'd like to share my knowledge with the community, because I believe this is really valuable input to all MacOS developers out there. This question has been asked so many times in so many places and so far I have never seen anyone coming up with a similar fix. Share the wealth, spread the knowledge and so on, you know what I mean.
PS:
我在这里回答我自己的问题可能看起来很奇怪,但是由于我已经找到了自己解决这个问题的方法,所以我想与社区分享我的知识,因为我相信这对所有 MacOS 开发人员都在那里。这个问题在很多地方被问过很多次,到目前为止我从未见过有人提出类似的解决方案。分享财富,传播知识等等,你懂我的意思。
If You Still Have Issues/Questions:
如果您仍有问题/疑问:
If you have additional questions regarding this topic or if you still have problems to build your old projects correctly, please do what Stack Overflow has been designed for: Click on "Ask Question" in the upper right corner of this page and create a new question. That way the whole community can help you solving those issues, since the issues may not directly (maybe not even indirectly) be related to this hack.
If you have additional questions regarding this topic or if you still have problems to build your old projects correctly, please do what Stack Overflow has been designed for: Click on "Ask Question" in the upper right corner of this page and create a new question. That way the whole community can help you solving those issues, since the issues may not directly (maybe not even indirectly) be related to this hack.
I would recommend you mention the fact that you did apply this hack at the very beginning of your question. Maybe you even want to directly link to this question, so that people, who never heard of this hack, can easily look it up. Otherwise most people will get rather confused when you mention SDK 10.4/10.5, PPC or GCC 4.0 in combination with Xcode4, which officially supports neither of these. You might get rather stupid comments instead of decent replies if you forget to mention this hack.
我建议您提及您确实在问题的一开始就应用了此 hack 的事实。也许您甚至想直接链接到这个问题,以便从未听说过这个 hack 的人可以轻松查找。否则当你提到 SDK 10.4/10.5、PPC 或 GCC 4.0 与 Xcode4 结合时,大多数人会感到相当困惑,而 Xcode4 官方不支持这些。如果你忘记提及这个 hack,你可能会得到相当愚蠢的评论而不是体面的答复。
Please refrain from posting your questions or issues here either as replies or as comments. Posting them as replies makes no sense because they are no replies and there is no way how people can reply back to you, other then using comments, and comments may not offer enough room for a decent reply to your question or a decent solution to your problem. And posting them as comments means you are limited to very little room and tracking reply comments will be hard as comments have no tree-like hierarchy (further they will still offer to little room for decent replies/solutions). Thank you.
请不要在此处以回复或评论的形式发布您的问题或问题。将它们作为回复发布是没有意义的,因为它们不是回复,并且人们无法回复您,除了使用评论之外,评论可能无法提供足够的空间来对您的问题进行体面的回复或对您的问题提供体面的解决方案问题。将它们作为评论发布意味着您被限制在很小的空间内,并且很难跟踪回复评论,因为评论没有树状层次结构(此外,它们仍然为体面的回复/解决方案提供很小的空间)。谢谢你。
Of course other kind of comments as well as better replies to the original question are always welcome ;-)
当然,始终欢迎其他类型的评论以及对原始问题的更好回复;-)
回答by Kazuki Sakamoto
Another easy way with only Xcode4, Xcode3 is no longer needed.
另一种仅使用 Xcode4 的简单方法,不再需要 Xcode3。
$ sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/ppc /Developer/usr/libexec/gcc/darwin
$ sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/ppc /usr/libexec/gcc/darwin
EDITS:
编辑:
For Xcode 4.1,
对于 Xcode 4.1,
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/ppc /Developer/usr/libexec/gcc/darwin
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/ppc /usr/libexec/gcc/darwin
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-cpp-4.2.1 /usr/bin/powerpc-apple-darwin11-cpp-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-gcc-4.2.1 /usr/bin/powerpc-apple-darwin11-gcc-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-g++-4.2.1 /usr/bin/powerpc-apple-darwin11-g++-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-cpp-4.2.1 /Developer/usr/bin/powerpc-apple-darwin11-cpp-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-gcc-4.2.1 /Developer/usr/bin/powerpc-apple-darwin11-gcc-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/powerpc-apple-darwin10-g++-4.2.1 /Developer/usr/bin/powerpc-apple-darwin11-g++-4.2.1
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/powerpc-apple-darwin10 /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc
You can use gcc-4.2 only for PowerPC. And “-isysroot /Developer/SDKs/MacOSX10.6.sdk” option is required, because 10.7 SDK doesn't support PowerPC any more.
您只能将 gcc-4.2 用于 PowerPC。并且需要“-isysroot /Developer/SDKs/MacOSX10.6.sdk”选项,因为10.7 SDK不再支持PowerPC。
回答by Scott Lahteine
I've gathered together all the information from this page, Mac OS X Hints, splhack.org, and the other sources cited here, and put together a set of BASH scripts which automate the process of restoring PPC and GCC 4.0 support using either an XCode 3 installation or just XCode 4's own iPhone platform files.
我收集了来自此页面、Mac OS X 提示、splhack.org 和此处引用的其他来源的所有信息,并将一组 BASH 脚本放在一起,这些脚本使用以下任一方式自动恢复 PPC 和 GCC 4.0 支持的过程XCode 3 安装或只是 XCode 4 自己的 iPhone 平台文件。
As always, use with caution! and please contribute any fixes or improvements. These scripts have only been tested on my own system as of this posting.
一如既往,谨慎使用!并请贡献任何修复或改进。截至本文发布时,这些脚本仅在我自己的系统上进行了测试。
You can download them from GitHub:
你可以从 GitHub 下载它们:
回答by jas
If you want gcc to work from the command line as well, (as well as the above) you'll also need to:
如果您希望 gcc 也从命令行工作,(以及上面的)您还需要:
cd /usr/libexec/gcc/powerpc-apple-darwin10/4.2.1
sudo mv as as.bak
sudo ln -s /Xcode3/usr/bin/as .
回答by Avram
This still works with Xcode 4.3.2 from the AppStore - the version where everything is self-contained in an App bundle. As in the original hint, install Xcode 3.2.6 first* and then download Xcode 4 from the AppStore. Then do the following symlink magic:
这仍然适用于来自 AppStore 的 Xcode 4.3.2——所有内容都独立于应用程序包中的版本。与原始提示一样,首先安装 Xcode 3.2.6*,然后从 AppStore 下载 Xcode 4。然后执行以下符号链接魔术:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
ln -s /Developer/Xcode3.2.6/SDKs/MacOSX10.5.sdk .
cd /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/
ln -s /Developer/Xcode3.2.5/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g* .
mv powerpc-apple-darwin10-llvm-gcc-4.2 powerpc-apple-darwin11-llvm-gcc-4.2
mv powerpc-apple-darwin10-llvm-g++-4.2 powerpc-apple-darwin11-llvm-g++-4.2
The last two lines rename darwin10 to darwin11 in the symlink - I'm guessing future versions of OS X will require this to be updated as appropriate.
最后两行在符号链接中将 darwin10 重命名为 darwin11 - 我猜未来的 OS X 版本将需要适当地更新它。
To install Xcode 3.2.x on Lion, mount the Xcode disk image, open Terminal, enter the commands (using bash, or the equivalent commands if you've changed your default shell):
export COMMAND_LINE_INSTALL=1 open "/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg"
要在 Lion 上安装 Xcode 3.2.x,请挂载 Xcode 磁盘映像,打开终端,输入命令(如果您更改了默认 shell,则使用 bash 或等效命令):
export COMMAND_LINE_INSTALL=1 打开“/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg”
You'll also need to set the clock back to a date prior to 31st March 2012 otherwise security certificates will fail validation during installation. You can safely change the date back again after installation obviously!
您还需要将时钟设置回 2012 年 3 月 31 日之前的日期,否则在安装过程中安全证书将无法通过验证。显然,您可以在安装后安全地再次更改日期!
回答by Aidan
Frédéric Devernay has a GitHub project called xcodelegacywhich works fantastic for me on Xcode 5.1.1, and needs very little work to get it going, just some downloading.
Frédéric Devernay 有一个名为xcodelegacy的 GitHub 项目,它在 Xcode 5.1.1 上对我来说非常棒,而且只需很少的工作就可以运行,只需要下载一些。
Using his project, I've managed to create universal binaries containing both ppc and i386 architectures compiled with the 10.4 SDK using GCC 4.0, all from within Xcode 5.1.1 running on Yosemite.
使用他的项目,我设法创建了通用二进制文件,其中包含使用 GCC 4.0 使用 10.4 SDK 编译的 ppc 和 i386 架构,所有这些都来自在 Yosemite 上运行的 Xcode 5.1.1。
I've verified myself that the universal binaries created work fine on 10.5 Leopard and on Yosemite itself.
我已经证实,通用二进制文件在 10.5 Leopard 和 Yosemite 本身上都可以正常工作。
Home page here: http://devernay.free.fr/hacks/xcodelegacy
主页在这里:http: //devernay.free.fr/hacks/xcodelegacy
Git hub project here: https://github.com/devernay/xcodelegacy
这里的 Git 中心项目:https: //github.com/devernay/xcodelegacy
回答by Stephen Chu
In case someone need to restore old SDKs and PPC compiler in Xcode 4.3 and 4.5, this is a script I came up with. Note you need to set the path to the Xcode app bundle and path to Xcode 3.2.6 install at the beginning of the script.
如果有人需要在 Xcode 4.3 和 4.5 中恢复旧的 SDK 和 PPC 编译器,这是我想出的脚本。请注意,您需要在脚本开头设置 Xcode 应用程序包的路径和 Xcode 3.2.6 安装的路径。
#!/bin/bash
XCODE="/Applications/Xcode45-DP1.app"
XCODE3="/Xcode3"
# restore SDKs
cd "$XCODE/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
sudo ln -s "$XCODE3/SDKs/MacOSX10.4u.sdk" .
sudo ln -s "$XCODE3/SDKs/MacOSX10.5.sdk" .
sudo ln -s "$XCODE3/SDKs/MacOSX10.6.sdk" .
# restore gcc 4.0
cd "$XCODE/Contents/Developer/usr/bin"
sudo ln -s "$XCODE3/usr/bin/"*4.0* .
sudo ln -s "powerpc-apple-darwin10-g++-4.0.1" "powerpc-apple-darwin11-g++-4.0.1"
sudo ln -s "powerpc-apple-darwin10-gcc-4.0.1" "powerpc-apple-darwin11-gcc-4.0.1"
# restore Xcode option
cd "$XCODE/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins"
sudo ln -s "$XCODE3/Library/Xcode/Plug-ins/GCC 4.0.xcplugin" .
You don't need to symlink 10.6 SDK if you are using Xcode 4.3 since it comes with one.
如果您使用的是 Xcode 4.3,则不需要符号链接 10.6 SDK,因为它带有一个。
Also the script does not restore gcc 4.2 since there are a lot of filename conflicts doing that. My goal is to restore PPC compiler and 4.0 is good enough for me.
此外,该脚本不会恢复 gcc 4.2,因为这样做会发生很多文件名冲突。我的目标是恢复 PPC 编译器,4.0 对我来说已经足够了。
回答by Jason Kenney
It would be useful to have a package to just install these files into an XCode 4 implementation. (or a tarball).
有一个包来将这些文件安装到 XCode 4 实现中会很有用。(或 tarball)。
FYI: 3.2.6 of Xcode3 does not include an as with ppc architecture. But I had a backup of Leopard on my computer. So I copied that one, seems to work. (Use /usr/libexec/gcc/darwin/ppc/as ).
仅供参考:Xcode3 的 3.2.6 不包含 ppc 架构。但是我的电脑上有 Leopard 的备份。所以我复制了那个,似乎有效。(使用 /usr/libexec/gcc/darwin/ppc/as )。
Considering that both gcc and as are open source the only stuff that may not be redistributable is the xcode plugin and the 10.4 SDK right?
考虑到 gcc 和 as 都是开源的,唯一不能再分发的东西是 xcode 插件和 10.4 SDK,对吗?