安装 Xcode 4.3 后无法获得 MacPort 功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9323738/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:14:32  来源:igfitidea点击:

Unable to get MacPort functionality after installing Xcode 4.3

xcodeosx-lionxcode4.3macports

提问by Jason

I am having trouble getting MacPorts to function properly. I just installed OSX Lion 10.7.3 I downloaded and installed MacPorts first, and then after reading the requirements, I downloaded Xcode4.3 from the App Store, and then installed it. I launched Xcode and it looks to be operational and functional. However when I attempted to port with MacPorts, it gave me this error message(excerpt):

我无法让 MacPorts 正常运行。我刚安装了OSX Lion 10.7.3 我先下载安装了MacPorts,然后看了需求,从App Store下载了Xcode4.3,然后安装了。我启动了 Xcode,它看起来可操作且功能正常。但是,当我尝试使用 MacPorts 进行移植时,它给了我以下错误消息(摘录):

Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.

I followed the advice from:

我遵循了以下建议:

How do i install additional packages for Xcode on OSX Lion to allow MacPorts to work

我如何在 OSX Lion 上为 Xcode 安装额外的软件包以允许 MacPorts 工作

and installed command_line_tools_for_xcode from the Preferences within Xcode. I closed Xcode, and again got the errors:

并从 Xcode 中的首选项安装 command_line_tools_for_xcode。我关闭了 Xcode,再次出现错误:

$ sudo port install libsocketsPassword:
Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
--->  Computing dependencies for libsockets
--->  Dependencies to be installed: openssl zlib
--->  Extracting zlib
Error: Couldn't determine your Xcode version (from '/usr/bin/xcodebuild -version').
Error: 
Error: If you have not installed Xcode, install it now; see:
Error: http://guide.macports.org/chunked/installing.xcode.html
Error: 
Error: Target org.macports.extract returned: unable to find Xcode
Error: Failed to install zlib
Log for zlib is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_zlib/zlib/main.log
Error: The following dependencies were not installed: openssl zlib
Error: Status 1 encountered during processing.

I am uncertain where to go next with this. How do i trouble shoot my Xcode and MacPort interface?

我不确定下一步该去哪里。如何解决我的 Xcode 和 MacPort 接口问题?

回答by geowar

In theory this should work if you have Xcode4.3 installed (in /Applications):

理论上,如果您安装了 Xcode4.3(在 /Applications 中),这应该可以工作:

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/

(And you've installed the optional command line tools)

(并且您已经安装了可选的命令行工具)

回答by Pavel Ferencz

Everything will start working fine after installation of "Command Line Tools for Xcode" package. You can get it from here: https://developer.apple.com/downloads/index.action#

安装“Xcode 命令行工具”包后,一切都会开始正常工作。你可以从这里得到它:https: //developer.apple.com/downloads/index.action#

回答by gmcnaughton

Please see the MacPorts migration instructions for Xcode 4.3.

请参阅Xcode 4.3MacPorts 迁移说明

The instructions are pretty involved. You need to run xcode-selectto set a new tools path, update developer_dirin macports.conf(as described by Henk Poley), re-install MacPorts (ouch), and finally uninstall and re-install all of your ports (double ouch).

说明相当复杂。您需要运行xcode-select设置一个新的工具路径,更新developer_dirmacports.conf(如由亨克Poley),重新安装的MacPorts(哎哟),最后卸载和重新安装所有的端口(双哎哟)。

Edit:libpvxstill wouldn't install after the above. Two extra steps were required:

编辑:libpvx在上述之后仍然不会安装。需要两个额外的步骤:

  1. sudo ln -s /Developer /
  2. sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs /SDKs
  1. sudo ln -s /Developer /
  2. sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs /SDKs

YMMV if you have different ports installed!

YMMV 如果您安装了不同的端口!

回答by Henk Poley

Also in /opt/local/etc/macports/macports.confchange the line with developer_dirto point to /instead of /Developer.

同样在/opt/local/etc/macports/macports.conf更改行developer_dir中指向/而不是/Developer

回答by Greg Allen

After

sudo xcode-select -switch /Applications/Xcode.app

I also had to run

我也不得不跑

sudo xcodebuild -license

and accept the licence

并接受许可

回答by Harish Narayanan

Here is a solution that has worked for me:

这是一个对我有用的解决方案:

  1. Install Command Line Tools for Xcode

    Xcode -> Preferences -> Downloads
    
  2. Help MacPorts find the right Xcode folder

    sudo /usr/bin/xcode-select -switch /Applications/Xcode.app
    
  3. Create symbolic links for clang compilers as they now live elsewhere

    sudo ln -s `which clang` /Applications/Xcode.app/Contents/Developer/usr/bin/
    sudo ln -s `which clang++` /Applications/Xcode.app/Contents/Developer/usr/bin/
    
  1. 为 Xcode 安装命令行工具

    Xcode -> Preferences -> Downloads
    
  2. 帮助 MacPorts 找到正确的 Xcode 文件夹

    sudo /usr/bin/xcode-select -switch /Applications/Xcode.app
    
  3. 为 clang 编译器创建符号链接,因为它们现在位于其他地方

    sudo ln -s `which clang` /Applications/Xcode.app/Contents/Developer/usr/bin/
    sudo ln -s `which clang++` /Applications/Xcode.app/Contents/Developer/usr/bin/
    

回答by Christoph Dwertmann

None of this works for me. Wait for macports to release a new version that officially supports XCode 4.3+

这些都不适合我。等待macports发布正式支持XCode 4.3+的新版本

回答by Pall Melsted

Setting the developer path in /opt/local/etc/macports.conf works for me,

在 /opt/local/etc/macports.conf 中设置开发人员路径对我有用,

developer_dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain

since most of the compilers are stored there now instead of /usr/bin under Developer.

因为现在大多数编译器都存储在那里而不是 Developer 下的 /usr/bin 。

回答by Clemens Lang

Try using trunk, there's no release supporting Xcode 4.3 yet.

尝试使用主干,尚无支持 Xcode 4.3 的版本。

回答by henryse

sudo mv /usr/bin/xcodebuild /usr/bin/xcodebuild.old
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild /usr/bin/xcodebuild