Thanks mostly to the great work done by the author of the FlashDevelop template we installed earlier there should be a .bat file in your project folder that we will use to automate the .ipa compile. I’ve edited it a bit to work with the current packager (note, the zip package from Part Two has since been revised, download the latest template files here). Before we run the .bat file make sure you have both your Provisioning Profile and your .p12 Certificate file in the “certificates” folder of your Project. (the FlashDevelop template will have created this Certificates folder for you). A word of warning, the .bat is set up to search for iphone_dev.mobileprovisions and iphone_dev.p12 so you can either rename your files or edit the .bat file to look for whichever filenames you have, the choice is yours.
Pointing to the Hybrid Flex/Air SDK
The only edit we need to make to the “PackageApplication.bat” file is to tell it where to find the Flex SDK on your machine. Open up the file in a text editor and look to the line where the FLEX_SDK value is set. Copy and paste the correct location to the Hybrid SDK you made as it sits on your harddrive. Remember to specify the bin folder and place in a trailing slash “” at the end. Save and close the .bat file. I’d suggest going in to the template yourself and hardcoding in your Flex SDK path so that it’s a one off task that you won’t have to repeat for other projects.
Next we will open up the “application.xml” file in your project folder (again automatically created by the template) and do a bit of editing. You’ll see that there are a few options you can set to change the properties of your app but for now we will just focus on the one necessary to make the compile. In particular we need to set the ID of the app in the first XML node of the application (named “id”). Make this value the same as the Bundle ID you entered in to the Provisioning portal for your app, so in my case it will be com.codeandvisual.myawesomeapp
Pressing the Go Button
Close the application.xml file and double click on the PackageApplication.bat file to run it. It will take you through a few simple steps in order to create your output .ipa file.
For the first option you can choose  test to create a test build and press enter.
Next you will be prompted to enter in your password. This is the password you created when you exported the .p12 certificate from Keychain Access on the Mac. Type it in and press Enter
If all has gone well your computer should have started compiling and you can go grab a coffee while you wait for it to finish, which should take a minute or two. The .bat file has got some fairly good error reporting if there have been any issues so read the output carefully and you should be able to sort through it.
In Part 5 we reach the pay off and will finally upload our app onto our iOS test device.