Category iOS

Installing NativeScript on Mac

There’s nothing quite like grappling with the installation of a development environment, there is no greater joy than getting bogged down before you’ve even written a single line of code. Today I installed NativeScript on Mac (El Capitain) and these are some of the problems I encountered.

The instructions on the NativeScript Advanced Setup for OSX seem straight forward enough, so lets give it a go:

brew install homebrew/versions/node4-lts

And before I even get off the starting blocks I’m in error country:

Error: undefined method `desc' for Node4Lts:Class

OK, maybe my brew is out of date since I don’t really use it, so I’ll try this:

brew update

Which resulted in this:

warning: unable to unlink .yardopts: Permission denied
warning: unable to unlink CONTRIBUTING.md: Permission denied
warning: unable to unlink SUPPORTERS.md: Permission denied
fatal: cannot create directory at '.github': Permission denied
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

Which means maybe I have an permissions problem, and you generally don’t use sudo with brew so I do this:

sudo chown -R $(whoami):admin /usr/local
cd /usr/local && git fetch && git reset --hard origin/master

And finally I try this again:

brew update

Success!

So now I can finally install Node (I’m not cool enough to already have it installed):

brew install homebrew/versions/node4-lts

Success! Things are going quite well and the rest of the steps go smoothly (I didn’t bother with the Android steps) except for the thing I actually need:

npm i -g nativescript

More permission errors:

npm ERR! Error: EACCES, mkdir '~/.npm/through2/0.2.3'

So, lets chown everything in my home npm directory:

sudo chown -R $(whoami):admin ~/.npm

And try it again:

npm i -g nativescript

Success! Now I can start dealing with real problems.

iOS 8 Directory Structure and In-App Purchase Downloads Problems

With iOS 8, every new build of your application will most likely be stored in a different container. This means that any file system paths you store to downloads or documents may change between builds.

While debugging some In-App purchase code I came across the following problem. I would start an In-App purchase with Apple hosted downloads, then just before the download completed, I stopped the App using Xcode. When I rebuild and run the app, the download would complete as normal and the download state was set to SKDownloadStateFinished. All good, with one exception: the path that download.contentURL contains, is pointing to a different app container, the original container from the previous build. A container that we don’t have access to, which will cause our move operation to fail!

This is one of those bugs that you’re probably not going to come across very often, but when you do it’ll eat up just enough of your time to annoy you! I’m assuming that the same error could occur if the user kills the app, updates it from the App Store, and then restarts. Now, off to file a radar…

Remember to fill in “What to test?” on new Testflight builds!

If you upload a new prerelease build to Testflight iOS 8, you need to fill in the “What to test?” textbox under “Testflight Beta Information” before your build will be released. It’s obvious the first time, but not for updated builds. There’s no indication that you need to fill this out for the build to go live, even if it’s something you should do it’s something you might miss.

Beware unofficial sync cables

My 4S is my daily phone and I use it for development too. When I got my new MacBook Air however, it wasn’t connecting properly. It connected and disconnected rapidly, vibrating each time, iTunes throwing up 50 messages saying the device was no longer available, Xcode the same. This was frustrating, my 2008 Macbook still worked with the 4S, but the new MacBook choked on it.

I bought a load of cables, none of them official Apple cables, none of them worked. They weren’t all cheap either. They’d charge from the power adapter but nothing more. In frustration today, after months of this crap, I decided to pay €20 for an official Apple 30-pin to USB Cable.

It works, flawlessly. Lesson learned Apple.