Getting Started with iPhone Programming: Ten Steps

July 3rd, 2009

I thought I’d put a few notes together on my experiences so far too. These are the ten steps to get started with iPhone programming. There are several sources of useful information that you can Google for. And developer.apple.com/iphone is the canonical source for information.

If you don’t want to do all this, well, you can just hire me or someone like me to write your iPhone app for you. That works too!  Email me at contact@tangozulu.biz.

First things first, you don’t actually need an iPhone to get started, although you’ll want one soon enough. You can program with the iPhone simulator in the development environment, but somethings (accelerometers for example) are not simulated. But you to need a Mac, Windows won’t do. (That’s ok, you need a UNIX box anyhow and that’s what MacOSX is after all. The iPhone is UNIX too. Get over the Windows thing; Microsoft doesn’t let you develop MacOS software on Windows Vista do they?)

1. Get a Mac.

So, get a Mac, any of the laptop pros are good for this. I like the 17 inch, but each to their own. If you have some bucks, get a 3 GHz, 8 GByte memory laptop. Amazing capacity, but you don’t need that level machine to write code for the iPhone.

You’ll need XCode, this is the development environment for the Mac and for iPhone. No worries, this is free. This is listed on the apple site as the iPhone SDK. But, it’s XCode with the iPhone SDK bundled. This is free. But, you’ll have to become an iPhone Dev Center member to download this. You can do a free option, but you won’t be able to download your app onto an actual iPhone with that, you’ll only be able to use the sim. If you buy the membership for $100, then you can later get the cryptographic keys to sign your app and download to an iPhone device.

2. Get an ADC (Apple Developer Center) membership. Spend the $100 for this either now or later.

3. Download and install the iPhone SDK (containing XCode as well) on your Mac and install it. If you have a new Mac, use the Snow Leopard version. Else (assuming you’re not upgraded yet) use the Leopard version. If you’re not running Leopard yet, then upgrade already. You’ll have to.

Ok, you’ve got a working dev environment now. So, “hello world” is next of course. Use this link from Apple to make your first app and try out the dev environment. Run it on the sim, getting it on the iPhone is another issue.
And, if you’ve not done this yet, get an iPhone and use it. Try out some apps and get a feel for what works and what doesn’t. Buy some more apps and try those non-apple apps out too. The point of this is to get a feel for the UI and user experience. Without this you’ll make bad decisions in your designs.

4. Write and run “Hello World” on the sim.

5. Get and use an iPhone if you haven’t yet.

Now, you’ve gotta get your keys. All iPhone apps are signed, and the ones on the iTunes store are countersigned by Apple. You have to 1) get your key to sign your app, and 2) set up your iPhone to accept that for developer purposes.

To get your keys, follow the precise instructions in the iPhone Developer Portal with the Provisioning Assistant there. If you have the free account, you won’t see this. You’ll only see this link when you have your paid account. So shell out the $100 and upgrade already.

You first make a certificate request to the Apple certificate authority, this is the standard public-private asymetric key. The certificate is signed by Apple to make it good. You also have to make a device profile for your iPhone. If you’re a solitary developer the “team” aspect of this is a no-op. If you’re part of a development team, then there’s a hierarchy of controls that can be put into place.

The the second part, you provision your device with your profile and certificate. Beware, XCode 2.x and 3.x are a bit different here. Their directions were 2.x based, and we’re running 3.x. Look under “Code Signing” in the target properties for your application to find the settings they’ll talk about.

Also, note that all this in your profile and provisioning is case sensitive! This created problems for me, either I missed where Apple said it was case sensitive or they didn’t say.

6. Pay your $100 to upgrade your account

7. Request a key

8. Make a profile for your device

9. Provision your device

At this point, you can now put your hello world app on your iPhone and walk around and show it to your family and significant other(s).

Then, learn. Time to exercise your brain and read. The iPhone OS and software development works with ObjectiveC. (Yup, get used to it. I actually like it better than C++.) You’ve also got some massive amount of APIs in the SDK to get familiar with too. Then there’s the human interface stuff and design philosophy. It’s important as this is how Apple does their polished apps. This is a learning curve, but it will help as there’s tremendous amounts of stuff already written for you. You can stride along in seven-league boots making new apps and use all the stuff Apple made for you.

There are plenty of reference materials in the usual well-written Apple style about all this, and about the UI too. But one way to get started is to use the Stanford iPhone class on iTunes U to learn the basics, then expand from that. It was taught by Apple engineers, so that helps.

10. Learn, with online resources or perhaps with the Stanford class.

Or, if you don’t want to do all this, hire me and I’ll write your app for you. So, happy hacking!

Solar Power System

July 2nd, 2009

I’ve finished the installation of my solar power system in the popup camper. I think of it as a pilot to a possible house solar system that’s rather more-expensive.

I talked about this a little before, but in short we have a 30 Watt panel feeding a 65 AH battery with a charge controller. This is a larger battery that I think I need, but was a standard size that I could buy. Having more reserve won’t hurt. When I tested it, I propped up the panel as below. (Yes, it still generates power in the shade, but less.)

BP 30 W solar panel The battery, in turn feeds several 12 Volt DC uses: LED lighting strips and four 120mm computer fans for ventilation. These are almost silent (I bought them specially for that). Then there’s the 120VAC inverter for AC power. That makes a sound with its vent fans so we’ll only use it when we need AC. That’s for charging a computer, etc.

The first steps to doing a solar installation are to figure out the electrical load you want to supply, and thus the amount of power you’ll need. My load is 200 Watts/day. Pretty minimal. Your house uses much more than that. Read your power meter for your house’s load. Or, for a smaller system like mine, calculate your load. There are online tools for this at places like the www.altestore.com which also has many helpful articles too.

Once you have an idea of the load, then figure the power you’ll get from the panels. Mine is for use in the longer sunny days of summer, so I figured 5-6 hours of sun per day. For a house, you’d need a year-long average of hours of sun/day, and adjust that for shade from nearby trees, hills, etc. The amount of power helps determine the size and number of the panel.

You also will need to know how many days reserve power you’ll need. If you’re an off-grid system, this is more critical since you can’t pull power from the mains. If you’re connected to the grid, you actually don’t need much (or perhaps any) batteries. Your reserve requirements determine the size of your batteries.

Then, you need a charge controller. Overcharging or overusing your batteries can shorten their life drastically. Since they’re expensive, it makes sense to spend a little money on a device that controls that charge level. It has to be sized for the amperage and current your panels provide. Wire this together with wiring for the amperage you’ll be passing through the wires. Put some fuses in place (I have one leading to the battery, and one from the battery.)

Then, you need an inverter, this converts the DC power to 120VAC power. Some systems use 12 VDC like mine, but larger systems will use batteries in series at higher voltages.

My inverter is the small blue device here. This is my battery, the small gray thing is my charge controller. The large black cable and the device it attaches to is a parallel system for plugging the camper into campground-provided AC power that we’re not using. Since I took this photo, I’ve added the outputs from the battery in terminal strips that the LED lights, fans, and USB power converter’s plugged into.

Most of the work was in the wiring and in figuring out the connections. In any real project the minutia of fitting the parts into what’s already there is a big part of things. Most of the connections are soldered, a few are crimped as I trust crimping less.

A less minimal system would have amperage meters to show the charging current and load current.  Some more expensive controllers have a monitor to show power stored, etc.  But this is a vacation-purposed system though, if the power dies it isn’t a big deal.

More planning on my part would have simplified the installation as I would have just ordered all the parts and wiring I needed from DigiKey, Jameco, or Mouser Electronics. But I tried to buy local from Radio Shack. Radio Shack is no longer a parts store and hasn’t been for years; I hereby give up on them. Since I like to see the parts and handle them when planning I really miss a local parts store. If I still lived in Austin TX or Silicon Valley there would be no problem. (I love Fry’s Electronics!) But government is the local industry here and they don’t need local electronics parts stores, just conference rooms.
So, vacation is soon and we’ll test out the system in real life instead of the driveway. And perhaps I’ll get some solar-powered iPhone programming done!

Airplane is Fixed!

July 1st, 2009

I flew to New Market to visit Shenandoah Avionics Monday to replace the D.G. (aka directional gyroscope or heading indicator). Finally, after a very long backorder, it had come in from Aircraft Spruce. (For symmetry’s sake, there should be a New Market Avionics in Shenandoah airport.)

It was a nice flight down there in the morning. I keep overestimating my airspeed though, I got there later than I’d planned. I pulled up to the unmarked hangar in the middle of the field (the airport owner doesn’t let Shenandoah Avionics put up a sign for some odd reason) and stopped.

When I went inside, the hangar was full, so we’d be working outside today. No problem, it was a pleasant morning. The mechanic and I got started, I removed the panel and loosened the existing DG’s mounting screws. He did the upside-down work from under the panel and dismounted the old one. We found out pretty quickly how it failed. They’d not seen this failure before where the instrument fittings broke. Usually the vanes on the gyro break off apparently.Old, unairworthy DG

So, I get to take the old one home to disassemble it. The owner suggested I cut away the case and make a teaching instrument out of it as the rotor was probably in good shape. Sounds like a good idea!

We checked the air and vacuum hoses to see if they were too tight, but they had the right amount of play in them. Sometimes things fail and we won’t be able to figure out why. This is one of those cases. Not all answers are worth the effort.

While the mechanic reached the new instrument up from the bottom, I pulled it into place from the panel and mounted it. Naturally, the mounting screws were different between the two instruments, so we had to put a new hole to the left bottom. The old instrument had the third mounting screw on the right bottom. The nice thing about standards is that there’s so many to choose from.

This new DG has a heading bug. We also wanted an internal light, but I couldn’t find one in our price range that had both. (To have both would have almost doubled the price.) So, the bug was it. My IFR instructors will be pleased, and it will be a lot easier for us owner-pilots when flying too. But the knob for the bug also meant another new hole.New DG The new DG was finally installed (here shown on my flight home, I’m using the bug). We tested it, but it didn’t work. So, check the hoses!

The vacuum-powered gyroscopes work by a vacuum pump pulling filtered air through the gyro housing, which directs that air by vanes on the gyro that spin it up to around 5000 revs/min. The little gauge to the right of the new instrument shows the vacuum pressure. (By the way, the new turn coordinator is to the left, we replaced that after my first IFR lesson in the plane.)

Each manufacturer labels the hose connections in the back of the instrument a bit differently. This, naturally, is subject to misunderstanding. Which is what happened. The filtered air intake was connected to the vacuum and vice versa. Once that was fixed, all was good. We taxied around in a circle and it worked. The mechanic was chagrined but I wasn’t concerned though. Mistakes happen, we’re human. It’s the unchecked and uncaught mistakes that worry me. We were checking and double-checking here.

By now it was the middle of the day and I had a bumpy flight home, not as peaceful as the morning’s flight. The winds were from the north everywhere else around here, but due to the particular pattern of hills around New Market, this airport’s winds were from the south. So, takeoff to the south, give extra space to the hill just off the runway on climbout (easy enough) and turn north, then east to home.

Done. Now I can finish my IFR, and the other owner-pilots can do their flying as needed with the DG working again.

WWDC

June 26th, 2009

As I mentioned in my last post, I attended Apple’s World-Wide Developer’s Conference in San Francisco recently. It’s been about five years since I’ve gone to a WWDC and I had a few observations.

First, Apple’s gotten cheaper with the food. Now, it’s probably still better than many conferences might have, but it used to be spectacular: catered hot food of various types, friendly to vegan and vegetarian friends, and stuff you’d pay well for in a good restaurant. I can’t fault them for cutting back, but I do wish there had been fruit in the morning. To their credit though, the box lunches were better than the breakfast, and there was free Odwalla juices all day on each floor.

But I solved the breakfast problem by simply buying my own of course. We were in the middle of San Francisco, so it was easy to find a grocery on the way to the hotel.

Second, I’m now past the median in age for the attendees. This one’s harder to solve. There were people there who could have been my kids. There’s not much I can do about this but stay active and lively. Don’t worry, I think I can still show those young whippersnappers a few things!

The trick, as always, is to keep learning. Sometimes it’s good to toss oneself into a new area and be forced to start over. The iPhone has some of that for me I think, while it is not completely new there’s enough new in it to keep me busy. Being forced to start over occasionally forces me to reconsider paradigms and points-of-view as we all did when we were younger. In turn, this keeps my outlook fresher.

Learning to fly did the same thing. I crossed a big hurdle when I realized that I couldn’t learn to fly like I learned other things. That is, I can’t stop the plane to go look up something like I do in software or hardware engineering. I had to learn differently and have it really in my head.

Third, while I was in the upper age half of WWDC, I was in the lower weight half. And I’m no athlete either! Fellow geeks, let’s face it: we don’t get nearly enough exercise! And we eat way to much bad stuff. Think of it as an I/O problem; garbage in, belly out. The human body is a machine meant to be used and we’re just using our brains and fingers. That brain works a lot better when everything else gets exercise too.  When a fifty-year old can leave guys 10 and 20 years younger huffing and puffing, something needs to be done!

Fourth: It was surprising how many of the attendees were either small business owners or running their own consulting operations. This may be one of those areas that the big businesses are in the minority. That hasn’t changed at all from past WWDCs and is heartening for the future of the economy in technology growth.