IONIC:Unable to install phonegap-plugin-push in ios app - ios

I am new with ionic framework.Currently i am working on ionic iOS app. when i install phonegap-plugin-push i am getting error
Failed to install 'phonegap-plugin-push':undefined Error: /Library/Ruby/Gems/2.0.0/gems/claide-1.0.1/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
i have searched it but no solution found yet!

I also got same kind of problem. In my case I used sudo ionic platform add ios
This is worked well while building every plugins but phonegap-plugin-push.
phonegap-plugin-push is keep giving above error [!] You cannot run CocoaPods as root. (CLAide::Help)
Then I used ionic platform add ios without sudo This is the actual solution for this. But in this case It is keep giving me the permission related issue code EACCESS.
Then I used followings step to overcome that one.
sudo chown -R $USER /usr/local/
Again added cordoava and ionic
sudo npm install -g cordova
sudo npm install -g ionic
Other informations
phonegap-plugin-push version: 1.10.0
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.2
Node Version: v7.7.2
Xocde Version: Xcode 8.2.1
CocoaPods Version: 1.2.0
Hope this will help.

Related

React-Native Bundle Error error SHA-1 for file is not computed

I am facing this error while creating bundle of react-native app.
I am executing command react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios
error SHA-1 for file /usr/local/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js (/usr/local/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js) is not computed. Run CLI with --verbose flag for more details.
ReferenceError: SHA-1 for file /usr/local/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js (/usr/local/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js) is not computed
at DependencyGraph.getSha1 (/usr/local/lib/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph.js:258:13)
at /usr/local/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:211:26
at Generator.next (<anonymous>)
at asyncGeneratorStep (/usr/local/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:46:24)
at _next (/usr/local/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:66:9)
at /usr/local/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:71:7
at new Promise (<anonymous>)
at /usr/local/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:63:12
at Transformer.transformFile (/usr/local/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:236:7)
at /usr/local/lib/node_modules/react-native/node_modules/metro/src/Bundler.js:87:34
react-native info command output
info Fetching system and libraries information...
System:
OS: macOS Mojave 10.14.3
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU # 2.30GHz
Memory: 1.73 GB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 23, 25, 26, 27, 28, 29
Build Tools: 27.0.3, 28.0.3
System Images: android-29 | Google Play Intel x86 Atom
Android NDK: 20.1.5948944
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
react-native: 0.61.5
To solve my issue I have run command with --force option.
npm install -i -g --force react-native-cli
This issue was raise due to configure old project with old react-native version. and then trying to run latest react-native ver with new Project.
install with npx
run
on windows 10
npx react-native run-android
on linux
npx react-native start
I resolved the issue in my Mac using
npx react-native start
For me, I installed the wrong package.
Instead of this:
npm i -g react-native
Make sure you do this:
npm i -g react-native-cli
I can't comment so use npm install -i -g --force react-native-cli as stated by Punita. It works when it comes to fixing the SHA-1 issue.
But please don't use sudo for any npm related things. thanks.
I think that's about version of react-native-cli.
You should try to update.
npm i -g react-native-cli
To solve my issue I have run command with --force option.
npm install -i -g --force react-native-cli
I would like to add that this same error happened to me (running on PC, Windows) when I tried to run the gradle command to build an Android release (./gradlew bundleRelease).
I found the cause of the issue was due to using Dropbox to sync the folder that this React Native project belonged to, using the Dropbox "Back up your PC automatically" feature, where I had my user Documents folder backed up by Dropbox. Essentially, I would get an error like this:
error SHA-1 for file C:\Users\Ted
Zhu\Documents\my-app\MyAppWin\index.js (C:\Users\Ted
Zhu\Dropbox\PC\Documents\my-app\MyAppWin\index.js)
is not computed. Run CLI with --verbose flag for more details.
ReferenceError: SHA-1 for file C:\Users\Ted
Zhu\Documents\my-app\MyAppWin\index.js (C:\Users\Ted
Zhu\Dropbox\PC\Documents\my-app\MyAppWin\index.js)
is not computed
I would notice in the error message, it referred to the same file (index.js) with two different paths:
C:\Users\Ted Zhu\Documents\my-app\MyAppWin\index.js
C:\Users\Ted
Zhu\Dropbox\PC\Documents\my-app\MyAppWin\index.js
This must've been because Dropbox created a symbolic link of the folder so that it would have a path within my Dropbox folder. This appears to cause the file in question to have two paths that refer to the same folder, and trick the Metro bundler into thinking that a SHA hash was not created for one of the project files.
The solution was to move this project to a different directory that is not backed up by Dropbox. In my case, I just created a new folder in my user home directory. Then I was able to successfully run the gradle command to build the Android app.
For me, I fixed it by install correct react-native-cli:
yarn global remove react-native-cli
yarn global add react-native-cli
For me, global cli update does not work.
I Just run the command like yarn react-native bundle...It works!
yarn react-native bundle --reset-cache --entry-file index.js --platform ios --bundle-output test.bundle --dev false
This worked for me:
npx react-native start
When Metro has started, open another Tab on the terminal, same directory then run:
npx react-native bundle ...
The problem for me was not using npx for the react-native command.
To solve I have run
npm install -i -g --force react-native-cli

Cordova 8 + iOS 4.5.4 = cannot find module "../cordova/platform_metadata"

Since the latest update to v8 of Cordova, I cannot build anything on Mac.
I always get
(node 626) UnhandledPromiseRejectionWarning: Error: Cannot find module '../cordova/platform_metadata'
I tried what was suggested in this post but I get the same error.
I then did a verbose and it seems like the plugin required to build for ios is not working well
Executing script found in plugin cordova-plugin-swift-support for hook "after_prepare": plugins/cordova-plugin-swift-support/src/add-swift-support.js
Resolving module name for cordova-lib/src/cordova/platform_metadata => ../cordova/platform_metadata
(node:599) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 1): Error: Cannot find module '../cordova/platform_metadata'
(node:599) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.
This was a bug in cordova-plugin-add-swift-support, just update it to latest version (1.7.1)
cordova plugin rm cordova-plugin-add-swift-support
cordova plugin add cordova-plugin-add-swift-support
you need to downgrade cordova 7.1.0 until this issue is fixed. Do this:
npm uninstall -g cordova
npm install -g cordova#7.1.0
cordova platform remove ios
cordova platform add ios
If your running an ionic project that requires the swift plugin you'll need to add the --force flag:
ionic cordova plugin rm cordova-plugin-add-swift-support --force
Then run:
ionic cordova plugin add cordova-plugin-add-swift-support
That just happened to me (using Ionic). In Ionic, the issue comes from a plugin or node_module that is still using cordova/platform_metadata, which is deprecated.
If you are using Linux, in your project directory, try this in the command shell:
grep -iRn 'platform_metadata'
In my case, it was the plugin cordova-plugin-add-swift-support that was still using that, and I wasn't even using that plugin my project, so I deleted it manually. Problem solved. The issue seems to arise when a plugin is calling a module that no longer exists, so you have to either remove that plugin or update it.
With Ionic 3 and Cordova 8.0.0 project.
Here are steps
ionic cordova platform remove ios
ionic cordova plugin rm cordova-plugin-add-swift-support
ionic cordova plugin add cordova-plugin-add-swift-support
ionic cordova platform add ios
I have faced same problem, then upgraded Cordova to 7.1.0 work for me
From my ionic project I did (bash):
grep -r 'platform_metadata' .
and found I had a plugin called cordova-plugin-swift-support was the culprit. I removed it and then added cordova-plugin-add-swift-support back in, and everything worked fine with cordova 8.0.0

Ionic v2 : "You cannot run cocoapods as root" error

I'm trying to build an Ionic 2 app with push notification in iOS.
I added Phonegap plugin push notification with this command line :
cordova plugin add phonegap-plugin-push --variable SENDER_ID=12341234 --save
But when I try to run my project in a device I have this error in xcode :
"GoogleCloudMessaging.h" file not found
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
I had this error :
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>'
I tried to run "pod install" directly in platforms/ios folder, but same issue.
So I try to remove sudo in the commande :
ionic platform add ios
But obviously I have this error :
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'
I really don't know what I have to do to solve that. An Idea ?
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.
If anyone is still having issues, I got it to work by running
pod install
in platforms/ios
and you may need to add permissions in that folder before that
sudo chown -R *username* platforms/ios
To allow code executions on your mac without using sudo simply run.
sudo chown -R Username /Users/username/Document/project location
It's working for me
If you use any plugin and platform add please install and add without
"sudo".
If needed permission them go to the project directory and click
setting->Get Info to give "Read & Write" permission then you can install plugin and platform without "sudo"
ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated#7.5.0
ionic cordova build ios --prod

Installing plugins keeps failing because of es6-prepare-plugin

I am trying to prepare my iOS app and I need to get socialsharing and the whitelist plugin working, but they do not work. For example, when I do this:
sudo cordova plugin add cordova-plugin-x-socialsharing
I get this:
Installing "cordova-plugin-x-socialsharing" for android
Failed to install 'cordova-plugin-x-socialsharing':
CordovaError:
Failed to fetch plugin es6-promise-plugin via registry. Probably this
is either a connection problem, or plugin spec is incorrect. Check
your connection and plugin name/version/URL. Error: npm: Command
failed with exit code 1 Error output: npm ERR! code ENOLOCAL npm ERR!
Could not install from "node_modules/es6-promise-plugin" as it does
not contain a package.json file.
npm ERR!
How can I fix this? I tried everything. From sudo to non-sudo commands, but nothing is working for me. Adding es6-prepare-plugin manually does not work either.
My system information:
Cordova CLI: 7.0.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 1.3.3
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v6.8.1
Xcode version: Xcode 8.3.3 Build version 8E3004b
PS: in my package.json file, I see this:
"es6-promise-plugin": "file:node_modules/es6-promise-plugin",
How can I change this?
Oh dear Lord. I found the answer I was looking for, after I've struggled for hours. This link on Github is the answer to this problem.
Seems like npm version 5.x.x does not work with some ionic-plugins. I downgraded to npm 4 using npm install -g npm#4.6.1 and installing this plugin worked for me afterwards.
Ionic is so buggy sometimes. Very annoying.

Ionic Platform Add IOS

when I try to add platform ios to my current ionic project the following problem is occurred to me:
Installing "cordova-plugin-whitelist" for ios
Plugin doesn't support this project's cordova-ios version. cordova-ios: 3.9.1, failed version requirement: >=4.0.0-dev
Skipping 'cordova-plugin-whitelist' for ios
How to solve the problem above? What should I do for it?
When I was reading the Ionic docs, I saw a section about Cordova which is called "Cordova Updates". So...when you get an error, a good practice is to search at the official documentation - it might be helpful.
Cordova Updates
$ sudo npm update -g cordova
In your case:
$ cordova platform update ios
Hope it helps.
$ cordova plugin rm cordova-plugin-whitelist
$ cordova plugin add cordova-plugin-whitelist#1.0.0

Resources