离子 v2 : "You cannot run cocoapods as root"错误



我正在尝试在iOS中构建一个带有推送通知的Ionic 2应用程序。

我使用此命令行添加了Phonegap插件推送通知:

cordova plugin add phonegap-plugin-push --variable SENDER_ID=12341234 --save 

但是当我尝试在设备中运行我的项目时,我在 xcode 中出现此错误:

"GoogleCloudMessaging.h" file not found

我寻找了一个解决方案,我安装了Cocoapods。我删除了平台iOS,并尝试使用此命令行添加它:

sudo ionic platform add ios

我有这个错误:

Installing "phonegap-plugin-push" for ios
Failed to install 'phonegap-plugin-push':undefined
Error: /Library/Ruby/Gems/2.0.0/gems/claide-1.0.2/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
Usage:
$ pod COMMAND
CocoaPods, the Cocoa library package manager.
Commands:
+ cache      Manipulate the CocoaPods cache
+ env        Display pod environment
+ init       Generate a Podfile for the current directory
+ install    Install project dependencies according to versions from a
Podfile.lock
+ ipc        Inter-process communication
+ lib        Develop pods
+ list       List pods
+ outdated   Show outdated project dependencies
+ repo       Manage spec-repositories
+ setup      Setup the CocoaPods environment
+ spec       Manage pod specs
+ update     Update outdated project dependencies and create new Podfile.lock
Options:
--silent     Show nothing
--version    Show the version of the tool
--verbose    Show more debugging information
--no-ansi    Show output without ANSI codes
--help       Show help banner of specified command
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.1/lib/cocoapods/command.rb:47:in `run'
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.1/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'

我尝试直接在平台/ios文件夹中运行" pod安装",但同样的问题。

所以我尝试在命令中删除 sudo:

ionic platform add ios

但显然我有这个错误:

MacBook-Air-de-user:MyApp compagny$ ionic platform add ios
Error during untar for /Users/user/.cordova/lib/npm_cache/cordova-ios/4.3.1/package.tgz: Error: EACCES: permission denied, open '/Users/user/.cordova/lib/npm_cache/cordova-ios/4.3.1/package/package.json'

Error: Failed to fetch platform ios
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: EACCES: permission denied, open '/Users/user/.cordova/lib/npm_cache/cordova-ios/4.3.1/package/package.json'

真的不知道我该怎么做才能解决这个问题。一个想法 ?

尝试更新科尔多瓦版本,删除平台并再次添加:

npm install -g cordova
cordova platform remove android
cordova platform remove ios
cordova platform add android
cordova platform add ios
cordova plugin add phonegap-plugin-push --save

我有同样的问题,它对我有用。

如果有人仍然遇到问题,我通过运行让它工作

pod install

在平台/iOS 中 在此之前,您可能需要在该文件夹中添加权限

sudo chown -R *username* platforms/ios

要在不使用 sudo 的情况下允许在 mac 上执行代码,只需运行即可。

sudo chown -R Username /Users/username/Document/project location

它对我有用

如果您使用任何插件和平台添加,请在没有的情况下安装和添加 "须藤"。

如果需要权限,他们转到项目目录并单击setting->Get Info授予"读写"权限,那么您可以在没有"sudo"的情况下安装插件和平台

ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated@7.5.0

ionic cordova build ios --prod

相关内容

  • 没有找到相关文章

最新更新