IntelliJ IDEA

This document aims to help you set up IntelliJ IDEA to use with Starling for desktop and mobile development.

If you find an error or a missing step, or if you have some other suggestion that might make things clearer for beginners, please help us out by enhancing this document! Just hit one of the Edit buttons and write away.

Preparations

  1. Make sure that Flash/Flex support is turned on in IDEA.
    • For this, navigate to Preferences → Plugins and check if “Flash/Flex Support” is activated.
  2. Download the latest AIR SDK from here.
    • Once downloaded, extract the archive and save it to a location you remember.
  3. Let IDEA know about Flex/AIR SDK
    • Navigate to File → Project Structure → SDKs. Then click on the “+” button, choose Flex/AIR SDK and navigate to the AIR SDK on your disk.
    • (Optional) Switch to the Documentation Paths tab in the same dialog window, click on the “+” button with a globe, and add the following URL:
      http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/
  4. Specify Starling as a Global Library
    • In the same window (File→Project Structure), click on Global Libraries in the list on the left. Then click on the “+” button.
    • Choose Actionscript/Flex, then specify this folder: [path-to-starling]/starling/src. Make sure it's added as Raw ActionScript library, not as Library sources.
    • In my case, the library was now simply named “src”, which is confusing. Rename it to “Starling” via the “Name:” text field.

Creating a Project that uses Starling

  • Navigate to File → New Project → Flash
  • Choose your target platform (Web/Desktop/Mobile)
  • Enable Pure Actionscript
  • Make sure that that Flex/AIR SDK you've previously added is selected.
  • Alter the other options as you see fit, then hit Next.
  • Now choose name and location for the project & click on Finish.
  • Finally, before starting to write your code, add Starling as a global library to your module.
    1. Navigate to File → Project Structure → Global Libraries.
    2. Find the Starling library you've added previously.
    3. Right-click on it and select Add to modules. Choose your module (you have only one for now) and hit OK.
  • Alternatively, you could also first select the module in the “Project Structure” window, then enter the “dependencies” tab and click on the “+” button on the bottom. The “Project or Global Library” selection will reveal Starling.

Creating the application descriptor

This step can be skipped if you are working on a project that targets the Flash Plugin.

All AIR projects need a special application descriptor XML file to run. IDEA will create one automatically, but to be able to run your app using direct rendering, you'll need to alter a few things, so it's good to have such a file added to your project and not being recreated every time you hit build.

  • Again, navigate to File → Project Structure.
  • Click on Modules and select your module.
    • For Desktop AIR Apps: Click on AIR Package tab and select Custom template instead of Generated which should be selected by default.
    • For Android and iOS Apps: Click on Android or iOS tab (either one should do) and select Custom template instead of Generated which should be selected by default.
  • Click Create. You don't need to change anything in the popup window.
  • Click OK to get back to the IDE main window and open the file you've just created.
  • Locate the renderMode element, uncomment it and change it to <renderMode>direct</renderMode>.
  • Whenever you update your AIR SDK, you will need to update the XML schema definition at the very top. The version number of the schema must be the same as the AIR SDK version. (IDEA will show you an appropriate error when that happens.)

Running the app

  • To start the app, right-click on the startup-class and select Run [Module Name].
  • This will create a default run configuration that you can modify by your needs in the dialog found in Run → Build Configurations.
  • To make a release build of an AIR application, click on Build → Package AIR Application.
    • On iOS, be sure to deactivate “fast packaging”. Only “ad hoc distribution” and “Apple App Store distribution” will yield the maximum performance.
    • On Android and Desktop, you can optionally use the “Captive Runtime”, which means that users won't have to install the AIR runtime.
  • To make a release build of a Web project (SWF), deactivate “Generate debuggable SWF” in the “Compiler Options” of the module settings.

Running on 'iOS Simulator'

The build configuration also supports running the app in the official iOS Simulator from Apple (on macOS only). However, it doesn't provide a way to choose the actual device being simulated (iPhone x, iPad?).

To do this, you need to set the environment variable AIR_IOS_SIMULATOR_DEVICE via the terminal to the corresponding value, for example:

launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPhone 4s"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPhone 5"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPhone 5s"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPhone 6"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPhone 6 Plus"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPhone 7"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPhone 7 Plus"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPad 2"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPad Retina"
launchctl setenv AIR_IOS_SIMULATOR_DEVICE "iPad Air"

For reference: the String you have to use it the exact text you see in the “Hardware / Device” menu of the iPhone simulator. Beware:

  • The strings are case-sensitive!
  • You need to restart IntelliJ so that it picks up a changed value.
  • Refer to this document to find out the exact strings available on your system.
This forum post contains several great tips about how best to set up your IntelliJ modules for multi-platform development: My Thoughts after Completing my first Starling App.
  manual/intellij_idea.txt · Last modified: 2018/02/09 09:21 by daniel
 
Powered by DokuWiki