Sunday, November 25, 2012

libgdx and iOS deployment quest - Part I

After seeing the successful deployment of Noblemaster's libgdx-based games to the iTunes store, I figured it would be fun to port the libgdx games that I've created to iOS and release them to the iTunes store as well. So, today I went out to the local Best Buy and picked up a Macbook Pro 15” MD103LL/A.  It was on sale for about $120 less than the retail price that was listed.  I could have went for the more expensive model that included more system memory, but after doing some reading, saw that adding memory is pretty simple and cost effective so I'll probably go that route.

I brought the machine home and the first order of business was to get it running on my network.  Fail.

First and foremost – for whatever reason, the MacBook Pro would knock my Netgear WND3300 Wireless router out of commission. The net result (heh!) was that not only could the Apple machine NOT get on the Internet, but it also fouled up the rest of my network. Other machines that were working just fine would no longer be able to access the Internet. This is not the first time I've seen this behavior.

My brother-in-law has had a MacBook Pro for a while now. Every time he has brought his machine over, he has caused the same issues... after setting up the wireless configuration, boom – my network goes down. The only way to correct this in the past has been to reset the router.

This time I was determined to figure out a workaround if not an out and out fix. Using Google was worthless.  None of the tips I saw worked out.  After poking around with “ifconfig” and messing around with general settings, I noticed that I could get things to work once again if I manually defined the DNS values. My standard test to verify is simply “ping” from a terminal window.

Now, normally, the DHCP server capabilities of the router kick in and assign the router as the DNS server for the DHCP client. This has worked flawlessly with Windows machine. For some odd reason, this causes issues using an Apple machine. I logged into the WND3300 and took a look at its DNS capabilities. It's cable modem side acts a DHCP client itself, which gets its configuration from the cable configurations that are assigned by the cable company. I looked at the assigned DNS server values. They looked correct. Based on a hunch, I modified the “Domain Name Server (DNS) Address” setting on the Basic Settings page from “Get Automatically From ISP” to “Use These DNS Servers” and specified what the cable modem always gives me. After doing that, the MacBook Pro no longer has any issues accessing the Internet and the other machines on the network similarly work fine. Whew! That blew about an hour or so of time.

Next on the list was to download Xcode. Xcode is the IDE used for developing iOS applications. I've used it a little bit in the past. I had to log into the Apple App Store and download it. Annoyingly, I also had to update my credit card info on file with Apple. As great as everyone claims Apple is, I find this to grate on my nerves... Especially given that Xcode is available as a free download. I guess I should also mention, I already had an Apple ID that I created back when I had an iPod Touch.  So, getting that stuff up and running was annoying but not world-ending.

With Xcode downloaded, I needed to install Eclipse. Wow. Installing Eclipse is easy. The problem comes in that there are about 10 different flavors of Eclipse. Historically, I've always gone for Eclipse Classic. However, this only provides a bare minimum. After doing some looking around, I discovered that there is a version of Eclipse for Mobile Developers. Sweet! It includes Java and C development tools. The libgdx library backend includes certain things written in C for performance reasons (the Box2D Physics Engine, for example.) I've had to make my own tweaks to that in the past so its been cool to have C tools available. At any rate, I installed that.

Then, I tried to run Eclipse. Blah. You need the Java JDK before it will work. On a Windows machine, you get that from Sun. Not so on an Apple machine. At a terminal prompt, I entered “javac -version” and it prompted me for an install. I wanted to specify an exact version of the JDK but I didn't see an option. I've heard of problems with JDK 7 and wanted to stick with JDK 6. I bit the bullet and just accepted whatever version the default installer selected. Turns out that I lucked out and am now running 1.6.0_37. Woot!

Next up I wanted to get my Mercurial repos running. On Windows, I use TortoiseHg which has really nice integration with Windows Explorer. On the Mac, there were a few options and I decided to give Atlassian's SourceTree a shot. I've got my repos hosted on Bitbucket so it seemed to make sense since BB is operated by Atlassian.  (Note: There has been an update on this -- I'm now using TortoiseHg on my Macbook Pro.)

In order to access my BB repos, I apparently need to get the ssh keys configured. I tried to follow Atlassian's directions where they imply that you'll be prompted to enter your ssh key info when you try to clone a project. This will supposedly add your key to your system's keychain. That's not the case. Trying to clone a repo resulted in an invalid URL problem and I couldn't get any further than that.

So, I copied my private BB ssh key over to the MacBook. In order to access my repos, I need to have my ssh key in the Mac's key ring. This is done via “ssh-add -K /path/to/key/here”. So I did this, got prompted for the passphrase and then.. it failed. Mwah? I generated the key using Puttygen and use it on nearly a daily basis, so I'm 100% the passphrase was being entered in correctly. Turns out that you need to use PuttyGen to export the key in an openSSH format. After doing that, I could add the key successfully.

Next up was to get my graphical development environment going. This meant getting Inkscape and GIMP up and running. Since I'm running OS X 10.8 (Mountain Lion), this is not as straightforward as simply installing the related dmgs. No. Trying to run Inkscape gives you a prompt saying “Where is X11?” Turns out that you need to first install Xquartz, which is the Open Source X11 that Apple no longer includes on its machines. Yippee.

After downloading that and rebooting, and trying to Inksape again, I was still prompted for “Where is X11”. Mwah? You need to go to your Utilities folder and start Xquartz and THEN start Inkscape. Geez. So much for the “ease” of using Apple products. On the other hand, the GIMP version was already setup with Mountain Lion compatibility so I didn't need to do much there other than copying the GIMP application to my Applications folder. Sweet.

No comments:

Post a Comment