xcode CFURLCopyResourcePropertyForKey 失败,因为它传递了这个没有方案的 URL:

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

CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme:

xcodemacosgitcommand-lineterminal

提问by phil88530

I understand this is an xcode warning/error, however, it happens when I try to run gitk --allfrom the command line.

我知道这是一个 xcode 警告/错误,但是,当我尝试从命令行运行时会发生这种情况gitk --all

YuFei-Zhus-MacBook-Pro:test phil88530$ gitk --all
2012-08-02 21:14:49.246 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: 
2012-08-02 21:14:49.252 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: 
2012-08-02 21:14:49.293 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: 
2012-08-02 21:14:49.295 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: 
2012-08-02 21:14:49.474 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: 
2012-08-02 21:14:49.476 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: 
2012-08-02 21:14:50.731 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: 
2012-08-02 21:14:50.734 Wish[33464:707] CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme: 
YuFei-Zhus-MacBook-Pro:test phil88530$ 

I just replaced a new disk and did a fresh install of osx and updated to mountain lion, installed x11 and xcode. Any suggestions why this happens?

我刚刚更换了一个新磁盘并重新安装了 osx 并更新为山狮,安装了 x11 和 xcode。任何建议为什么会发生这种情况?

采纳答案by phil88530

alias gk='gitk --all 2> /dev/null &' (I am on mac)

别名 gk='gitk --all 2> /dev/null &' (我在 mac 上)

I have it in the ~/.bash_login file, and it solves it :D

我在 ~/.bash_login 文件中有它,它解决了它:D

you can also put it the .bashrc file

你也可以把它放在 .bashrc 文件中

回答by Seiichi Yonezawa

$ alias gitk='gitk 2>/dev/null'

I have same problem here. This is quick tip until someone answers this solution.

我这里有同样的问题。这是快速提示,直到有人回答此解决方案。

回答by Tair

If you are MacPorts user upgrade tcl/tk to 8.6.0:

如果您是 MacPorts 用户,请将 tcl/tk 升级到 8.6.0:

$ sudo port install tcl tk

回答by mon4goos

Running gitk with a new version of tcl-tk seems to solve this problem (tested with Mac OS X 10.8.4). If you have Homebrew installed, the following should work:

用新版本的 tcl-tk 运行 gitk 似乎解决了这个问题(用 Mac OS X 10.8.4 测试)。如果您安装了 Homebrew,以下应该可以工作:

  1. From the command line, run: brew install tcl-tk
  2. Then add the following to your .bashrc or .bash_profile: alias gitk='"$(brew --prefix tcl-tk)/bin/wish" "$(which gitk)"'
  1. 从命令行运行: brew install tcl-tk
  2. 然后将以下内容添加到您的 .bashrc 或 .bash_profile 中: alias gitk='"$(brew --prefix tcl-tk)/bin/wish" "$(which gitk)"'

After restarting your terminal, you should be able to run gitk normally without seeing any "CFURLCopyResourcePropertyForKey" errors.

重新启动终端后,您应该能够正常运行 gitk 而不会看到任何“CFURLCopyResourcePropertyForKey”错误。

回答by Itachi

I got this error just now and find a solution to solve it.

我刚刚收到此错误并找到解决方案。

I was trying to invoke the function getResourceValue:forKey:error: in my project and my os version is 10.7.5.

我试图在我的项目中调用函数 getResourceValue:forKey:error: 并且我的操作系统版本是 10.7.5。

I init a new NSURL object by using + URLWithString: and the problem occurred before, after I replace it with + fileURLWithPath:, it's ok now.

我通过使用 + URLWithString: 初始化了一个新的 NSURL 对象,之前出现了问题,在我将其替换为 + fileURLWithPath: 之后,现在就可以了。

The difference value between the two objects with different functions is /Volumes/Data/a file://localhost/Volumes/Data/a/

两个不同功能的对象的差值是/Volumes/Data/a file://localhost/Volumes/Data/a/

Apple has statemented that about NSURL class below,

Apple 在下面声明了关于 NSURL 类,

Handling Object Creation Failure The NSURL class fails to create a new NSURL object if the path being passed is not well-formed; the path must comply with RFC 2396. Examples of cases that will not succeed are strings containing space characters and high-bit characters. Should creating an NSURL object fail, the creation methods return nil, which you must be prepared to handle. If you are creating NSURL objects using file system paths, you should use fileURLWithPath: or initFileURLWithPath:, which handle the subtle differences between URL paths and file system paths. If you wish to be tolerant of malformed path strings, you'll need to use functions provided by the Core Foundation framework to clean up the strings.

处理对象创建失败 如果传递的路径格式不正确,NSURL 类将无法创建新的 NSURL 对象;路径必须符合 RFC 2396。不成功的例子是包含空格字符和高位字符的字符串。如果创建 NSURL 对象失败,创建方法将返回 nil,您必须准备好处理。如果您使用文件系统路径创建 NSURL 对象,您应该使用 fileURLWithPath: 或 initFileURLWithPath:,它们处理 URL 路径和文件系统路径之间的细微差别。如果您希望容忍格式错误的路径字符串,则需要使用 Core Foundation 框架提供的函数来清理字符串。

Error while using getResourceValue:forKey method in NSURL

在 NSURL 中使用 getResourceValue:forKey 方法时出错

回答by Alric

On Mountain Lion 10.8.2, I fixed this issue installing/upgrading tcl and tk – as tair mentioned.

在 Mountain Lion 10.8.2 上,我修复了安装/升级 tcl 和 tk 的问题——正如 tair 提到的。

brew install tcl
brew install tk

酿造安装tcl
酿造安装tk

The UI of gitk will likely change, but you can tweak that in ~/.gitk.

gitk 的 UI 可能会改变,但你可以在 ~/.gitk 中调整它。

回答by dule

This blog post solved my issue for this:

这篇博文解决了我的问题:

http://blog.jasonsemko.com/post/51668282398/easy-fix-for-cfurlcopyresourcepropertyforkey-failed

http://blog.jasonsemko.com/post/51668282398/easy-fix-for-cfurlcopyresourcepropertyforkey-failed

The long and short of it is gitkisn't parsing the version string of git that comes with Xcode correctly, and is puking on the extra details.

总而言之,它gitk没有正确解析 Xcode 附带的 git 版本字符串,而是在额外的细节上呕吐。

So to fix, you can install a git with a clean version number.

因此,要修复,您可以安装一个带有干净版本号的 git。

brew install git

brew install git

You may need to make sure brew's version of git gets called by changing the order directories gets searched in your PATH(e.g., I had to load /usr/bin/localbefore /usr/bin). Alternatively, you can alias git to the absolute path installed by brew.

您可能需要通过更改在您的目录中搜索的顺序来确保调用 brew 的 git 版本PATH(例如,我必须在/usr/bin/local之前加载/usr/bin)。或者,您可以将 git 别名为 brew 安装的绝对路径。