1.0 MagicScript Setup

MagicScript projects are written in JavaScript and use the tools in the Lumin SDK to package and install apps on Magic Leap devices. This topic walks you through setting up your workspace for creating MagicScript apps. In addition to common JavaScript development tools, MagicScript development requires the Lumin SDK that includes the Magic Leap Builder (mabu) and Magic Leap development bridge (MLDB) command-line tools.

Pre-requisites

Before you begin developing MagicScript projects, complete the following:

Install Node.js

Node.js is an open-source, cross-platform environment that lets JavaScript run outside a browser. Install and set up Node.js along with any required dependencies. This process also install NPM on your machine.

  1. Download and install the latest long-term support (LTS) version of Node.js from https://nodejs.org. Node.js version 12.10 or later is recommended for MagicScript. During installation, include additional content required for dependencies support, if prompted.
  2. Verification: Type node at the command prompt. Welcome to Node.js v<version> displays if Node.js is installed.

Install MagicScript Tools

The CLI (command-line interface) tool for MagicScript (magic-script) provides options to speed MagicScript development setup by creating template projects. The CLI also lets you build and run your app with minimal knowledge about the underlying developer tools used.

These steps assume you have installed all the software requirements.

  1. In The Lab, open the Activity Bar and select the CLI link ( >_ ). A command-line environment opens.

    Expand the Action Bar and then select the command-line icon

  2. Verification: Confirm the Magic Leap SDK is available by typing: mldb

    If MLDB is available, MLDB console help is displayed

  3. In the command-line session, run the following command to download required packages and install them:

    npm install --global magic-script-cli

    You can safely ignore warning messages that appear regarding deprecated components

  4. macOS users only: If you receive permission errors or warnings, you can install Node.js without super-user privileges with NVM (Node Version Manager) by following these steps:

    1. In a terminal session, enter:

      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

      For additional information or if you need support with installing and using NVM, see https://github.com/nvm-sh/nvm#install-script.

    2. To set stable as the default version of Node.js for any new console window created, enter the following: nvm alias default stable

  5. Verification: Confirm magic-script is installed by typing: magic-script

MagicScript console help displays in the terminal. If you run magic-script --version, the current version number is returned after a successful installation.

Command Line Environment Setup

To run magic-script commands, you must add the MLSDK to your computer's path environment variable. You should also add your developer certificate to the path so you can install apps on Magic Leap devices. The following steps configure your command-line interface for either a single session or multiple sessions.

Single Session

Single-session configuration automatically updates the environment path variables to the latest path of your MLSDK tools. Perform these steps each time you open a new terminal session.

  1. Open a command line from the Action Bar in The Lab.
  2. Create an MLCERT variable with the location of your developer certificate. <location/of/.cert> below is the path to your developer certificate (.cert) file.
    • Windows - In command line, enter set MLCERT=<location/of/.cert>
    • macOS - In command line, enter export MLCERT=<location/of/.cert>

Multi-session

Environment variables can be configured so that whenever a terminal session is open the specified Magic Leap SDK and your Magic Leap Certificate path are already set. If you set these variables, you must manually update the environment variables and paths, including the MLCERT variable, whenever you need an updated SDK or change the location of your certificate files.

Windows:

Perform the following steps:

  1. Press the Windows key to open the Start menu, type env, and then click Edit the system environment variables. The System Properties window opens.

  2. Click the Environment Variables\'85.

    Set Windows environment variables

  3. Under System variables, click New.... The New System Variable window opens.

  4. For the Variable name, type MLSDK.

  5. For Variable value, click Browse Directory..., navigate to the latest supported Magic Leap SDK version (for example, C:\Users\name\MagicLeap\mlsdk\<version>), and click OK.

  6. Repeat steps to add an MLCERT variable and set the value to the location of your developer certificate (.cert) file.

macOS:

Open a terminal, navigate to your home directory and edit or create the .profile file. Add the following lines to the .profile file: source ~/MagicLeap/mlsdk/<version>/envsetup.sh

export MLCERT=<location/of/.cert>

Where:

  • <version> is the version of the Lumin SDK as it appears in the path
  • <location/of/.cert> is the path to the location of your developer certificate (.cert) file