Ionic v2:“你不能以 root 身份运行 cocoapods"错误

时间:2023-01-31
本文介绍了Ionic v2:“你不能以 root 身份运行 cocoapods"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

I'm trying to build an Ionic 2 app with push notification in iOS.

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

I added Phonegap plugin push notification with this command line :

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

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

But when I try to run my project in a device I have this error in xcode :

"GoogleCloudMessaging.h" file not found

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

I looked for a solution and I had install Cocoapods. I removed platform iOS and I try to add it with this command line :

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 install",但同样的问题.

I tried to run "pod install" directly in platforms/ios folder, but same issue.

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

So I try to remove sudo in the commande :

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'

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

推荐答案

尝试更新 Cordova 版本,删除平台并重新添加:

Try update Cordova version, remove platforms and add again:

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

我遇到了同样的问题,它对我有用.

I had the same problem and its worked for me.

这篇关于Ionic v2:“你不能以 root 身份运行 cocoapods"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:离子 - svg 不出现 下一篇:如何为安卓开发软键盘?

相关文章

最新文章