Flash and the Mac App Store

When the Mac App Store launched in January 2011, it included one app built with Flash. it was my game Gold Strike. I won’t go into the history of the game, which started with Flash 5, and then evolved into Director/Shockwave, and then back to Flash CS5 to become an iPhone app. But it was that last iPhone app version, done in CS5 that became the Mac App.
So the first thing I did was to make sure that I could export from Flash CS5 and get a decent application as a Flash projector. So I changed Publish Settings to export only a Macintosh projector and tested. I had to make a few adjustments, especially when you consider that the projector window can be stretched and scaled. But after a bit I got the projector working the way I wanted.
Now the hard work begins. You really have to do a lot to this projector file, a .app file, to get something that you can submit to the store. All of it pretty much has to be done on a Mac. I’m also assuming you are already signed up with a Mac Developer program. Oh, and read this entire thing first, don’t follow it as a step-by-step or you will be in trouble. You’ll see.
To do a lot of the changes, you need to get into the .app file. Control+click the file and select Show Package Contents. Now you can see the guts of the .app file.
Look in Contents/Resources for the icon.icns file. This is where you need to edit the icon. I used a program called Icon Composer that should be on your Mac as long as you have the Apple developer tools installed.
Next, you need to look at the Contents/Info.plist file. Edit that in BBEdit or something like it. It is just a text file. You need to make a number of changes in there. Refer to the document at the Mac Developer Center titled “Submitting to the Mac App Store.” This lists the plist items you need to be concerned about. Though it wouldn’t hurt to also look through the others and make changes where you think they might be necessary — copyright statements and such. Make sure you change CFBundleName to your applications’ name.
Now the Mac App Store doesn’t allow apps unless they are Intel-only. The App Store itself is only for Snow Leopard, which is Intel-only anyway. To get rid of the old PowerPC code in the .app file you need to launch Terminal and navigate over to your .app file. Change its name to something else to make room for the new copy you are about to create. Then use:
/usr/bin/ditto --rsrc --arch i386 YourAppName Copy.app YourAppName.app
Now test again to make sure it still works. You’ll notice the file size is much smaller now without all that PowerPC code.
Next you need to sign the app. You should have worked your way through the Mac Developer site to create a record for your app and for yourself as a developer. In the end you should get two certificates that would be neatly tucked away inside your Mac keychain. Lots about this on the developer site, so I won’t go into detail.
First, sign the app with your application certificate.
codesign -f -s "3rd Party Mac Developer Application: Your Name" -v YourAppName.app
The result is some message about the certificate being replaced. It is a very odd message, but the result is that it worked.
Now, you need to build an installer.
/usr/bin/productbuild --component YourAppName.app /Applications --sign "3rd Party Mac Developer Installer: Your Name" YourAppName.pkg
A common mistake here is to use the same certificate for each one. But you have to use your app certificate for codesign and your installer certificate for productbuild.
Now you have to test your installer. You can’t just double-click it to run the installer. You need to keep using the Terminal.
sudo installer -store -pkg YourAppName.pkg -target /
When you do this the first time, you will be puzzled because the app doesn’t appear in your Applications folder. The installer notices that it is still there, in your development folder, so it doesn’t bother to install it. Very annoying. You can move and rename it as you want, but the installer still won’t work. I had to end up compressing it into a .zip file, and then the installer couldn’t find it and would do a proper install to the Applications folder.
So that’s it. You now have a package file that you can upload to Apple. Except, no it isn’t.
So far, this is what I did to submit Gold Strike 1.0 to the app store. And somehow it got through. But there are several problems with this method that I had to clean up before I got version 1.0.1 through.
The main one is that the projector commits a huge sin: it uses a private API. That’s a big no-no for the App Store.
Now there is not much, or anything, you can do about this. This is deep inside the projector and you can’t remove it or rename it even with a binary editor. Try, and you just get an app that crashes.
So the solution is to not use Flash CS5. You’ve got to use Flash CS3 to build the projector. You see, I told you not to follow this as a step-by-step.
So you need to save copy of the .fla from CS5 as a CS4 file. Then from CS4 to CS3. (Note that going to CS4 might work too, but I don’t have CS4 installed anywhere to test).
Now, using CS3 you publish the projector. Then repeat all the steps above. The result is an app that does not use any private APIs.
But you are still not done. When you run the projector you get “About Adobe Flash Player 9″ as the first menu item in the application menu. This is also a sinsthat Apple will not allow. But there is no way to change them using Flash.
So you have to break out a binary editor and go to town. I used 0xED (http://www.suavetech.com/0xed/0xed.html). Look in Contents/Resources/Flash Player.rsrc. You’ve got to change the About menu item name. It takes some detective work to find it. Then, the important thing is to replace each character with a character. Overwrtie, don’t insert. Don’t delete any. So you may have to pad your name with extra spaces.
I also found the information that appears in the About box. I don’t know if that is important to Apple or not, but I changed it just to be safe.
Now codesign and built the package again. That should do it.
But of course the rules are always changing. So by the time you read this things might be different.
I don’t have any plans to use this process again as there are just too many places where things can go wrong. I hope, instead, that Adobe improves the projector publishing process. For starters, you should be able to set up an icon, set the about menu, choose Intel-only, and set all of the important items in the Info.plist file. Most importantly, of course, no private APIs.

February 11, 2011 • Posted in: General • No Comments

The Mac App Store? Should I Try It?

Today Apple announced that there will be a Mac App Store. It will be open by mid-January. The idea is that a developer like me can submit Mac applications and Mac users can purchase them through this store. Apple will handle all payment and give me 70%.
Questions, though. Will you need to build you application through XCode? Or, can you use any current Mac software development tool? I would be using Flash, of course. I could use a Flash “wrapper” of some sort, to add extra functionality. Will these kinds of applications be allowed in the App Store? Impossible to tell yet.
So lets assume that they are. Lets assume I can make a “projector” in Flash from one of my games and submit it to the App Store. Should I bother?
I haven’t distributed Mac/PC applications since 2007, I think. Maybe 2006. For a few years I tried selling those $19.95 “downloadable” games that were popular for a while. I didn’t make enough to make it worthwhile. I didn’t belong to one of those larger publishing systems that marketed the heck out of their games. They took too much control and too much of the profit. I would have rather worked for clients, which I did.
The one interesting note is that I think I made just as much from Mac sales as I did from the much larger PC market. I figured it had to do with the fact that Mac software was found on only a few sites, the main one being Apple’s own list of software. If you were there you didn’t need to be anywhere else, really. And it was free. Compared to the PC market where you had to be on dozens of sites, most of which charged.
But anyway, I’m thinking I will stay out of the Mac App Store. I’ll just enjoy it as a consumer, not a developer.

October 20, 2010 • Posted in: General • No Comments

Back in the (Flash iPhone Dev) Game!

It came as a complete shock to me that Apple reversed its decision about allowing Flash-developed iPhone apps in the store. Even after the press covered the story, I didn’t believe it until later that same day Apple approved my Pieces of Eight game. That game had been sitting in the App Store review process 5 months! I’m glad I left it in there.
But this reversal of policy actually does two things. First, it reverses the policy, of course. So now you can use Flash CS5 with the “Packager for iPhone” to build apps. But second, it legitimizes the whole thing. Before, you had to wonder what Apple thought. No action on their part would have meant no information. We wouldn’t know what Apple would do in the future. But by reversing the policy, they are now on the record as saying “this is OK.”
That doesn’t mean they can’t change their mind in the future. But it does give me some amount of confidence that they won’t.
So where to from here?
Well, first, I’m right in the middle of updating my Flash Games book. So I’ll be adding a chapter on building iPhone games. As soon as I’m done that, I’ll be going back to making new games for the iPhone.
Not sure what will be next. When Apple pulled the plug in April, I was about to make a series of free games that would promote my pay games. But since then I’ve experimented with using advertising to support apps. And that seems like a much better way for me to go. So perhaps I’ll work on some free games with ads. The current CS5 packager doesn’t have any support for Apple’s iAd platform, but it may be able to handle third-party ad platforms. I’ll have to investigate.
So right now I’m still in the planning stages, but by the end of the year I expect to be spending a lot of time making iPhone games again.

October 4, 2010 • Posted in: General • No Comments

Look Ma, No Plug-Ins!

So after my renewed enthusiasm for Flash died suddenly thanks to Apple, I turned my attention to my next game development project. My solitaire games site needed to be rejuvenated. I originally created it in 2002/2003 using Shockwave. It actually used Flash assets, but in the pre-AS3 world I needed Shockwave for speed and versatility. I created a main game engine and sets of rules for each solitaire game.
It worked well for a while, but it was harder to add new rule sets than I thought. And then Shockwave started to die. We went through that year or two when there was really no Shockwave for Macs, at least not Intel Macs with default settings. Then followed a year or two more of Shockwave working poorly on Macs. So I started planning a complete re-write of Just Solitaire in Flash using AS3.
If Flash had remained an app-building option for the iPhone and iPad, I would have continued along that route. But it didn’t, so I began to consider HTML5.
OK, I say “HTML5″ but what I really mean is JavaScript. It is just that JavaScript isn’t sexy. It is not taken seriously. But with the recent browser wars forcing each browser to perform better, JavaScript is now quite a fast and reliable scripting language.
And, as it turns out, more than capable of being used for solitaire games.
So I worked for more than a month on creating a whole new solitaire engine in JavaScript. And I love it. The new engine not only works better than the old Shockwave one, but it works in places that neither Shockwave nor Flash do: The iPhone, the iPad, Android devices, Linux Firefox, and so on.
So my first attempt to make a plug-in-less game site is a success. I am still working on it, making it better, but the main site is up and running, better than ever.

June 25, 2010 • Posted in: General • No Comments

Developing For Android Using Flash

One of the great things about using a tool like Flash to develop games is that I can take those games to new platforms, ones that didn’t even exist when the game was created. I made Gold Strike in 2003, using Flash 5 or MX. But now it is on the iPhone, and soon Android phones as well.
Adobe, who has continued to expand the Flash playback engine into new arenas, will be bringing Flash to Android phones in the form of AIR for Android. It is just in the beta test phase, and I’m thankful that I’ve been allowed to test it and then given permission to blog about it.
Here is a video of Gold Strike running on a Nexus One.

I’m excited about this because I hear that the Android Marketplace can actually be pretty decent. There are fewer Android phones out there, and fewer people with them buy apps, I’m sure. But there is also less competition.
I’m impressed at how well Flash performs. The game runs at top speed — as opposed to the slow speeds on the original iPhone and 3G. So the processor in the Nexus One seems to be equivalent to the iPhone 3GS or iPad. Or, maybe Adobe was able to do other things to speed up Flash.
The screen, of course, is another issue. The Nexus One has a 800×480 screen. This is interesting as it could make it possible to build some games that need more pixels than the iPhone screen has available at 480×320.

April 20, 2010 • Posted in: General • No Comments