iOS/OSX Gotchas: Troubleshooting Tips for Building on a Mac
There are a few relativley common issues when building a Cordova app on OSX related to permissions that are worth noting.
You are seeing permission errors from "npm": If you are seeing permission errors from "npm," you may be running into a situation where the build agent user's cache folder (~/.npm) is inaccessible. Generally this occurs if the folder or some of its contents was created while running as an administrator (sudo). Fortunately this is easy to resolve:
Log into OSX with the user that installed and set up the cross-platform agent
Open the Terminal app and type:
sudo npm cache clear
sudo chown -R `whoami` ~/.npm
You checked in the "hooks" folder from Windows and are seeing "spawn EACCES" errors: If you encounter a "spawn EACCES" error when building on a Mac or Linux, be sure all files in the hooks folder to have an "execute bit" set as this a requirement for Cordova. To resolve, add an execute bit to the files in source control or execute a set of chmod commands as a part of your build script. Ex:
chmod +x <file name goes here>
This is commonly seen with Ionic due to the hook in hooks/after_prepare.
You checked in the "platforms" folder from Windows and are seeing permission errors: You should not run into this situation if you are using the Visual Studio Team Services Extension for Cordova, but if you are seeing errors that are originating from files in your project's "platforms" folder, the root cause may be that you checked in shell scripts under the "platforms/android/cordova" or "platforms/ios/cordova" folders from Windows. This is because the NTFS file system has no concept of an "execute bit" that is required to run these from OSX. (The contents of the platforms is generally not intended for checked in and by default are excluded from Cordova projects in Visual Studio as a result.)
For example, this error is saying the "version" script is not executable:
Command failed with exit code EACCES
To resolve this problem you have two options:
Don't check in the contents of the "platforms" folder into source control. This is by far the path of least resistance. The Gulp build script can add them at the time you build.
If you absolutely must check in the contents of the platforms folder from Windows, you can craft a shell script to set the execute bits on these files and include it as a part of your build process. There is a Cordova hook based version of this script available in the tips and workarounds section.
Signing suddenly stopped working for iOS on Feb 14th, 2016. Apple's WWDR certificate expired on Feb 14th and as a result you may experience signing failures if you have not updated the cert and removed the old one. Follow the steps outlined by Apple under What should I do if Xcode doesn’t recognize my distribution certificate? to resolve the problem. Note that this also affects development certs despite the title.