iOS: Xcode7安装KSImageNamed插件,自动读取图片名称

时间:2022-12-12 14:45:37

官方文档:

## How do I use it?    

Build the KSImageNamed target in the Xcode project and the plug-in will automatically be installed in `~/Library/Developer/Xcode/Plug-ins`. Relaunch Xcode and `imageNamed:` will magically start autocompleting your images.

翻译如下:

## 我如何去使用这个插件?

编译ksimagenamed目标在Xcode项目,之后插件会自动被安装在`~/Library/Developer/Xcode/Plug-ins`上。重新启动Xcode,此时` imagenamed:`会奇迹般地开始自动加载你需要的对应名称的图片。

 

**Important**: Old versions of KSImageNamed were installed in `~/Library/Developer/Application Support/Developer/Shared/Xcode/Plug-ins`. Make sure to remove `KSImageNamed.xcplugin` from there before installing the new one.

翻译如下:

*重要点*:老版本的ksimagenamed被安装在`~/Library/Developer/Application Support/Developer/Shared/Xcode/Plug-ins上。确保去除旧版本的` ksimagenamed.xcplugin `,然后在同一地方再安装新的‘ksimagenamed.xcplugin `。

 

## How do I include file extensions when autocompleting?

Enter the following command and relaunch Xcode:
`defaults write com.apple.dt.Xcode KSShowExtensionInImageCompletion -bool YES`

翻译如下:

## 我如何去使用这个插件?

当自动加载图片时,我怎么引入包含文件的扩展名?

输入以下命令并重新启动Xcode

`defaults write com.apple.dt.Xcode KSShowExtensionInImageCompletion -bool YES`

 

以上是官方文档
在第一次安装的时候切记在跳出bundle选择的时候选择load bundle,不然会安装失败,这样的话,解决方法如下:
官方文档中说安装地址在~/Library/Developer/Application Support/Developer/Shared/Xcode/Plug-ins,但我的安装地址是在~/Library/Developer/Xcode/Plug-ins(安装的时候选择的吧,给忘了),rm -rf 删除那个KSImageNamed.xcplugin文档,然后命令行敲入`defaults write com.apple.dt.Xcode KSShowExtensionInImageCompletion -bool NO`注意是NO,然后重新安装就可以了,别忘记load bundle!

如果曾经安装过,那么就先删除那个插件(过程如上),再`defaults write com.apple.dt.Xcode KSShowExtensionInImageCompletion -bool NO`,ok,重新来过

就是这样

 

插件在Github的下载地址:https://github.com/ksuther/KSImageNamed-Xcode