输入“sudo gem install cocoapods”命令安装cocoapods时出现“Operation not permitted - /usr/bin/xcodeproj” 异常,具体错误如下所示。
�sinfordeMini:~ sinfor$ sudo gem install cocoapods Password: Fetching: cocoapods-core-1.3.1.gem (100%) Successfully installed cocoapods-core-1.3.1 Fetching: claide-1.0.2.gem (100%) Successfully installed claide-1.0.2 Fetching: netrc-0.11.0.gem (100%) Successfully installed netrc-0.11.0 Fetching: cocoapods-trunk-1.3.0.gem (100%) Successfully installed cocoapods-trunk-1.3.0 Fetching: molinillo-0.5.7.gem (100%) Successfully installed molinillo-0.5.7 Fetching: colored2-3.1.2.gem (100%) Successfully installed colored2-3.1.2 Fetching: xcodeproj-1.5.3.gem (100%) ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj�
该如何解决“Operation not permitted - /usr/bin/xcodeproj”异常呢?
解决方案一:因为我们的mac电脑有系统集成保护,这是osx系统防止恶意程序的最后一道防线,因此我们需要关闭rootless即可,具体关闭方法可以看简书网友的文章:http://www.jianshu.com/p/23c01067cf7e,关闭rootless之后再运行sudo gem install cocoapods命令即可正常安装cocoapods软件了。
解决方案二:将cocoapods安装在别的文件夹下,如/usr/local/bin目录,运行sudo gem install -n /usr/local/bin cocoapods命令即可正常安装,如下:
sinfordeMini:~ sinfor$ sudo gem install -n /usr/local/bin cocoapods Successfully installed xcodeproj-1.5.3 Fetching: ruby-macho-1.1.0.gem (100%) Successfully installed ruby-macho-1.1.0 Fetching: cocoapods-1.3.1.gem (100%) Successfully installed cocoapods-1.3.1 Parsing documentation for xcodeproj-1.5.3 Installing ri documentation for xcodeproj-1.5.3 Parsing documentation for ruby-macho-1.1.0 Installing ri documentation for ruby-macho-1.1.0 Parsing documentation for cocoapods-1.3.1 Installing ri documentation for cocoapods-1.3.1 3 gems installed
这样就不会再报“Operation not permitted - /usr/bin/xcodeproj”异常了。