This post was originally published at Tutorial: Corona SDK to Corona Enterprise

With the recent announcement that Corona SDK is free, many previous Basic and Pro subscribers were given access to Corona Enterprise (available for Mac OS X only). However, some developers may not understand how to take advantage of it. This tutorial will help ease you into the Enterprise environment.

Requirements and Setup

For iOS, you will need a fully updated installation of Apple’s Xcode (this is standard requirement for Corona SDK iOS developers as well, so you likely already have it installed). When using Enterprise, almost all development tasks will be done via Xcode and Finder.

For Android, you will need to install the Android SDK and all of its build tools. While Eclipse and Android Studio can be used as an IDE environment, you may find that using the Terminal’s command line is easier.

Depending on the platform you wish to develop for, we recommended that you first read the download and setup sections contained within these tutorials:

1. Getting Started

For either iOS or Android, you should begin by copying a starter application template (folder) from this location on your system:

/Applications/CoronaEnterprise/ProjectTemplates/App

Copy the entire App folder to the location where you typically save your Corona SDK projects, then rename it to something logical such as the same name similar to your existing SDK project. If you put them in the same folder, it will need to be a name.  For this tutorial we will call it MyEnterpriseApp.

2. Adding Your Existing Corona SDK Code

Inside this folder is a subfolder named Corona and it contains a simple app which exhibits basic two-way communication. Simply overwrite everything in this folder with your Corona SDK project files (main.lua, config.lua, icon files, etc.).

At this point, you can continue to test your app in the Corona Simulator, except for any Enterprise features that you decide to add. As such, you should consider wrapping your Enterprise features in conditional checks to see if you’re running in the Simulator or not. For example:

When it’s time to test these native features, you’ll have to either test on an actual device or, for iOS, you can test via the Xcode Simulator.

3. Build Settings

For Corona SDK builds, the build.settings file is used to set and configure various aspects for the project’s build process. However, Corona Enterprise does not use the same build.settings file, so you’ll need to take a few extra steps. For iOS, this is done via a handful of settings within Xcode. For Android, most of the information will go into a file called AndroidManifest.xml.

For users familiar with Corona SDK, the build.settings file is made up of several major blocks, as outlined in this tutorial:

  • iphone
  • android
  • plugins
  • orientation
  • excludeFiles

The iphone section is for iOS settings and it contains information that generally goes into the app’s Info.plist file. For many of the items, there are ways to use the Xcode user interface and add the desired values, but some will require you to open the actual Info.plist file and add key-value pairs. See the following links for more details and instructions:

The android block contains information that generally goes into the AndroidManifest.xml file. This is a plain text file which can be edited with any text editor. See the following article for more details on this topic:

Plugins are handled differently within Enterprise and are discussed below in the “Using Plugins” section.

For iOS, the orientation block settings are managed within Xcode’s “project settings,” and for Android, these will be controlled from the AndroidManifest.xml file.

The excludeFiles block is not relevant to Enterprise — if you wish to exclude files, just do not include them within the project.

4. Using Plugins

Plugins are fairly simple to work with in Corona Enterprise. Unlike Corona SDK, you don’t need to include plugins within the build.settings file, although you should probably do so just in case you want to create an SDK build at some point during development.

To obtain the most current plugins, please visit the Daily Builds download page and select the “Corona Enterprise” tab along the top. Once there, look for a link similar to CoronaEnterprisePlugins.2015.2576.tgz. Ensure that you download the package that matches the version of Enterprise that you’re using. Inside the downloaded package, you will find the compiled binary versions of each plugin.

iOS

On iOS, plugins build out to Unix library files which have a .a extension (i.e. libmyplugin.a).

For Corona Enterprise, simply open up the project in Xcode:

MyEnterpriseApp/ios/App.xcodeproj

In the left column of the Xcode window you’ll see the Navigator panel which can help you organize the project and add files. Note that this is not a direct representation of all the actual files/folders within the project, but rather a symbolic organization tool. In a new Finder window, open the CoronaEnterprisePlugins.*.* package. Then navigate to the desired plugin’s iphone folder and drag-and-drop the *.a file into Xcode’s Navigator panel. This will add the plugin to the project and give you the opportunity to have it copied in as well. You’ll need to repeat this step for each plugin that you need.

In addition, some plugins require extra frameworks be added to your project from within Xcode. For instance, the iAds plugin requires the iAd.framework. Similarly, AdMob requires several frameworks including:

  • AdSupport
  • AudioToolbox
  • AVFoundation
  • CoreGraphics
  • CoreTelephony
  • EventKit
  • EventKitUI
  • MessageUI
  • StoreKit
  • SystemConfiguration

Some of these frameworks are already in your Xcode project, while others must be explicitly added. Each plugin varies in what frameworks are required, so you should research the plugin or the plugin’s SDK to help determine which frameworks are required for iOS.

Android

Android uses .jar files (Java Archive files). These are the Java equivalent of the C-based .a files that Xcode uses.

Inside your Corona Enterprise project’s android folder (for example MyEnterpriseApp/android/), you will see several .xml and .sh files, along with a folder named src. To include your plugins, you’ll need to create a directory named libs inside the same folder (alongside src) and copy your .jar files inside it. These .jar files are located within the downloaded CoronaEnterprisePlugins.*.* package, inside the respective plugin’s android folder.

Building Plugins for General Usage

If you create and build plugins for your app using Enterprise, you cannot use them with your SDK build even if you add them to build.settings. SDK builds require the plugin to be hosted either by Corona Labs, a designated third party, or as self-hosted plugins (only available for Corona Enterprise Unlimited subscribers).

Building the Project

If you have your plugins in place and your Corona SDK files in the Corona folder, you’re ready to build the project. This process differs for each platform, so please refer to the previous tutorials for step-by-step instructions:

In Summary

Native development can be a daunting venture for people who have never touched on native development, but once you follow through the process a few times, converting a Corona SDK project to Corona Enterprise becomes second nature. Additionally, as you learn more about Java, Objective-C, and/or Swift, you can implement all kinds of powerful native features within your Corona-built app.


Read More: 

This post was originally published at Tutorial: Corona SDK to Corona Enterprise