【问题标题】:Ionic 3 project cannot be built for ios after installing OneSignal plugin安装 OneSignal 插件后无法为 ios 构建 Ionic 3 项目
【发布时间】:2017-06-02 16:17:53
【问题描述】:

我创建了一个新项目并安装了 OneSignal 插件。

sudo ionic cordova plugin add onesignal-cordova-plugin

sudo npm install --save @ionic-native/onesignal


之后我为 Android 构建还可以,但我为 iOS 构建。

sudo ionic cordova build ios


它给了我这样的信息 -->

    Lolzzs-MacBook-Pro:myOnesignal lolzzlolzz$ sudo ionic cordova build ios
> cordova platform add --save ios
✖ Running command - failed!
[ERROR] An error occurred while running cordova platform add --save ios (exit code 1):

        Using cordova-fetch for cordova-ios@~4.4.0
        Adding ios project...
        Creating Cordova project for the iOS platform:
                Path: platforms/ios
                Package: io.ionic.starter
                Name: MyApp
        iOS project created with cordova-ios@4.4.0
        Installing "cordova-plugin-console" for ios
        Installing "cordova-plugin-device" for ios
        Installing "cordova-plugin-splashscreen" for ios
        Installing "cordova-plugin-statusbar" for ios
        Installing "cordova-plugin-whitelist" for ios
        Installing "ionic-plugin-keyboard" for ios
        Installing "onesignal-cordova-plugin" for ios
        Failed to install 'onesignal-cordova-plugin': undefined
        Error: /usr/local/lib/ruby/gems/2.4.0/gems/claide-1.0.1/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 /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.2.1/lib/cocoapods/comma
nd.rb:47:in `run'
                from /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.2.1/bin/pod:55:in `<top
 (required)>'
                from /usr/local/bin/pod:22:in `load'
                from /usr/local/bin/pod:22:in `<main>'

【问题讨论】:

  • 为什么要使用 sudo 构建?我认为在这种情况下错误很明显:You cannot run CocoaPods as root
  • 你也不应该使用 sudo 来安装插件
  • @tier1 我使用的是 Mac,我放了 sudo 以避免权限被拒绝,但我会在没有 sudo 的情况下再试一次,谢谢,我会再次测试:-D
  • @KampongChamUser 面临同样的问题。告诉我你是怎么解决的

标签: cordova ionic-framework plugins onesignal ionic3


【解决方案1】:

经过很长时间尝试使用 oneSignal 构建我的项目时出现完全相同的错误

我看到一个指令去平台/ios 并运行:

sudo gem install cocoapods

pod install --repo-update

效果很好

【讨论】:

    【解决方案2】:

    删除你的 node_module、平台和插件

    删除 package-lock.json,

    npm install --- don't use sudo

    然后在 buildflag 中使用 allow from root 标志执行添加平台

    ionic cordova platform add ios --buildflag="--allow-root"

    然后

    ionic cordova build ios

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-23
      • 2019-09-29
      • 1970-01-01
      • 2015-11-15
      • 1970-01-01
      • 2022-12-03
      • 2021-11-02
      相关资源
      最近更新 更多