Build-time properties for an app are defined using a optional build.settings
file written in Lua syntax. It should be placed in the project's base directory.
This guide outlines the most common build settings for apps across the various platforms that Solar2D supports. For those developers who require more advanced settings, please consult the Advanced Build Settings guide for which options are available.
At the minimum, the build.settings
file should contain a settings
table which will contain various child tables to dictate
settings = { -- Child tables here }
The build.settings
file can be used to set app orientation in relation to the device's physical orientation in space — this includes
Please note that there are three different things which are subject to orientation:
All orientation settings must be contained in the orientation
table within settings
:
settings = { orientation = { -- Parameters }, }
Within the orientation
table, there are two optional key values: default
and supported
:
settings = { orientation = { default = "", -- Initial launch orientation supported = {}, -- Table of allowed options for auto-orientation }, }
Each of these accepts the following orientation conventions:
Name | Orientation |
---|---|
"portrait" |
Device in the vertical position with the home button at the bottom |
"portraitUpsideDown" |
Device in the vertical position with the home button at the top |
"landscapeLeft" |
Device in the horizontal position with the home button at the left |
"landscapeRight" |
Device in the horizontal position with the home button at the right |
On most devices, auto-orientation is triggered by the accelerometer if the device is rotated or flipped during runtime. If you want to limit an app to either landscape orientation, specify both "landscapeLeft"
and "landscapeRight"
in the supported
table.
supported = { "landscapeLeft", "landscapeRight" },
Similarly, to limit an app to either portrait orientation, specify both "portrait"
and "portraitUpsideDown"
:
supported = { "portrait", "portraitUpsideDown" },
When the device orientation changes, the coordinate position (0,0)
on the display stage will correspond to the top-left corner of the current orientation.
The iPad ignores the default
setting and attempts to launch in the current physical orientation of the device, assuming that orientation is specified in the supported list.
If you ever need to detect the current device orientation, it can be read from the system.orientation property. This will provide a value from the four standard conventions listed above. In addition, iOS devices may report either the "faceUp"
or "faceDown"
orientation.
Within the settings
table, you can include a plist
table nested within an iphone
table. This plist
table is used to set values for the compiled app's Info.plist
file.
settings = { iphone = { plist = { CFBundleIconFiles = {}, -- Required! UILaunchStoryboardName = "LaunchScreen", -- Required! UIStatusBarHidden = true, CFBundleDisplayName = "Solar2D App", CFBundleName = "Solar2D App", }, }, }
The iphone
table encompasses all iOS devices, not just iPhone devices.
For boolean values in plist
keys, use true
or false
)YES
or NO
)
In the example above, a few common plist
keys are shown:
CFBundleIconFiles
(table) — a required table of app icon image files to associate with the app. See Custom App Icons below for details.
UILaunchStoryboardName
— a required string pointing to a valid .storyboardc
file. See Launch Screen — iOS below for important details.
UIStatusBarHidden
(boolean) — specifies if the status bar should initially be hidden when the app launches.
CFBundleDisplayName
(string) — the display name of the bundle. If you do not need to localize the app and the bundle name contains only ASCII characters, omit this key and specify the bundle name as Application Name in the Simulator Build for iOS window. If you localize the app (guide), include this key in both the plist
table and in the InfoPlist.strings
files of your language CFBundleName
keys.
CFBundleName
(string) — a short app name of 16 characters or less. If the bundle name contains only ASCII characters, omit this key and specify the bundle name as Application Name in the Simulator Build for iOS window. If you localize the app (guide), this key should be included in the plist
table and also alongside CFBundleDisplayName
in the InfoPlist.strings
files of your language CFBundleName
key in the plist
table, but do not include the CFBundleDisplayName
key.
Please see Apple's documentation for more information on supported values and what you can do with them.
On iOS, when accessing certain hardware or plist
table of build.settings
. For example:
settings = { iphone = { plist = { NSCameraUsageDescription = "This app would like to access the camera.", NSPhotoLibraryUsageDescription = "This app would like to access the photo library.", NSPhotoLibraryAddUsageDescription = "This app would like to add the photo library.", }, }, }
When the system prompts the user to allow access, the associated description is displayed as part of the alert. Note that the descriptions can be customized to your preference and they can even be localized (guide).
The following APIs are affected by iOS permissions, so you should include the permission key(s) noted in the associated API documentation if you're using any of these commands:
saveToPhotoLibrary
is true
saveToPhotoLibrary
is true
saveToPhotoLibrary
is true
eventName
of "accelerometer"
In addition to the iOS settings mentioned above, the following build options are available as outlined in the Advanced Build Settings guide:
Setting/Feature | Purpose |
---|---|
Device Capabilities | Used to restrict your app to installation on devices with specific capabilities. |
PNG Processing | Used to circumvent PNG file processing (pngcrush ) at build time. |
Within the settings
table, you can include an android
table to control build settings for Android devices.
settings = { android = { }, }
You can override the version code entered into the Simulator Build for Android box with an optional versionCode
build.settings
file. This is an internal number used to distinguish application releases for the Android app store, corresponding to the versionCode
item detailed here. This setting is invisible to users.
settings { android = { versionCode = "11", }, }
The version code must be specified as an integer — it cannot contain any decimal points. One possible scheme is to set versionCode
to "10"
for version 1.0. The next update would be "11"
for version 1.1, and so forth.
The usesPermissions
table creates <uses-permission>
AndroidManifest.xml
file:
settings { android = { usesPermissions = { "android.permission.INTERNET", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION", }, }, }
In the example above, a few useful android.permission
keys are exhibited:
"android.permission.INTERNET"
— permits an application to access the Internet."android.permission.WRITE_EXTERNAL_STORAGE"
— allows media.save()
and camera support."android.permission.ACCESS_FINE_LOCATION"
— allows access to GPS."android.permission.ACCESS_COARSE_LOCATION"
— allows getting the location from WiFi/cellular.See the Android documentation for more information on supported values and what you can do with them.
The usesFeatures
table creates <uses-feature>
AndroidManifest.xml
file. These parameters tell the Android app store which hardware/software capabilities the app does or doesn't require. See the Android features reference for a list of supported values.
settings { android = { usesFeatures = { { name="android.hardware.camera", required=true }, { name="android.hardware.location", required=false }, { name="android.hardware.location.gps", required=false }, }, }, }
If you require a feature (required=true
), devices lacking the feature will not be able to download or purchase the app. As a precaution, if your app uses the feature for some aspects but does not require it for "basic functionality," you should include the feature within the usesFeatures
table but set its required
key to false
:
{ name="android.hardware.camera", required=false },
The usesExpansionFile
boolean indicates if the app should be built with expansion files. If it's set to true
and the build target is Google Play, everything in the project directory except the Lua scripts are put into the expansion file. See the Android documentation for more information.
settings = { android = { -- This tells the Simulator to create an expansion file usesExpansionFile = true, -- The following permissions are required to download expansion files usesPermissions = { "android.permission.INTERNET", "com.android.vending.CHECK_LICENSE", "android.permission.WRITE_EXTERNAL_STORAGE", }, }, }
Using expansion files requires setup of Google licensing. Please see here for details.
In addition to the Android settings mentioned above, the following build options are available as outlined in the Advanced Build Settings guide:
Setting/Feature | Purpose |
---|---|
Minimum SDK Version | Allows you to exclude your app from being installed on devices with older versions of Android. |
Android TV | Required if you are deploying an app to Android TV. |
Screen Support | Specifies/limits which screens an Android app supports. |
Disabling File Access | Used to block all access to your app's files. |
Large Heap | Requests that the Android OS provides your app with more heap memory. |
Android Directives | Used to AndroidManifest.xml in your application. |
For macOS desktop or Win32 desktop apps, build.settings
file supports a window
table for customizing the app's desktop window:
settings = { window = { }, }
Please see the example within Creating macOS Desktop Apps or Creating Win32 Desktop Apps for details and a complete list of acceptable window
parameters.
Solar2D offers several plugins which can be used in your projects. These plugins can be included via the plugins
table nested within the settings
table:
settings = { plugins = { }, }
For example, the Google Play Games Services plugin may be included as follows:
settings = { plugins = { ["plugin.gpgs"] = { publisherId = "com.coronalabs" }, }, }
Plugin key names often include punctuation, for example plugin.gpgs
. In these cases, you must use the "brackets and quotes" method of defining the key (["plugin.gpgs"]
).
Before deploying an app, you should design the proper app icons for the targeted platforms.
For iOS, several icon files are required. Please see the Managing Xcode Assets guide for a reference on the Images.xcassets
folder and how to include/reference it within your app.
Google has changed how Android icons are managed with Android 8 and later, using Adaptive Icons. Starting with daily build 2019.3504 and later, icons are now handled using the AndroidResources
folder. See our guide on Adaptive Icons for more information.
For Android, icon files will be copied into the .apk
during the build, assuming they are available in your root project folder main.lua
)
File | Size (w×h) |
---|---|
Icon-xxxhdpi.png |
192 × 192 |
Icon-xxhdpi.png |
144 × 144 |
Icon-xhdpi.png |
96 × 96 |
Icon-hdpi.png |
72 × 72 |
Icon-mdpi.png |
48 × 48 |
Icon-ldpi.png |
36 × 36 |
Desktop apps — applications built for macOS or Windows — require additional icons as follows:
For macOS desktop apps, you must add a Icon-osx.icns
.icns
file (details). See the Creating macOS Desktop Apps guide for more information.
For Windows desktop apps, you must add a Icon-win32.ico
.ico
file (details). See the Creating Win32 Desktop Apps guide for more information.
Apps designed for TV systems require additional icons:
For Apple's tvOS, several unique icons and assets are required. Please see the Managing Xcode Assets guide for a reference on the Images.xcassets
folder and how to include/reference it within your app.
For Android TV, you should include a Banner-xhdpi.png
By default, a Solar2D branded splash screen will appear when the app opens. This splash screen can be customized or disabled.
If you'd like to display your own custom splash screen, include the splashScreen
table within build.settings
as above, but set the enable
key to true
and add an image
key defining the image name. For instance:
settings = { splashScreen = { enable = true, image = "mySplashScreen.png" }, }
Alternatively, you can customize the splash screen on a
settings = { splashScreen = { ios = { enable = true, image = "mySplashScreen_iOS.png" }, android = { enable = true, image = "mySplashScreen_Android.png" } }, }
For customized implementation, image
indicates the path to any image file in the project. The image will be displayed on a black background and it will match the default orientation of the app, scaled to fit the screen of the current device. You may need to experiment to arrive at the ideal image for your splash screen, but if it's large enough for the largest device your app is intended to run on, you only need one image.
Because build.settings
does not apply to app builds performed via Solar2D Native, special handling is required to customize the splash screen in these instances:
For iOS, place an image named _CoronaSplashScreen.png
in the root of your app bundle, specifying it as a "resource" in Xcode.
For Android, place an image named _corona_splash_screen.png
within res/drawable/
using whatever mechanism is appropriate in Android Studio or otherwise.
To remove default splash screen, add the splashScreen
table to the project's build.settings
with the enable
key set to false
:
settings = { splashScreen = { enable = false }, }
Alternatively, you can remove the splash screen on a
settings = { splashScreen = { ios = { enable = false }, android = { enable = true } }, }
For iOS, you must include some form of launch screen support. Apple recommends that you utilize an
For your convenience, a default (blank) LaunchScreen.storyboardc
document is automatically added to all new project templates. The same file is also bundled with the application itself, in case you need to copy it over to existing projects. It can be found within the Solar2D application folder here:
/Applications/Corona/Resources/Resource Library/iOS/LaunchScreen.storyboardc
The Xcode storyboard document can be customized with your own images/layout — see our guide for instructions.
If you use the default LaunchScreen.storyboardc
file in an existing project, you must include the UILaunchStoryboardName
key within the plist
table so that iOS recognizes the existence of the file. Notice that the key's value ("LaunchScreen"
) matches the name of the file itself, minus the file extension:
settings = { iphone = { plist = { UILaunchStoryboardName = "LaunchScreen", -- Required! }, }, }
Excluding files is a feature of Solar2D — it does not work for Solar2D Native builds.
More sophisticated apps may have files which are needed on one platform but not another. For example, the icon files for each platform are different and you might want to include only the appropriate files on each platform. This is not something Solar2D handles automatically, since file naming may vary and unique situations can't be predicted. Most developers will not need to specify files which should be excluded from builds, but the option is available if necessary.
Files to be excluded are specified ios
, android
, macos
, win32
, tvos
, all
—*
means any string of characters, sometimes including /
. In other words, these patterns match the path names of files in the app bundle as strings. This generally only matters if you have an elaborate directory structure with multiple instances of directories with the same name at different levels, for example a/music
, a/b/music
, a/b/c/music
, etc. Note that the directory separator character is always a forward slash /
, even if building on Windows.
File exclusion is a powerful facility and it's possible to corrupt your app bundle if you use this procedure unwisely and accidentally exclude files critical to its operation. After making any changes to the excludeFiles
setup, monitor the console carefully during the next build and watch for any issues. You should also examine the contents of your app bundle carefully and check exactly which files are included.
Consider these examples on how to exclude various file names and types:
settings = { excludeFiles = { -- Exclude unnecessary icon assets from all builds all = { "Icon*.png", "Images.xcassets", "Icon*.ico", "Icon*.icns" }, }, }
settings = { excludeFiles = { -- Exclude iOS launch screen bundle on Android devices android = { "LaunchScreen.storyboardc" }, }, }
settings = { excludeFiles = { -- Exclude all files at all paths which end with "secret.txt" all = { "*secret.txt" }, }, }
settings = { excludeFiles = { -- Exclude all .aac files in the "music" directory on Android devices android = { "music/*.aac" }, -- Exclude all .ogg files in the "music" directory on iOS devices ios = { "music/*.ogg" }, }, }
settings = { excludeFiles = { -- Exclude unnecessary assets from macOS desktop apps macos = { "Icon*.ico" }, -- Exclude unnecessary assets from Win32 desktop apps win32 = { "Icon*.icns" }, }, }