Tuesday, September 21, 2010

Deploy to iPhone with Flex Builder: even better

I promise this is the last post about this boring topic.
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. If not, you can download it from here.

Ok, this is an even easier way to deploy to iPhone from Flex Builder 3 or Flash Builder 4. Just follow this steps and you will be ready to go in 2 minutes:
  1. Download these batch files and put them wherever you want. In these files you need to configure the variables PFI, PROV_PROFILE_PATH, CERTIFICATE_PATH and PASSWORD. In the debug batch files, you also need to change the ip address next to the -connect option by the ip of the machine running the debugger.
  2. Download the launch configurations from here. Inside the zip you will find 4 .launch files. Put them in <Flex Builder Workspace Path>\.metadata\.plugins\org.eclipse.debug.core\.launches and restart Flex Builder.
  3. Now, go to Run->External Tools->Open External Tools Dialog... . In the four launch configurations you need to adjust the Location field to point to the correct batch file downloaded in the step 1. You should see something like this:



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.


Sunday, September 19, 2010

Deploy to iPhone with Flex Builder

Edit: There is an improved version of this here.
Edit 2: There's an even better version here.

Follow these 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 RES_PATH=C:\Users\John\Documents\Flex Builder 3\Test\bin-debug
set PROV_PROFILE_PATH=C:\Users\John\Documents\Flex Builder 3\Test\bin-debug\John.mobileprovision
set CERTIFICATE_PATH=C:\Users\John\Documents\Flex Builder 3\Test\bin-debug\JohnDevCertificate.p12
set PASSWORD=123456
set APP_XML_PATH=C:\Users\John\Documents\Flex Builder 3\Test\bin-debug\Test-app.xml
set IPA_PATH=C:\Users\John\Documents\Flex Builder 3\Test\bin-debug\Test.ipa

cd %RES_PATH%

java -jar "%PFI%" -package -target ipa-test -provisioning-profile "%PROV_PROFILE_PATH%" -storetype pkcs12 -keystore "%CERTIFICATE_PATH%" -storepass %PASSWORD% "%IPA_PATH%" "%APP_XML_PATH%" "%RES_PATH%\Test.swf"

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.
In the Location text box, write the path to the Pack.bat file. You can use "Browse Workspace..." if the file is located inside your project directory or "Browse File System..." if not. You should get something like this:


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


This is valid for Flex Builder 3, but I think it should work with Flash Builder 4 too.

Hope it's useful to someone. Feel free to ask if something isn't clear.