Build an App for iPhone or iPad with FlashDevelop

Mar 17, 2012   //   by Lorenzo Nuvoletta   //   AS3, Blog, iOS, Mobile  //  7 Comments

This guide contains the essential steps to build an App for iOS using FlashDevelop and Windows, I will not stop trying to explain what I am doing or why I am doing it, sometimes it gets so obscure that I don’t even know, just do it and it will work…. hopefully. Of course before you even start reading this make sure to pay the $99 fee to the Apple bloodsuckers to become an iOS developer.

Let’s Start

  • Install OpenSSL for Windows.
  • Create a new project with FlashDevelop selecting AIR Mobile AS3 App
  • Open CMD (Start, serach program cmd) and execute the following commands:
  1. cd C:\OpenSSL-Win32\bin (or wherever path you installed OpenSSL)
  2. set OPENSSL_CONF=c:\OpenSSL-Win32\bin\openssl.cfg
  3. set RANDFILE=.rnd
  4. openssl genrsa -passout pass:fd -out mykey.key 2048
  5. openssl req -new -key mykey.key -out CertificateSigningRequest.certSigningRequest -subj “/emailAddress=yourAddress@example.com, CN=Your Name, C=US” (Don’t forget to change your name and email)

Creating the Certificate

  • Go to https://developer.apple.com/ios/manage/certificates/team/index.action - Certificates->Development Tab, Click on Request Certificate and upload the file CertificateSigningRequest.certSigningRequest that is in your OpenSSL bin. Submit and refresh the page a couple of times until it says DOWNLOAD. Download that file and put it in your OpenSSL bin.

Adding the Device

Create App ID

  • Go to https://developer.apple.com/ios/manage/bundles/index.action and Click on New APP ID and add a name and an unique id. (Unique ID has to be the same you have in the application.xml in the FlashDevelop Project, that ID is set as default “air.MobileSomething” you should change it to something like “com.yourname.yourappname”, also remember to change the same APP_ID in SetupApplication.bat)

Create a Provisioning Profile

  • Go to https://developer.apple.com/ios/manage/provisioningprofiles/index.action and Click New Profile. Check everything, continue and refresh the page a couple of times until you see Download.
  • Download the file in the folder “cert” in your FlashDevelop Project.
  • Go to iTunes, File-Add File to Library… and import this file. (iTunes will not prompt you with any message, so to souble check you did it right try to reimport it).

Create the p12 file

  • Open CMD (Start, serach program cmd) and execute the following commands:
  1. cd C:\OpenSSL-Win32\bin (or wherever path you installed OpenSSL)
  2. set OPENSSL_CONF=c:\OpenSSL-Win32\bin\openssl.cfg
  3. set RANDFILE=.rnd
  4. openssl x509 -in ios_development.cer -inform DER -out developer_identity.pem -outform PEM
  5. openssl pkcs12 -export -inkey mykey.key -in developer_identity.pem -out iphone_dev.p12 (When prompted to enter the password, write fd, or whatever password you used to create the key)
  • Copy the iphone_dev.p12 in your “cert” folder in the FlashDevelop Project

Setting the FlashDevelop Project

  • In the “bat” folder edit the file SetupApplication.bat

From line 18:

set IOS_DIST_CERT_FILE=cert\iphone_dev.p12
set IOS_DEV_CERT_FILE=cert\iphone_dev.p12
set IOS_DEV_CERT_PASS=fd
set IOS_PROVISION=cert\YourFileName.mobileprovision

Create the IPA

  • Execute the file PackageApp.bat in your FlashDevelop Project.
  • Select 8 “ad-hoc” and when prompted to enter password, enter: fd
  • Wait few minutes and you should see a IPA file in your “dist” folder
  • Import the IPA in iTunes and Sync.

 

At this point you should have your App running on your iPhone/iPod/iPad. This whole process is crazy, I don’t know why Apple doesn’t do anything to make it simpler. Try to do the same thing on Android it will take you not more than 5 seconds, but anyway, we all want to make the Apple gods happy.

For your reference I used this guides:

ConnorUllmann.com

Codeandvisual.com

Emanueleferonato.com

Share if it helped you!

    7 Comments

    • Great explanation of the certificate and profiles creation!
      Ad-hoc isn’t the fastest packaging option: check the project template’s readme.
      Also iFunBox is much better to install the IPA.

      • Thanks Philippe, I noticed that the same code behaves differently if compiled ad-hoc or with the interpreter. I need to try the iFunBox. Would be nice to have a debugger in FlashDevelop for iOS similar to the one for Android, without having to manually load the app all the times.

        • You can debug iOS apps from FD. Check the readme ;)

          • Well yea, but you still need to manually install the debug version on your device otherwise it wont connect to the debugger, yesterday I was trying to debug a nasty part of my code and I had to install/uninstall the app a dozen of times :D

        • I wonder if HockeyKit would give you a faster iteration time. You could have the build process automatically upload to the server, and then your app would automatically detect that it needed to download the new version. Still a little clunky, but fewer manual steps. (disclaimer: have not tried this myself yet)

    • Hi,

      This worked like magic and it saved me a lot of hours and hair pulling. Thank you! I now want to add another device. I figured I need another mobile provisioning file, do I also need to re-make the p12 file?

      Thanks
      Tim

    • Hi, this works fine… but there is a simple information about iPad deploy. You can restrict the deployment changing the application.xml (manifest). You can add iPad support or not, just uncomment the string line over 2

    Leave a comment

    August 2014
    M T W T F S S
    « Mar    
     123
    45678910
    11121314151617
    18192021222324
    25262728293031