Exporting for iPhone using Air 2.7 and FlashDevelop – Part Four, Creating an Air Certificate and Compiling to .IPA


Share:

Continuing on from Part Three of the Exporting for iPhone using Air 2.7 and FlashDevelop Tutorial You should should now have your Apple Developer account and certificates ready to package up your app. In this part we will compile the .swf into an .ipa file ready to transfer onto an iOS device for testing.

Putting everything in the right place

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.

Exporting for iPhone using Air 2.7 and FlashDevelop - Part Four, Creating an Air Certificate and Compiling to .IPA

Editing application.xml

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.

  1. For the first option you can choose [1] test to create a test build and press enter.
  2. 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.

Next

In Part 5 we reach the pay off and will finally upload our app onto our iOS test device.

Index

Part 1 – Installation
Part 2 – Creating an iPhone Project
Part 3 – Generating Developer Certificates, Provisioning Profiles and .p12 Files
Part 4 – Creating an Air Certificate and Compiling to .IPA
Part 5 – Loading your .IPA File onto a Test Device

Share:

  • You should add the “interpreter” targets, they are *very* fast to package and run really well: ipa-test-interpreter, ipa-debug-interpreter

  • Hi Philippe, I find that the main reason to test on a device is to make sure the performance is still satisfactory. Interpreter mode would not be so useful in this regard as the code runs slower than normal. In most cases it makes sense to do your debugging on your computer as you can skip the step of packaging and transfering onto a test device all together.

    Having said that, I’ve updated the .bat file in the template to include the interpreter mode now, thanks for the suggestion.

  • Hey there,

    This tutorial has been great but I am trying to create the IPA and keep getting the compilation error 305: initial window content swf version 11 exceeds namespace version…..

    Do you have ides on how to solve this?

  • I’m getting stuck with an error when trying to create the IPA. After the “please wait about 3 minutes” text, I get error 305: Initial window content SWF version 11 exceeds namespace version http://ns.adobe.com/air/application/2.0

    Any ideas?

    I’ve tried changing “2.0” to “2.7” (don’t think your suppose to do that), but I just get two other errors; error 103 and 104: application.versionNumber is required

    • Hi Ken, looks like Robbie above had the same issue – please see his solution. I personally compile to 10.1 and it works fine, you might be able to up this to 10.3 by now also.

  • Hi Ken, glad it worked.

    In regards to iPad, I don’t have a test device so I can’t be sure on that one but it will probably involve editing the application.xml file and entering in an ipad section. you will probably also want to change requestedDisplayResolution from “standard” to “high”. You’ll also want to change the stage size of your project.

    Please feel free to share this information if you sort it out.

  • Robbie, how did you “rolled the -flex config back to Flash player 10”?? Where in FlashDevelop we do that? thanks!!

  • when i run the PackageApplication.bat ,an error occurred :application.version is an unexpected element/attribute , application.versionNumber is required
    the value of element version is 1.0 in myapplication.xml
    and xmlns=”http://ns.adobe.com.air/application/2.0″
    i tried to change the value 2.0 to 2.6 or 2.7 ,than another error occurred :Intial window content SWF version 11 exceeds namespace version http://… …2.0
    can you understand me? i’m sorry my english is so poor , i’m Chinese ,look forward to you reply ,thanks

    • Hi Heyao, hmm.. not sure about that one. However the second error sounds like it’s related to Robbie’s issue above – try setting the Flash player version to 10 in your Project>properties dialog.

  • I’ve rolled my flash player back to v 10 in the project properties but I’m still getting the same error as those above:
    application.xml: error 305: Intial window content SWF version 11 exceeds names
    pace version http://ns.adobe.com/air/application/2.0

    I’m using the latest Flex SDK with the latest Air copied over it (the ‘hybrid’ mentioned in this set of tutorials) and Flash Develop 3.3.4.

    Any thoughts would be super helpful! Thanks.

    • Hi Josh, the error message is the same so I’d expect it to be the same issue. It’s explicit in naming that SWF version 11 as the problem so I’d focus on making sure the swf that is being targeted by the .bat file is indeed version 10.

  • Thanks for the response. I’ve specified Flash Player version 10.0 in the project properties but still the same problem.

  • ADL also gives me an error saying “Error loading initial content” when I compile the project in FlashDevelop using the template provided. Should the node of the ‘application.xml’ document be: ? It seems like there should be a 2.7 on the end to reflect the latest version. However, I’ve tried putting 2.7 it doesn’t work.

  • Sorry the node I was talking about reads: application xmlns=”http://ns.adobe.com/air/application/2.0″

  • hi author,
    i keep having failure with these configuration, so far can’t find a working configuration yet. please help.
    i get the lastest zip from your modification from german bloger.
    i also play around with the AIR 2.0 and AIR 2.7, still getting error of version 11 exceed names etc…

    ** no luck
    flash develop 4.0 beta.
    project property platform AIR 2.0
    set FLEX_SDK=C:Program Files (x86)FlashDevelopToolsflexsdkbin

    ** no luck
    flash develop 4.0 beta.
    project property platform AIR 2.0
    set FLEX_SDK=D:_flashsdkAdobeAIRSDKbin

  • my UI is flash develop 4.0 beta.

    my batch file for IOS packager,

    :: Path to Flex SDK binaries
    rem set FLEX_SDK=D:_flashsdkflex_sdk_pfibin
    rem set FLEX_SDK=C:Program Files (x86)FlashDevelopToolsflexsdkbin
    rem set FLEX_SDK=D:_flashsdkAdobeAIRSDKbin
    set FLEX_SDK=D:_flashsdkflex_sdk_adtbin

    the combine sdk is according to the guide, i hope it is correct. AIR SDK overwrite FLEX SDK. both download from http://www.adobe.com/products/air/sdk/ and http://www.adobe.com/cfusion/entitlement/index.cfm?e=flexsdk

    and i get these…

    iPhone IPA generator

    Thanks, password input done.

    IPA creation may take up to 3 minutes, please be patient
    ——————————————————–
    D:_flashexerciseiPhone AIR 2application.xml: error 305: Intial window conten
    t SWF version 11 exceeds namespace version http://ns.adobe.com/air/application/2
    .0
    ——————————————————–
    ERROR: IPA creation FAILED.

    Troubleshotting: did you configure the Flex SDK path in this Batch file?

    Press any key to continue . . .

  • i found that flash develop default sdk is something like hybric AIR+FLEX.

    i compare 2 sdk folder, below is the statistics. C drive has original FlashDevelop4, D drive has hybrid according to the guide in this blog.

    Compare C:Program Files (x86)FlashDevelopToolsflexsdk with D:_flashsdkflex_sdk_adt
    9/8/2011 8:30:24 AM
    Filename,Folder,Comparison result,Left Date,Right Date,Extension
    10.0,frameworkslibsplayer,Left only: C:Program Files (x86)FlashDevelopToolsflexsdkframeworkslibsplayer,* 4/8/2011 2:18:17 AM,,0
    10.1,frameworkslibsplayer,Left only: C:Program Files (x86)FlashDevelopToolsflexsdkframeworkslibsplayer,* 4/8/2011 2:18:17 AM,,1
    10.3,frameworkslibsplayer,Left only: C:Program Files (x86)FlashDevelopToolsflexsdkframeworkslibsplayer,* 4/8/2011 2:18:17 AM,,3
    11.0,frameworkslibsplayer,Left only: C:Program Files (x86)FlashDevelopToolsflexsdkframeworkslibsplayer,* 9/8/2011 7:01:11 AM,,0
    9.0,frameworkslibsplayer,Left only: C:Program Files (x86)FlashDevelopToolsflexsdkframeworkslibsplayer,* 4/8/2011 2:18:17 AM,,0
    FlashDevelopNotice.txt,frameworkslibsplayer,Left only: C:Program Files (x86)FlashDevelopToolsflexsdkframeworkslibsplayer,* 4/8/2011 2:18:17 AM,,txt
    bundles,frameworksprojectsmobilecomponents,Right only: D:_flashsdkflex_sdk_adtframeworksprojectsmobilecomponents,,* 9/8/2011 8:14:13 AM,
    11.0,runtimesplayer,Left only: C:Program Files (x86)FlashDevelopToolsflexsdkruntimesplayer,* 9/8/2011 6:41:56 AM,,0

  • Hi j2, a bit of information overload there but I am seeing “11.0” listed on the last line of the dump, this is standing out as red flag.

  • actually i am mixing

    AIR SDK 2.7

    into

    – Flex 4.5.1 4.5.1 21328

    i dun have Flex 4.5.0.19786 as shown in the screenshot.
    i guess that should not be matter right?

    thx for your prompt reply…

    btw, i am using win7, 64bit version. i have java 32bit installed with environment set.

    D:_flashexerciseiPhone AIR 2>adt -version
    2.7.0.20020

    D:_flashexerciseiPhone AIR 2>java -version
    java version “1.6.0_26”
    Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
    Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

  • the version 11.0 is coming together with FlashDevelop4 Beta which reside in program files x86.
    i set the packager batch file FLEX_SDK to point to the hybrid sdk adt.
    i can’t find what is wrong there.

    • Thanks Emibap, when I get the chance I will test that and add it to the Template package. If anyone wants to beat me to it please feel free to update and send me a zip.

  • if you (as described above) run into the errors
    “application.version is an unexpected element/attribute”
    and “application.versionNumber” is required
    that seems to be because the structure of the application.xml has changed in the newer SDK versions.
    Just rename the XML Node “version” to “versionNumber”.

  • Josh: the error “Error loading initial content” occurs, if no SWF was created yet. So hit “Ctr”+”Enter” to publish the SWF, after that you should be able to do the packaging.

    • Hi Bas, woah, that looks like an error that has it’s roots elsewhere. Sorry I don’t know much about the java side bit it could be some sort of corrupted or incompatible install of java on your system.

  • Hi, great tutorial!

    I only have one question,

    When running the .bat file I get the following error “could not retrieve certificate chain from keystore”

    I created both my .mobileprovision & .p12 file on a mac, then transfered them to my pc, put them in the certificates folder and I get this error.

    Did a quick research on the net and apparently, .p12 files created on mac cannot work on pc, any help?

    Thanks in advance

    • Hi Seb, as described in the tutorial I create my .p12 files on the mac and have no problems using it on the PC. The mobile provisioning file is created on the server by Apple so again that shouldn’t make any difference.

  • hi,

    When executing the PackageApplication.bat it generates this error:

    IPA creation may take up to 3 minutes, please be patient
    ——————————————————–
    ADT does not support 64bit java for IPA targets
    ——————————————————–
    ERROR: IPA creation FAILED.

    Troubleshotting: did you configure the Flex SDK path in this Batch file?

    I’ve followed all steps of the tutorial.
    I’m on win7 64bit and java 32 bit is installed.
    The flex SDK path is correctly sets.

    What can i do to fix this ?
    Thanks

    (Sorry for not explain better, my english is very poor as you can see :p)

    • Hi Valandre, In order to fix this problem on a 64 bit machine you should try and enter an absolute path to your 32 bit java install in the adt.bat file.
      adt.bat is located in your {hybrid flex directory}/bin/ folder. If you open this in a text editor you can replace the @java shortcut with the absolute path (put it in “” quotation marks if you have any spaces or special characters in the path).

      Hopefully that should do the trick.

  • @j2:
    In FlashDevelop 4, in project properties windows, go to tab Compiler Options and see “adtional compiler options”. By default is set to: “-swf-version=11”, change it to: “-swf-version=10”.

    @someone help me!!:
    I get this error generation IPA:

    IPA creation may take up to 3 minutes, please be patient
    ——————————————————–
    Exception in thread “main” java.lang.IllegalArgumentException: Comparison method
    violates its general contract!
    at java.util.TimSort.mergeLo(Unknown Source)
    at java.util.TimSort.mergeAt(Unknown Source)
    at java.util.TimSort.mergeCollapse(Unknown Source)
    at java.util.TimSort.sort(Unknown Source)
    at java.util.TimSort.sort(Unknown Source)
    at java.util.Arrays.sort(Unknown Source)
    at adobe.abc.Algorithms$Pool.sort(Algorithms.java:377)
    at adobe.abc.GlobalOptimizer$Abc.sort(GlobalOptimizer.java:2668)
    at adobe.abc.GlobalOptimizer.emit(GlobalOptimizer.java:2788)
    at adobe.abc.LLVMEmitter.optimizeABCs(LLVMEmitter.java:438)
    at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:247)
    at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcodeImpl(AOTCompiler
    .java:446)
    at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGenerator.java:81)
    Compilation failed while executing : ADT
    ——————————————————–
    ERROR: IPA creation FAILED.

  • I get the same error … please help:

    IPA creation may take up to 3 minutes, please be patient
    ——————————————————–
    Exception in thread “main” java.lang.IllegalArgumentException: Comparison method
    violates its general contract!
    at java.util.TimSort.mergeLo(Unknown Source)
    at java.util.TimSort.mergeAt(Unknown Source)
    at java.util.TimSort.mergeCollapse(Unknown Source)
    at java.util.TimSort.sort(Unknown Source)
    at java.util.TimSort.sort(Unknown Source)
    at java.util.Arrays.sort(Unknown Source)
    at adobe.abc.Algorithms$Pool.sort(Algorithms.java:377)
    at adobe.abc.GlobalOptimizer$Abc.sort(GlobalOptimizer.java:2668)
    at adobe.abc.GlobalOptimizer.emit(GlobalOptimizer.java:2788)
    at adobe.abc.LLVMEmitter.optimizeABCs(LLVMEmitter.java:438)
    at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:247)
    at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcodeImpl(AOTCompiler
    .java:446)
    at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGenerator.java:81)
    Compilation failed while executing : ADT
    ——————————————————–
    ERROR: IPA creation FAILED.

  • I tried to compile ipa file with these settings but after getting message about three minutes I got an error about how command java was not recognized as internal or external command, executable program or commandline file. The error is my direct translation from Finnish so it’s not word on word.

    Anyway it looks like java is not found…? What I should do to make it work? I have Win7 64bit. I tried to edit adt.bat file by adding path to java.exe file but it didn’t work (though I’m not sure how it should been inserted).
    Any help?


Creative Digital Agency

Code and Visual works with clients around Australia to create and build outstanding and accessible digital services. If you want to discus a project contact us now for an initial consultation.


Categories

Recent Posts