为什么我的 Xcode 插件(例如 clang 格式)在更新到新版本的 Xcode 后不再工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30361228/
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
Why are my Xcode plugins (such as clang format) installed with Alcatraz no longer working after updating to new version of Xcode?
提问by Pavel Smejkal
Today I updated to Xcode 6.3.2 and I can't run the Clang code formatting – it seems like it's not even installed. Everytime I update Xcode, I have to reinstall Alcatraz and most of the packages (why btw?) to make them work on the new version of Xcode.
今天我更新到 Xcode 6.3.2 并且我无法运行 Clang 代码格式——它似乎甚至没有安装。每次更新 Xcode 时,我都必须重新安装 Alcatraz 和大多数软件包(为什么顺便说一句?)以使它们在新版本的 Xcode 上工作。
This time I reinstalled all packages (like VVDocumenter, Color picker, etc), but the ClangFormat doesn't work – it doesn't even appear in the "Edit" menu. Any idea why?
这次我重新安装了所有软件包(如 VVDocumenter、Color Picker 等),但是 ClangFormat 不起作用——它甚至没有出现在“编辑”菜单中。知道为什么吗?
btw. I tried to restart Xcode as well as the Mac itself :)
顺便提一句。我尝试重新启动 Xcode 以及 Mac 本身:)
EDIT (Solution):
编辑(解决方案):
Solution for Xcode 6.3.x (If this does not work, use the general solution below.)
Xcode 6.3.x 的解决方案(如果这不起作用,请使用下面的通用解决方案。)
In terminal, enter the following:
在终端中,输入以下内容:
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add 9F75337B-21B4-4ADC-B558-F9CADF7073A7
General solution
通用解决方案
Get the new UUID via the terminal:
通过终端获取新的 UUID:
defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
Add the new UUID to the DVTPlugInCompatibilityUUIDs key in the plugin (your xcplugin file --> show package contents --> Contents/Info.plist
将新的 UUID 添加到插件中的 DVTPlugInCompatibilityUUIDs 键(您的 xcplugin 文件 --> 显示包内容 --> Contents/Info.plist
采纳答案by vomako
Oftentimes, the following helps: Re-install Alcatraz, restart Xcode, de-install and re-install your plugin. Sometimes it helps to restart Xcode again. This worked for me.
通常,以下方法会有所帮助:重新安装 Alcatraz,重新启动 Xcode,卸载并重新安装您的插件。有时它有助于再次重新启动 Xcode。这对我有用。
If your plugin still does not show up, the problem is probably that the the compatibility key of your new Xcode is not yet included in the list of compatibility keys of your plugin.
如果您的插件仍然没有显示,问题可能是您的新 Xcode 的兼容性密钥尚未包含在您的插件的兼容性密钥列表中。
Possible solutions:
可能的解决方案:
- Wait for an update of the plugin that includes the new UUID of Xcode
- If you do not want to wait (for example, if you installed a beta of Xcode and it would take too long for the plugins to be updated), you may manually add the new UUID of Xcode to the plugin (details on how to do this see below). Of course, there is no guarantee that your plugin will work then. If Xcode has changed so that it is really not compatible anymore, it will, of course, not work. However, oftentimes it will work.
- 等待包含 Xcode 新 UUID 的插件更新
- 如果您不想等待(例如,如果您安装了 Xcode 的测试版,并且插件更新时间太长),您可以手动将 Xcode 的新 UUID 添加到插件中(详细说明如何做这见下文)。当然,不能保证您的插件届时会正常工作。如果 Xcode 发生了变化,以至于它真的不再兼容,那么它当然不会工作。但是,通常它会起作用。
To add the new UUID to the plugin:
要将新的 UUID 添加到插件:
In terminal, enter the following if you use Xcode 6.3.2:
如果您使用 Xcode 6.3.2,请在终端中输入以下内容:
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add E969541F-E6F9-4D25-8158-72DC3545A6C6
For other versions of Xcode, get the UUID of Xcode via the terminal: defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
and use it to update the UUID in the find
command above.
对于其他版本的 Xcode,通过终端获取 Xcode 的 UUID:defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
并在find
上面的命令中使用它来更新 UUID 。
[Instead of using the find
command above, you may also manually add the new UUID to the DVTPlugInCompatibilityUUIDs
key in the plugin package (your xcplugin
file --> show package contents --> Contents/Info.plist
)]
[除了使用find
上面的命令,您也可以手动将新的 UUID 添加到DVTPlugInCompatibilityUUIDs
插件包中的键中(您的xcplugin
文件 --> 显示包内容 --> Contents/Info.plist
)]
Sources: GitHuband post by "ianmasters"
来源:GitHub和“ ianmasters”的帖子
回答by wenghengcong
After install Xcode 6.4, I choose "Skip Bundles",I can't find Alcatraz.
安装 Xcode 6.4 后,我选择“Skip Bundles”,我找不到 Alcatraz。
Fisrt I try the add UUID,but Alcatraz also no working;
首先我尝试添加 UUID,但 Alcatraz 也不起作用;
Then try this:
然后试试这个:
defaults read com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-6.4
In iTerm show below:
在 iTerm 中显示如下:
allowed = {
};
skipped = {
"com.mneorr.Alcatraz" = {
version = 1;
};
};
but this file can't edit,so delete:
但是这个文件不能编辑,所以删除:
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-6.4
Next,I reinstall Alcatraz,Xcode show “Load Bundles" again,this time I will not make wrong,choose "Load Bundles".
接下来,我重新安装 Alcatraz,Xcode 再次显示“Load Bundles”,这次我不会出错,选择“Load Bundles”。
回答by Maciej Gad
You could use this script to update your Xcode's plugin after update (works fine with Xcode 7.3):
您可以使用此脚本在更新后更新您的 Xcode 插件(适用于 Xcode 7.3):
#!/bin/bash
xcodeUUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
echo $xcodeUUID
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add $xcodeUUID
or copy from my gist https://gist.github.com/MaciejGad/86302b6b8bdb1ee25115
或从我的要点https://gist.github.com/MaciejGad/86302b6b8bdb1ee25115复制
回答by Elviin Goomez
It turns out, Xcode now has a whitelist / blacklist of bundles you enable. You can check it from the Terminal by running:
事实证明,Xcode 现在有一个你启用的包的白名单/黑名单。您可以通过运行从终端检查它:
$ defaults read com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-6.3.2
{
allowed = {
};
skipped = {
"com.mneorr.Alcatraz" = {
version = 1;
};
"com.onevcat.VVDocumenter-Xcode" = {
version = 1;
};
"com.travisjeffery.ClangFormat" = {
version = 1;
};
};}
The bad news is that the prompt to load the bundles won't show again, even if you reinstall Alcatraz. The fix is simple though, just delete the whitelist / blacklist by running:
坏消息是,即使您重新安装 Alcatraz,加载包的提示也不会再次显示。修复很简单,只需通过运行删除白名单/黑名单:
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-6.3.2
and re-open Xcode to be prompted again (and this time make sure you click “Load Bundles”).
并重新打开 Xcode 以再次收到提示(这次确保您单击“加载捆绑包”)。
Orignal post here: Re-enable Alcatraz on Xcode 6.3.2 or newer
回答by ElonChan
Use the general code for "all version" of Xcode in terminal,then restart Xcode ,all will be right:
在终端中使用“所有版本”Xcode的通用代码,然后重新启动Xcode,一切都会正确:
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID
Please attention that the code have combined the code of other answers.
请注意代码已经结合了其他答案的代码。
If the version of your Xcode is 6.3.2,the code above is equal to
如果你的 Xcode 版本是 6.3.2,上面的代码就等于
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add E969541F-E6F9-4D25-8158-72DC3545A6C6
When your Xcode is 6.3 or 6.3.1 ,is equal to:
当您的 Xcode 为 6.3 或 6.3.1 时,等于:
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add 9F75337B-21B4-4ADC-B558-F9CADF7073A7
You can find that the difference is the code at the end,it's the uuid of Xcode,so we can get the new uuid of Xcode use this
可以发现区别在于最后的代码,是Xcode的uuid,所以我们可以使用这个来获取Xcode的新uuid
defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
and change it at the end of that code.
并在该代码的末尾更改它。
If this still not work,you may have not chosen "load bundle" in the alert of Alcatraz
如果这仍然不起作用,您可能没有在Alcatraz的警报中选择“加载包”
If you have chosen "skip bundle",you can do this
如果您选择了“跳过捆绑包”,则可以执行此操作
- reload Alcatraz
- the alert of Alcatrazwill appear again, choice load bundle
- use the code above in thermal
- reload Xcode
- successfully !!
EDIT:I've tried,just need to use the general code in terminal again,the alert will show again,choose it ,it'll be ok.
编辑:我试过了,只需要再次在终端中使用通用代码,警报将再次显示,选择它,就可以了。
回答by Zappel
This has worked for me since Xcode 6.3.2
这对我有用,因为 Xcode 6.3.2
http://pablin.org/2015/05/27/re-enable-alcatraz-on-xcode-6-dot-3-2-or-newer/
http://pablin.org/2015/05/27/re-enable-alcatraz-on-xcode-6-dot-3-2-or-newer/
回答by deksden
Plugin compatibility key did not work for 6.3.2 / 6.4.b2
插件兼容性密钥不适用于 6.3.2 / 6.4.b2
Let's look into this thread: https://github.com/omz/Dash-Plugin-for-Xcode/issues/37- they have an issue and solution.
让我们看看这个线程:https: //github.com/omz/Dash-Plugin-for-Xcode/issues/37- 他们有一个问题和解决方案。
General summary: XCode did change a way to load plugins (custom plugins loads first), so it is necessary to make some code changes.
一般总结:XCode 确实改变了加载插件的方式(自定义插件先加载),所以有必要做一些代码更改。
回答by smileBot
Try building from the source rather than installing using the curl command! For some reason nothing I did with the curl command worked for me including changing the UUID. So I deleted everything from the plugin folder and downloaded the master and did a build. Restart xCode and accept the dialog. Maybe this will help you.
尝试从源代码构建而不是使用 curl 命令安装!出于某种原因,我对 curl 命令所做的一切都没有对我有用,包括更改 UUID。所以我从插件文件夹中删除了所有内容并下载了主文件并进行了构建。重新启动 xCode 并接受对话框。也许这会帮助你。
回答by arsenius
This script both updates the UDIDs for your plugins and ensures that you are prompted to load bundles:
此脚本既更新插件的 UDID 又确保提示您加载包:
#!/bin/bash
xcodeUUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
echo $xcodeUUID
xcodeVersion=`defaults read /Applications/Xcode.app/Contents/Info.plist CFBundleShortVersionString`
echo $xcodeVersion
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add $xcodeUUID
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-$xcodeVersion