Monday, September 20, 2010

Deploy to iPhone with Flex Builder: improved

First, I must say I'm new to Flex Builder and to flash development in general; so maybe there is a better way of doing this. And also I'm not very good writing in English; that's the reason of the grammar mistakes and the weird writing style. Hope the info to be useful anyway.
I think this is a better solution that the one in the previous post, because this solution is more flexible to be used in different projects.

These are the new steps:

1. First, you need the Packager for iPhone from Adobe. If you have installed Flash CS5, you can find the packager in %ProgramFiles(x86)%\Adobe\Adobe Flash CS5\PFI or %ProgramFiles%\Adobe\Adobe Flash CS5\PFI.


2. Create a file Pack.bat with this content: 

set PFI=C:\Program Files (x86)\Adobe\Adobe Flash CS5\PFI\lib\pfi.jar
set PROV_PROFILE_PATH=C:\Users\John\Documents\PackagerForIphone\Provisioning\John.mobileprovision
set CERTIFICATE_PATH=C:\Users\John\Documents\PackagerForIphone\Provisioning\JohnDevCertificate.p12
set PASSWORD=123456

set SWF_PATH=%1
set APP_XML_PATH=%2
set IPA_PATH=%3

set ADD_RES1=%4
set ADD_RES2=%5
set ADD_RES3=%6
set ADD_RES4=%7
set ADD_RES5=%8
set ADD_RES6=%9

java -jar "%PFI%" -package -target ipa-test -provisioning-profile "%PROV_PROFILE_PATH%" -storetype pkcs12 -keystore "%CERTIFICATE_PATH%" -storepass %PASSWORD% %IPA_PATH% %APP_XML_PATH% %SWF_PATH% %ADD_RES1% %ADD_RES2% %ADD_RES3% %ADD_RES4% %ADD_RES5% %ADD_RES6% %ADD_RES7% %ADD_RES8% %ADD_RES9%


or download it from here.

You need to change the paths to point to where you have each corresponding item in your machine.

3. In Flex Builder, go to Run->External Tools->Open External Tools Dialog... and create a new launch configuration by clicking in the little button with the plus symbol. You need to fill the following fields:
Location: write the path to the Pack.bat file.
Working Directory: the directory where the .swf is. Usually is the directory bin or bin-debug inside the project directory.
Arguments: the parameters to be passed to Pack.bat. It's important you put them in the same order the .bat reads them. If you use the posted .bat, then the order is:
  1. Path to .swf file
  2. Path to application descriptor xml
  3. Path to output ipa file
  4. And then additional resources in no particular order(icons, Default.png, etc)

The Default.png and icons must be in the same directory that the .swf, and the paths are relative to this directory.
You should get something like this:


Note the use of variables like project_loc and project_name instead of the hardcoded path. This allow us to use the tool in different projects without change anything.

4. Now, after building your project as usual, go to Run->External Tools->Pack

Right now I'm working in some performance tests in my spare time. I'll post the results if I find something interesting.


2 comments:

  1. can you share your flash builder project and your bat file in a zip??? that would rock!

    ReplyDelete
  2. oh, I'm sorry, I missed that link, thank you!

    and I found this other post: http://iphoneflashdev.blogspot.com/2010/09/i-promise-this-is-last-post-about-this.html

    ReplyDelete