cocoapods安装回顾:上一篇讲cocoapods安装失败的最大原因主要又3个,ssl证书过期,ruby环境版本太低,没有rvm环境,解决上面问题后就能成功安装cocoapods(安装教程:https://blog.csdn.net/qq_29848853/article/details/129340315)
安装可视化插件前提:cocoapods包管理环境已成功安装,并且项目Podfile文件三方依赖可以正常安装更新
cocoapods安装补充:如果xcode移动了位置,cocoapod可能会找不到路径就无法使用,这时候需要重新指令切换xcode路径,xcode-select --switch /Applications/Xcode.app。pod search afnetworking会重新恢复正常
1,打开命令终端,输入安装Alcatraz的命令
sudo curl -fsSL https://raw.githubusercontent.com/supermarin/Alcatraz/deploy/Scripts/install.sh | sh
问题:访问443失败
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
2,通过修改hosts解决上面此问题
打开hosts:
sudo vim /etc/hosts
添加加速后的域名网站:
185.199.108.133 raw.githubusercontent.com
加速域名查询方法:
打开https://www.ipaddress.com/,查询域名raw.githubusercontent.com,记录对应的ip地址。
编辑,保存并退出:
点击键盘i进入编辑模式,复制域名后,点击Esc并输入:wq保存并退出编辑模式
3,再次输入安装Alcatraz命令
sudo curl -fsSL https://raw.githubusercontent.com/supermarin/Alcatraz/deploy/Scripts/install.sh | sh
问题:xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH
192:~
4,可以通过设置Xcode
中Command Line Tools
来解决这个问题
打开Xcode--Preferences--Locations,在command line tools中选择相应的版本
5,再次输入安装Alcatraz命令
sudo curl -fsSL https://raw.githubusercontent.com/supermarin/Alcatraz/deploy/Scripts/install.sh | sh
结果:还是失败
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:22 --:--:-- 0
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
6,好吧,还是不行,那就离线安装吧,哈哈
Alcatraz github下载地址:GitHub - alcatraz/Alcatraz: Package manager for Xcode,下载后在xcode中打开,编译,然后重启Xcode即可
问题:xcode打开后window下不显示Package Manager,或Xcode升级后打开Xcode会提示load bundle或Skip bundle
原因:Xcode插件失效并不是升级或重装后原本的插件被删掉了,其实插件还在这个目录~/Library/Application Support/Developer/Shared/Xcode/Plug-ins 。之所以插件失效,是因为每个插件只供特定UUID的Xcode使用,更新后uuid改变,于是便不能正常使用
7,查看当前Xcode的uuid,并修改插件的uuid为当前Xcode的uuid
在终端执行获取默认UUID指令:
defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
结果:可能你的Xcode不是你安装的,而是直接拷贝别人安装好的Xcode到你的应用程序中,那么这个命令得不到Xcode的uuid
The domain/default pair of (/Applications/Xcode.app/Contents/Info, DVTPlugInCompatibilityUUID) does not exist
8,在xcode应用目录查找默认UUID
获取xcode的默认UUID:
或者在应用程序中找到Xcode,右键选择显示包内容,找到Info.plist文件打开找到DVTPlugInCompatibilityUUID对应的值就是我们要的uuid
DVTPlugInCompatibilityUUID:BAB79788-ACEE-4291-826B-EC4667A6BEC5
查找插件的DVTPlugInCompatibilityUUIDs,把xcode的uuid添加到插件的uuid里面:
打开访达,按住Shift+option(windows)组合键,调出文件查找输入框,输入 ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins右键显示包内容,找到Info.plist文件打开找到DVTPlugInCompatibilityUUIDs的项目,添加一个Item,Value的值为之前Xcode的UUID,保存
重启 Xcode:
重启 Xcode 之后会提示”Load bundle”、 “Skip Bundle”,这里必须选择”Load bundle”,不然插件无法使用。如果又不小心点了Skip Bundle,那就删掉你刚才在插件plist文件里添加的那行Item,然后重启Xcode,然后再重新刚才的那几步。
9,移除插件和清除插件缓存,重新安装离线插件
rm -rf ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin
rm -rf ~/Library/Application\ Support/Alcatraz/
Alcatraz github下载地址:GitHub - alcatraz/Alcatraz: Package manager for Xcode
10,安装cocoapods插件
可以通过Alcatraz插件管理器安装
11,总结:远程安装安装Alcatraz插件管理器和cocoapods插件还是比较困难的,主要网络访问老是失败,要翻墙可能会成功,所以可以直接离线安装,从github网站下载离线包。
本地安装步骤主要如下:
下载压缩到本地 ---- 解压压缩包 --- 直接运行xcode项目 --- 编译成功关闭xcode --- 重新打开xcode弹出“Load bundle”框 --- 加载后可以在window下找到Package Manager --- 在Project下找到cocoapods插件
注意:安装成功后,可能只会显示一次,下次打开xcode插件栏目又会消失,这时候需要添加xcode的UUID到插件的DVTPlugInCompatibilityUUID里面,添加UUID步骤已在上面说明,可以按上面操作
12,下一章我们讲cocoapods插件的使用,更新和管理远程依赖库