.mpk format used by C++ applications except in this case there is no native code in the
Magic Leap SDK
The Magic Leap SDK is needed to run applications on an actual device. Detailed instructions can be found in the creator portal. For MagicScript development, all that is needed from Package Manager is the Lumin SDK that includes the
mldb command-line tools.
Make sure you've also created a developer certificate according to the instructions in the portal.
Once you have these, it's a good idea setup your command-line environment to use them. For example on MacOS and assuming you installed mlsdk v0.20.0, add the following to your shell startup config.
%USERPROFILE%\MagicLeap\mlsdk\v0.20.0\envsetup.bat SET MLCERT=c:\path\to\downloaded\certificate.cert
source $HOME/MagicLeap/mlsdk/v0.20.0/envsetup.sh export MLCERT=/path/to/downloaded/certificate.cert
Verify that you have
mabu in your path and that
$MLCERT is set and points to your developer certificate.
MagicScript CLI Tool
In addition to the SDK, there is a helpful command-line tool known as
magic-script that helps with MagicScript applications.
This tool is written using node.js. Make sure you have node and then install the CLI tool with npm.
npm install --global magic-script-cli
Verify this worked by checking for
magic-script in your path.
Create a new Project
For your first project, use the
magic-script init command to generate a scaffold from a template. For example:
magic-script init my-app com.example.my-app "My App"
The template changes over time, but it generates a tree structure something like this:
my-app/ ├── app.mabu ├── app.package ├── manifest.xml ├── package.json ├── rollup.config.js └── src ├── app.js └── main.js
manifest.xml file is pre-populated with the values set in the init command and most the other top-level files are build configuration and package metadata. The interesting part is the
src/app.js file where customized code goes.
Open this folder in your favorite code editor. We recommend Visual Studio Code.
Build and Install
Build and install your application by attaching your device and running the following in your new project folder:
# Enter the project directory cd my-app # Plugin in device and verify it's connected mldb devices # Build and install the application onto the device. magic-script build -i
For your information, This internally performs several steps:
- Installs local npm dependencies with
npm installto get rollup and plugins.
- Uses rollup to bundle
- Generates a
bin/index.jsexecutible with the
#!/system/bin/script/mxsshebang line that imports user code.
digest.sha512.signedwhich is a digest of all files in
bin/*.jssigned by your developer certificate.
mabu build ...to bundle this into a mpk.
mldb install ...to install the mpk on the device.
Run your application in debug mode with:
Internally this does a couple things:
- Launches the app using
mldb launch ....
- Reads the output of
mldb logto see the web inspector port and forwards it over USB to a local port using
mldb forward ....
If all goes well, you'll eventually see a success message and a chrome-inspector url that can be copy-pasted into Chrome to remotely debug the application.