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 Magic Leap Developer Tools - Install MLDB and mabu tools contained in the Lumin SDK, version 0.20.0 or later
Install Zero Iteration from The Lab's Package Manager - Required for the Simulator. Dependencies:
- Install Lumin Runtime SDK version 0.23.0 or later
- Magic Leap device running Lumin OS 0.95 or later
Get a Magic Leap Developer Certificate - Required to test apps on Magic Leap devices
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.
- 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.
- 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.
In The Lab, open the Activity Bar and select the CLI link ( >_ ). A command-line environment opens.
Verification: Confirm the Magic Leap SDK is available by typing: mldb
If MLDB is available, MLDB console help is displayed
In the command-line session, run the following command to download required packages and install them:
npm install --global magic-script-cliYou can safely ignore warning messages that appear regarding deprecated components
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:
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.
To set stable as the default version of Node.js for any new console window created, enter the following: nvm alias default stable
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.
- Open a command line from the Action Bar in The Lab.
- 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:
Press the Windows key to open the Start menu, type env, and then click Edit the system environment variables. The System Properties window opens.
Click the Environment Variables\'85.
Under System variables, click New.... The New System Variable window opens.
For the Variable name, type MLSDK.
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.
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
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