# Control Which Files ShipThis Uploads

> Use platform-aware globs in shipthis.json to control which files are uploaded for iOS and Android builds.

Source: https://shipth.is/docs/guides/controlling-uploaded-files

When you run the command [`shipthis game ship`](https://shipth.is/docs/reference/game/ship) your game files are selected, compressed into a zip, and uploaded to the backend.

ShipThis gives you full control over which files get uploaded by using **globs** in your project config file `shipthis.json`.

::::info What is a glob?
A glob is a way of pattern matching on file names. It is a string which includes special **wildcard** characters which match on multiple files.

Some examples:

- `**/*` matches all files
- `android/**` matches everything in `android`
- `*.ipa` matches IPA files
- `.gradle/**` matches everything in `.gradle`

Read more about globs on Wikipedia https://en.wikipedia.org/wiki/Glob_(programming)

::::

## How the globs are used

The `shipthis.json` file will contains a **"globs"** value which should look something like:

```json
{
  "globs": {
    "base": {
      "include": ["**/*"],
      "exclude": ["...common ignores..."]
    },
    "android": {
      "exclude": ["ios/**", "*.ipa", "*.xcarchive"]
    },
    "ios": {
      "exclude": ["android/**", "*.apk", "*.aab", ".gradle/**"]
    }
  }
}
```

This **"globs"** value has base values which are always used and then platform-specific values which are used when the tool is **only** building for those platforms.

Each has an **"include"** and an **"exclude"** - these are arrays of globs. When they are used, the **"include"** values are used first, and then **"exclude"** values are used to remove items.

When you run `shipthis game ship` the tool does the following:

1. Determines which platform(s) are selected 
  - If you specify a platform with the `--platform` option or if you have only configured a single platform then this is the selected platform.
  - If you have configured both platforms, and are not specifying a platform then both are selected.
2. Collects the base glob rules and the rules for the selected platform(s)
3. Uses the globs to find all of the matching files
4. Zips, uploads, runs the build.

### Examples

- `shipthis game ship --platform ios`
  - This will use **"base"** and then **"ios"**
- `shipthis game ship --platform android`
  - This will use **"base"** and then **"android"**
- `shipthis game ship` with no `--platform` 
  - Checks which platforms you have configured

## Upgrading from legacy globs

Previous versions of shipthis used a different format for these rules. Without the platform specific features.

Legacy projects may still use:

- `shippedFilesGlobs` (include rules - equivalent of `globs.base.include`)
- `ignoredFilesGlobs` (exclude rules - equivalent of `globs.base.exclude`)

::::info If you have not edited these values

Good news! If you have not edited these values in your `shipthis.json` file then shipthis will use the new default values for globs which include platform specific excludes to reduce the size of uploaded files and speed up builds.

::::

If your `shipthis.json` file contains the old-format (legacy) globs then shipthis will display one of the following messages:

### Warning "Using legacy default globs"

```bash
Using legacy default globs - you should upgrade to the new globs. Learn more: https://shipth.is/docs/guides/controlling-uploaded-files
```

This is displayed if you have NOT changed `shippedFilesGlobs` or `ignoredFilesGlobs`. To make the message go away, you can run:

```bash
shipthis game export --current --force
```

This will overwrite your `shipthis.json` file with an updated version of the file which includes the new glob format.

### Warning "Using legacy custom file selection globs - you should upgrade to the new globs"

```bash
Using legacy custom file selection globs - you should upgrade to the new globs. Learn more: https://shipth.is/docs/guides/controlling-uploaded-files
```

This warning is displayed if shipthis detects that you HAVE edited the `shippedFilesGlobs` or `ignoredFilesGlobs` values. In this scenario, shipthis will use your `shippedFilesGlobs` and `ignoredFilesGlobs`. You should manually apply your custom globs to the new format `shipthis.json` file by referring to the example above.

## Related

- [`game ship` command reference](https://shipth.is/docs/reference/game/ship)
- [How your code is handled](https://shipth.is/docs/guides/code-handling)
