Posted on by

While we just posted a tutorial on Understanding “build.settings” a few days ago, we’d like to update it and notify the developer community of a new feature in Corona: the ability to exclude certain files from your app builds!

Excluding Files

In the previous tutorial we discussed four primary sub-tables which can be included within the build.settings file, covering orientation, iOS settings, Android settings, and plugins. Now, utilizing Daily Build #2364 or later, you can add another table called excludeFiles which allows for selective exclusion of specific files or pattern-matched files on a global or per-platform basis.

Here’s an example:

settings = 
{
   excludeFiles = 
   {
      all = { "*secret.txt", "artwork/*" },
      iphone = { "Icon-*dpi.png", "audio/*.ogg" },
      android = { "Icon.png", "*@2x.png", "audio/*.m4a" }
   },
},

Many apps won’t need this feature, but more sophisticated apps can utilize it, resulting in a reduced app bundle size, especially if it uses larger device-specific media files like audio or video. You can even include a folder in your project to hold original artwork, promotional files, and other items that you use when developing your project, but don’t want to include in the final product delivered to users.

The excludeFiles table may contain three sub-tables:

  • all — exclude these files regardless of the platform.
  • iphone — exclude these files for iOS devices.
  • android — exclude these files for Android devices.

There’s only one simple pattern matching option: an asterisk (*) which is considered a “wildcard” that can be placed anywhere in the string. This asterisk matches anything including the slash (/) that separates folders. For instance: *.png would match every PNG file, even in folders.

Warning!

Because the pattern matching can be too aggressive if used carelessly, it’s imperative that you check your built app bundles and make sure that all intended files are included (and that all files intended for exclusion are actually excluded). You should also monitor the console carefully during the build process and watch for any alerts that may indicate an issue with the exclusion process.

In Summary

This feature is now available to Pro and Enterprise subscribers through Daily Builds, and it will be available to Starter and Basic subscribers in the next public build release.

For future reference, the excludeFiles feature is documented in the Project Build Settings guide.


Posted by . Thanks for reading...

14 Responses to “New Feature: Excluding Files from Builds”

  1. Joe

    Nice feature. It’s very usable especially when I started to use two differents set of audio files for iOS & Android recently.

    Reply
  2. Andreas

    That’s perfect! I always had to copy files around to build for the different platforms (e.g. in iOS I use a tutorial video clip, on Android because of some problems with video on some older devices I use static bitmaps for the tutorials).

    Now there is one less thing to take care of when I build updates, and that’s great!

    Thanks & best,
    Andreas

    Reply
  3. Thomas

    Thanks, cool addition. This allows me to keep my Photoshop and Texturepacker source files in the project folder, but still build without them.

    Reply
  4. JCH_APPLE

    Very useful feature. I’m using fireworks and layered PNG that I flatten when ready, I can now keep them in the same folder and exclude them very easily. Congrats for this (

    Reply
  5. Ed Maurina

    Good job guys! This is a lot of help for those of us who target many stores. I know I often ended up with one final version of my game per store simply to keep the different assets separated. i.e. The code was the same, but I used different assets for different stores and devices sold via those stores (Google Play, Amazon, Apple, …)

    Oh, and now I can keep my source images in the folders. This is awesome! I used to have to keep a sources folder separate from the project. No more!

    So, thanks!

    Reply
  6. Rob Miracle

    Plugins are excluded on a plugin-by-plugin using the supportedPlatforms key. For instance with iAds, since it’s iOS only:

    settings =
    {
    plugins =
    {
    ["CoronaProvider.ads.iads"] =
    {
    publisherId = “com.coronalabs”,
    supportedPlatforms = { iphone=true, ["iphone-sim"]=true },
    },
    },
    }
    This feature is just about excluding files that are in your project folder.

    Reply

Leave a Reply

  • (Will Not Be Published)