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.

Posted on February 11, 2011 at 10:47 am by Gary Rosenzweig · Permalink
In: General

14 Responses

Subscribe to comments via RSS

  1. Written by Fernando
    on 2/11/2011 at 2:23 pm