Moving a Corona App to Corona Enterprise Guide. Advice required.

Moving App from Corona to Corona Enterprise

This guide outlines the steps required to move your Corona SDK app to Corona Enterprise for iOS on the Mac. It covers general setup and also using existing Corona plugins. This is my first time using Xcode, therefore I am 100% sure there are better ways of approaching this, so if anyone sees anything that doesn’t sound right please jump in and correct me.

Note: Requires full Enterprise license for plugins (not just trial).

Assumes you have been working with Corona SDK already on your system and have now got a licence for Corona Enterprise. Also assumes you have created your signing certificates / certificates see: [https://docs.coronalabs.com/guide/distribution/iOSBuild/index.html].

Download and Install Xcode

Download and install Xcode. These notes refer to Xcode v6.2

Add your Apple Developer account to Xcode. Xcode -> Preferences -> Accounts.

Download Corona Enterprise and Enterprise Plugins

Go to:

https://developer.coronalabs.com/downloads/daily-builds/

Click the “Corona Enterprise” tab.

Select a version, for example, 2015.2635, and then download both:

CoronaEnterprise.2015.2638.tgz CoronaEnterprisePlugins.2015.2638.tgz

Once downloaded, extract both Tars.

“Install” Corona Enterprise

Move the extracted CoronaEnterprise folder to /Applications.

Creating App

First we must create an Xcode App, and the easiest way of doing this is to use the default project template provided my Corona Enterprise.

Navigate to /Applications/CoronaEnterprise/ProjectTemplates/App

Copy the App folder to another location, such as the Desktop.

Rename to the folder to your desired app project name.

Modify App

Change project name

Change the name of the project by clicking once on the word “App” in the list item in the left column, then enter the new name.

ce-image-1.png?raw=1

Another dialog will pop-up asking if you would like Xcode to do some renaming for you, select “Rename”.

Change the Bundle Identifier, Version, Build

Bundle Identifier

Update this and ensure it is unique. You cannot change the last part of bundle identifier in this text box, you must change that in the previous way we changed the Project Name (see above).

Example bundle identifier:
 

com.myexampleapp.MyApp

ce-image-2.png?raw=1   

Version and Build

From what I understand, the Version number is the user facing version number, for example: 1.2

Whereas the Build number is the number of the build. Conventionally this is incremented by 1 with each new build of the app.

Unfortunately I am not that hot on version numbering, so if anyone has some advice / corrections that would be great.

Provisioning Profiles

If you don’t already have a provisioning profile in place for your app, Xcode can create one for you if you press the “Fix Issue” button.

I did this for the demo, but for my other app I already had provisioning profiles and certificates in place.

Note: I have already setup my Developer Account in Xcode, and cannot remember how I did this, so you will need to do this.

Edit the Deployment Info, Devices, Device Oritentation

Edit the settings for your app.

ce-image-4.png?raw=1

Add “Other Linker Flags”

Add the required “Other Linker Flags” to the Build Settings -> Linking section.
   

-ObjC -lobjc -lsqlite3

ce-image-6.png?raw=1

Reference

Note: these instructions are from the brilliant tutorial:
 

https://coronalabs.com/blog/2014/03/18/tutorial-corona-enterprise-quickstart-ios/

Run!

Select an iPhone simulator from the menu.

ce-image-7.png?raw=1

Hit the menu item Product -> Build.

If you get any strange errors, it’s worth trying Product -> Clean , and then Prodcut -> Build. That sometimes clears errors with missing files.

Hopefully it successfully builds, then you can press the play button in the window and it should build again and send to the simulator.

Further Setup

Now that you have a fully working demo, we need to customise the project for your needs.

Capabilites

Select the top item in the left panel (Project name).

Select “Capabilites” from the horizontal nav in the middle of the window.

Now turn On or Off the features you need.

See Image: https://www.dropbox.com/s/bcgbbbfmbeji0ms/ce-image-8.png?raw=1

Rename the name of the App

If you need a different name of the actual app (the name that appears under the icon on iOS) then select “Info” from the nav in the middle of the window.

Find “Bundle display name” in the list, and change this to your desired name.

Then run the App, and once running on your iphone it should be named the name you chose.

Please note: As of yet I have not shipped an Enterprise App. Therefore I cannot gurantee that this is a correct method of naming your app. If anyone else has advice on this please let me know.

ce-image-9.png?raw=1

[Refrence (does not have the same instructions, but has similar instructions): http://stackoverflow.com/questions/238980/how-to-change-the-name-of-an-ios-app/20418989#20418989 ]

Remove ‘sdk-facebook’ reference

Go to “Build Settings” in the main horizonal nav in the middle of the window.

Scroll down until you find ‘Search Paths’ -> ‘Framework Search Paths’.

Now remove that path to “sdk-facebook”.

I believe (please correct me if I am wrong) that this approach is an old method, and Facebook now comes as a plugin.

Copy across your working Corona files

Now you need to move your existing working files from Corona into the Corona directory. You may do this by copying, or alternatively, you may symlink your existing directory that contains your Corona app project files.

In this example I actually used the Corona Example Code, “Notifications”. SampleCode/Notifications/LocalNotifications. I used this one because it allowed me to test if adding plugins (next section) actually works.

Adding existing plugins

Chances are that you are using existing Corona plugins, therefore, when you run your app, you will be presented with a message saying something like:
 

module ‘plugin.notifications’ not found:resouce (plugin.notifications.lu) does not exist in archive

   
So, and I am not sure this is the best way to do it, but this is the way I have successfully managed to get it working:

  • Go to the directory you extracted the Enterprise Plugins to earlier.
  • Find the required plugin folder (in this case notifcations)
  • Go into the ‘iphone’ directory
  • Now drag the plugin (ie: “libnotifications.a”), into the left column in Xcode which contains the file structure, onto “CoronaEnterprise/lib”
  • Tick the checkbox for “Copy items if needed”

Fix the error we just introduced

Since dragging a plugin into Xcode, we seem to have introduced an error.

If you test this by trying to build, and you’ll get an error like:
 

“clang: error: linker command failed with exit code 1 (use -v to see invocation)”

   
Now, this is a direct result of dragging the plugin into Xcode.

To fix this, we need to go to the “Build Settings” menu in the main horizontal middle nav. Scroll down to “Search Paths” -> “Library Search Paths” and you will notice that the path to /your/path/ios/CoronaEnterprise/Corona/ios/lib appears to have quotes around it “”

Remove those quotes, re-build and we should be good to go.

Add your remaining required plugins

Since the error is fixed, we can now add the remaning plugins we need and that error shouldn’t re-introduce itself to us.

Another error

Doing these steps a few times, an error did occur which I hadn’t seen before:

"\_OBJC\_CLASS\_$\_SKMutablePayment", referenced from:

The reason for this was because the “AdSupport.framework” and “StoreKit.framework” librarys were missing. Adding these back into the “Linked Frameworks and Libraries” section in “General” fixed the error.

Finished

If all went successfully, hopefully we now have our Corona SDK app running via Corona Enterprise and Xcode.

What’s Next?

Plugins

Well, it’s a safe assumption that you’ve bought Corona Enterprise because you want to build plugins. Fortunately, you’re in luck. As mentioned ealier, the excellent “Tutorial: Corona Enterprise Quickstart (iOS)” https://coronalabs.com/blog/2014/03/18/tutorial-corona-enterprise-quickstart-ios/ is a fantastic guide to creating your first plugin.

Combine that tutorial with the Open Source Corona Enterprise plugins: https://github.com/coronalabs/plugins-source and you should be able to cobble together a plugin in no time.

I must admit though, that I do not know how to build multiple plugins in one project yet.

Building for shipping

Well, this is something that is causing me a little conern. As most of the tutorial above, whilst does seem to work, has been patched together from various sources and a bunch of trial and error, I have no idea if it’s correct and even suitable for App Store release.

If anyone has experience in submitting a Corona Enterprise app to the App Store, I would be hugely greatful if you could spare a little time to outline the steps required to get it ready.

From what I have read, I believe you need to create an “Archive”. Not sure what that means yet…

Some general warnings

In the current build there are a few warnings hanging around the left hand side of Xcode.
 

It appears we are Missing “Default-568h@2x.png”.

There are also some “Update to recommended settings” warnings, which I assume are fine to do, but I have not done yet.

See image: https://www.dropbox.com/s/r7fn5tg8bw642o7/ce-image-13.png?raw=1

Anyone have comments about these?

App Icons

Another thing that confuses me a little, is that when I build my App and run on my device, it pulls the correct icon from the Corona folder. I’m not sure how this is doing that - I guess that the project is configured to look into the Corona folder.

However, when I added Crashlytics (which is really straightforward - just follow their Wizard guide thing), the Crashlytics website didn’t pull through the App Icon - so not sure if that’s a Crashlytics issue or a project setup issue.

General notes about this thread

When creating this thread I reached the limit of allowed quote blocks and images. Would it be possible to increase this limit for the future?

This was incredibly useful thank you, I have just been going through all of this pain the last day or so and you saved me a bunch of time.  Great post!

You’re welcome! Glad it could be of some help :slight_smile:

Great info and Really Useful - I will add a few more tips I have found when I get back to my office…  Appreciated…

Brilliant :slight_smile: It’ll be great to get some tips!

I will add some Objective-C basic programming notes soon!

This was incredibly useful thank you, I have just been going through all of this pain the last day or so and you saved me a bunch of time.  Great post!

You’re welcome! Glad it could be of some help :slight_smile:

Great info and Really Useful - I will add a few more tips I have found when I get back to my office…  Appreciated…

Brilliant :slight_smile: It’ll be great to get some tips!

I will add some Objective-C basic programming notes soon!