These are the docs for 13.3, an old version of SpatialOS. The docs for this version are frozen: we do not correct, update or republish them. 14.5 is the newest →

Building from the Command Line Interface (CLI)

This page covers building using the spatial command-line tool.

After you’ve made code changes to a project, you should build it.

You don’t need to build the whole of a SpatialOS project at the same time. What you build depends on what changes you’ve made to it:

If you’ve changed the schema

Any time you change the schema (for example, add or change a component), you need to regenerate the generated code, and fix code references.

Don’t forget to keep your schema backwards-compatible.

1. Build schema changes

  1. Generate code from the schema:

  2. Fix any code references that are broken by the schema changes.

  3. Run spatial worker build <worker type> for any relevant workers.

You can then use your IDE to modify your code that uses the generated code.

2. Migrate the initial snapshot

If you change the schema, you’ll need to migrate your initial snapshot to the new schema, or generate a new one.

You can manipulate the snapshot using the worker SDKs. See the docs for C++, C#, or Java for details.

If you’ve changed worker code

1. Build worker code

When you’ve made a change to the code of your worker, run spatial worker build <worker type>. This runs the ‘build’ task for the worker, which normally puts the resulting assets within build/assembly. See build configuration for details.

2. Update the initial snapshot

You must update your initial snapshot (or generate a new one) if you make any changes that affect what’s in the snapshot. This includes (but isn’t limited to):

  • adding or removing entities in the initial state (by changing the code which adds them)
  • changing the number of entities in the initial state (by changing the code which adds them)
  • changing the template (used to spawn an entity) of any entity that’s in the initial snapshot, including
    • adding components to the entity
    • removing components from the entity

To update the initial snapshot, use the worker SDKs. See the docs for C++, C#, or Java for details.


To clean the results of code generation and build, run spatial worker clean <worker type>](/reference/13.3/shared/spatial-cli/spatial-worker-clean). This runs the ‘clean’ task for the worker. See build configuration for details.

To clean the whole project, run spatial worker clean. This also removes the build directory at the root of your project.

Building workers offline

You can use spatial worker build to build workers offline, so you can iterate on local projects without an internet connection. For more information, see Using the spatial CLI offline for local projects.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums