Cordova and ios-deploy causes builds to fail with "codesign exit code 1"/ "permission denied" - ios

I'm working on a Cordova based mobile application, and wanted to make use of the Cordova CLI's ability to deploy and run my mobile app right from the command line, without having to go into XCode to do the build
When doing:
cordova run ios --device
Cordova graciously tells you that you should install the ios-deploy node module. I did so following the steps on their GIT site.
When I next tried to do a run, I started to get codesign errors, specifically:
/Users/blahblah/platforms/ios/build/device/myApp.app: Permission denied
Command /usr/bin/codesign failed with exit code 1
I couldn't get the code signing to work from Terminal, and worse, going back into XCode resulted in the same error!
Fortunately the error messages says it all: permission denied; I was able to correct this by popping back into Terminal and running a chmod on my entire app folder, i.e.:
chmod -R a+rwx myApp
I could then go back into XCode and get the project building and deploying again (whew!), however if I tried to do the deploy via the Cordova CLI, then same issue would occur.
It seems like the ios-deploy and / or cordova is messing around with the folder permissions, but I'm not sure how to correct this.
Any suggestions would be appreciated!
UPDATE:
To be clear, I am able to successfully sign the app within XCode if I first go into Terminal, and then into the platforms/ios folder and perform a chmod -R a+rwx on the "www" folder.
The problem I'm having is trying to get this to build / sign successfully from the command line.
I've done some further diagnosis, and it seems that the problem is with the Cordova CLI itself, and not with ios-deploy; when I execute:
cordova prepapre
It copies my "www" folder over to the "platforms/ios/www", however it changes the permissions when doing so from everyone having write access (i.e.: drwxrwxrwx) to only my user having write access i.e.: (drwxr-xr-x)
It seems that this is fouling up the codesign application, and is causing my permission denied errors above.
I'm just hoping someone knows how I can work around this, or what I might be doing wrong with my build - I'd prefer not to have to go into XCode to do these builds.

So it turns out that the Cordova CLI is working just fine, as is the ios-deploy npm package.
The problem turns out to be within the solution itself, and has nothing to do with the tools.
I am using the Ionic framework within this particular Cordova application, and their framework installs some "after_prepare" hooks (within the hooks folder) which attempt to help prepare / clean up some extraneous files prior to the build.
One of these hooks (named "020_remove_sass_from_platform.js") was trying to help out by cleaning up unneeded SASS files prior to the build in order to reduce the size of the compiled app.
Unfortunately this hook was adjusting the folder permissions (I guess in order to ensure the delete could succeed), and this was the cause of the "www" folder's permissions changing during a "cordova prepare".
I deleted the hooks, and now the Cordova CLI builds and signs the APK as expected, and the ios-deploy package pushes it to the device, all without using XCode.
Hope this can be of some help to someone else.

Check the CODE_SIGN_IDENTITY property in your build settings. Is your provisioning profile selected there?
You also need to enter a valid bundle identifier in your apps .plist.
The identifier has to match the one you provided when generating the profile.

Try this
sudo npm install -g ios-deploy --unsafe-perm

Related

Alternative for hybrid web app without knowledge in app/server

i used to upload my ZIP (with HTML5/CSS web app) in phonegap since 4, 5 years and create cool mobile apps. But since some months it's look like Adobe dismiss the project, no more answer on forum etc.
Is there a good solution, when you don't know everything about shift/cocoa/java and server things, to simply upload your webapp (basically a website in a zip) and get IPA/APK ?
I heard about monaco or voltbuilder. Thanks
Not really. Although I can confirm https://build.phonegap.com works for me. If you have an error related to a malformed xml, you can try to delete the project on the website and re-uplading the zip file onto a new project. That's a bug I have experienced in the past.
Otherwise, you can install Cordova and Phonegap on your pc to build it using npm on the terminal (Linux/MacOs).
$ sudo npm install -g cordova
or for windows (CMD):
C:\> npm install -g cordova
then navigate with the command line using cd to go to a folder
eg. cd myfolder.
You can see the files in your current directory with ls (Linux/MacOs) or lsdir (windows)
Once you are in your project's folder and that you can see with lsdir or ls your config.xml file of your project, then you can run those commands to add the platform you want to build:
cordova platform add ios
cordova platform add android
Finally to build the app, you need to:
cordova build
Note: To build an Ipa, you will need to use a device running MacOs since it requires XCode. I highly recommand you to get familiar with Cmd or the terminal if you are building an app.
I hope I have answered your question well

ionic emulate ios (domain=com.apple.CoreSimulator.SimError, code=163)

I am trying to simulate a project with ionic using the command ionic emulate ios. I have installed xcode last version on mac Sierra. But no work. this is the error:
** BUILD SUCCEEDED **
No target specified for emulator. Deploying to iPhone-SE, 10.2 simulator
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=163):
Unable to lookup in current state: Shutdown
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=163):
Unable to lookup in current state: Shutdown
Error: ENOENT: no such file or directory, stat '/var/root/Library/Logs/CoreSimulator/4A052961-F773-4156-9D6C-76F137CC761B/system.log'
I found this solution(https://forums.developer.apple.com/thread/66665) but no work for me.
https://cordova.apache.org/docs/en/latest/guide/platforms/ios/
Open a Project within Xcode
Cordova for iOS projects can be opened in Xcode. This can be useful if you wish to use Xcode built in debugging/profiling tools or if you are developing iOS plugins. Please note that when opening your project in Xcode, it is recommended that you do NOT edit your code in the IDE. This will edit the code in the platforms folder of your project (not www), and changes are liable to be overwritten. Instead, edit the www folder and copy over your changes by running cordova build.
Plugin developers wishing to edit their native code in the IDE should use the --link flag when adding their plugin to the project via cordova plugin add. This will link the files so that changes to the plugin files in the platforms folder are reflected in your plugin's source folder (and vice versa).
Once the ios platform is added to your project and built using cordova build, you can open it from within Xcode. Double-click to open the ${PROJECT_NAME}/platforms/ios/${PROJECT_NAME}.xcodeproj file. The screen should look like this:
https://cordova.apache.org/static/img/guide/platforms/ios/helloworld_project.png
Then follow the instructions to deploy to a simulator:
https://cordova.apache.org/docs/en/latest/guide/platforms/ios/#deploying-to-simulator
You will be able to see errors more clearly.
In my case it was the problem of an unmatched resource file. I simply deleted it.
After this, I tried:
sudo chown -R $USER:$GROUP ~/.npm sudo chown -R $USER:$GROUP ~/.config
in terminal and was able to run the app in a simulator

ionic build ios fails with "[TypeError: Arguments to path.join must be strings]"

I am trying to create an ionic app on Mac.
I followed the instructions on ionic's website to create a basic app and was able to run it in the browser but when I run "ionic build ios" I get following error. I cannot find a log file or any other error to debug this. How do I go about fixing this?
Check your Gulp version and gulpfile.js. You may need to remove the calls to gulp.src
See:
Gulp TypeError: Arguments to path.join must be strings
and
https://github.com/sindresorhus/gulp-ruby-sass/issues/191
ok, after lot of looking and searching I figured my npm install was messed up.
Part of my installs were in /usr/local and few of them were in /User/user.name/npm folders. /Users/user.name/npm was set in the npm config prefix.
I had two installs of cordova, one on each folder above. Some how the cordova from /usr/local was getting used to create the project and that was the old version.
To fix the problem, I uninstalled all my global npm installs and pointed my npm config prefix to /usr/local and gave myself execute permission on that folder. Everything is working now.
Here is the video that explains how to do it: https://docs.npmjs.com/getting-started/fixing-npm-permissions

phonegap run ios gives shell.js internal error (Mac, Cordova)

This is the console output that I get when trying to execute "phonegap run ios", which executes "cordova run ios".
ErlendMBPrivate:fsecapp erlendellingsen$ phonegap run ios
[phonegap] executing 'cordova run ios'...
shell.js: internal error
Error: EPERM, operation not permitted '/Applications/XAMPP/htdocs/jobb/fsecapp/platforms/ios/F-Securities/config.xml'
at Object.fs.chmodSync (fs.js:821:18)
at copyFileSync (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:41:6)
at /usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:198:5
at Array.forEach (native)
at Object._cp (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:157:11)
at Object.cp (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/common.js:186:23)
at /usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:74:23
at Array.map (native)
at /usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:65:40
at _fulfilled (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/q/q.js:787:54)
Now. I understand somewhat that there seems to be a chmod-problem. However. All of the folders that are named in the output log, are all accessible, readable and writeable by all users. I have chmodded all the folders.
More importantly
When I enter sudo-mode, there are no internal error. However. When authenticated as root, and using "sudo -i" when executing the command, the command line is unable to find any valid signing identites
If you don't understand the problems I get when executing as sudo, please see the StackOverflow-question I posted last week: Phonegap/cordova command line gives code signing error, xcode works fine. (IOS)
Phonegap (through Cordova) has insufficient permissions on the project folder.
To fix this issue is necessary to modify the project folder permissions in order to make the config.xml file writable by Cordova.
Normally Phonegap is run by the user, Cordova is invoked by Phonegap so in order to give Cordova permissions is necessary to give the user the ownership of the project folder. This can be achieved as follows:
sudo chown -R $(whoami) "/Applications/XAMPP/htdocs/jobb/fsecapp"
source

iOS xcode 5 crashlytics error - Shell Script Invocation Error - ./Crashlytics.framework/run: Permission denied

I have Crashlytics Framework added to my project, with a script.
Run script:
Shell: /bin/sh
Script: ./Crashlytics.framework/run KEY_HERE
When I try to run the project, I get the following error:
Shell Script Invocation Error - ./Crashlytics.framework/run: Permission denied
BUT if i delete the framework and add it again, it runs fine... ONCE. Then the next time I get the same error. Then i have to delete it, and re-add it, for it to only run once, and then the same story...
Does anybody have an idea how to fix this? THANKS in advance.
Are you keeping your project and the Crashlytics framework in Dropbox? I've noticed that Dropbox changes/resets the permissions set.
Try pausing Dropbox sync and then set the permissions of Crashlytics.framework/run to 755.
UPDATE:
chmod 755 run only worked temporarily for me.
As Hemal Shah wrote in his answer, I also had to tell git to make run executable. You can do so by calling git update-index --chmod=+x run and committing that. (via this answer).
After having moved my project and the Crashlytics framework out of Dropbox, and doing this, there were no further issues with it.
In terminal just navigate to Crashlytics.framework folder if you use Crashlytics, in case you already use Fabric go to Fabric.framework folder. run should be there. And change permissions by running this in terminal: chmod 755 run.
Hemal from Crashlytics here!
A few things could be causing this - make sure that you're running the latest version of Crashlytics. If you click on the lower right-hand corner, then the release notes should show "- Added arm64 support for iPhone 5s."
Double check that if your SCM requires it, that the "run" binary is marked as executable!
Also, make sure you only have one copy of Crashlytics.app on your system and one copy of Crashlytics.framework in your project and that you're linking to the same copy being invoked.
I wanted to include my answer in case there is someone else who had this similar problem but is not using Crashlytics. I'm using Twitter Fabric and started get the error: ./Fabric.framework/run permission denied
Going to Build Phases and deleting the run script fixed this for me.
Edit: Adding to what I said above, just deleting the run script doesn't completely solve the problem, since you still need one to work with Fabric/Crashlytics. I ended up having to contact Crashlytics and this is what they told me (similar to #singhSan's resp0nse):
"Back up through the setup until you can click on the app-selector arrow in the top left corner. Then click on "+ New App" and select your project. This will function as a repair mode and get you the run script build phase you need."
Problem solved.
A simple and quick fix is to delete your Crashlytics framework and add it again in your project. This will fix the issue.
Run below commands in your project folder:-
chmod +x Crashlytics.framework/run
chmod +x Crashlytics.framework/uploadDSYM

Resources