Overview

This article covers how to get started with enaml-native and create your first app.

The process is:

  1. Install the miniconda
  2. Install the SDKs and tools (Android and/or iOS dependencies)
  3. Install the enaml-native-cli
  4. Create a new project
  5. Run the app

Instructions for each step is described below.

System dependencies

enaml-native uses the conda package manager.

Download and run the installer from conda.io/miniconda.html.

Once installed you should be able to run conda --version from the command line to see which version you have and make sure it was installed correctly.

Next the Android and iOS SDK's need installed.

App dependencies

Android SDK
  1. Download android studio
  2. Once done, open it and go to Tools->Android->SDK Manager from the menu
  3. Under the SDK Platforms tab, select the latest
  4. and under the SDK Tools tab, select Android SDK Build-Tools <version>, Android Emulator, Android SDK Platform-Tools, and Android SDK Tools (they should be selected by default)
  5. Now click apply and let everything download

iOS

iOS apps can only be built with a mac or macbook running OSX.

You must install xcode from the App Store before continuing.

Installing the enaml-native cli

The enaml-native-cli is installed with pip

pip install enaml-native-cli

After installing, run enaml-native --help to see the available commands.

Note: You can install the latest dev version using pip install git+https://github.com/codelv/enaml-native-cli.git

Create and run a new project

To create a new project use the cli to init a new project.

# Within the folder of choice
enaml-native create app

Now cd to the destination folder, activate the virtual env, and build the python and ndk libraries.

#: Go into project folder
cd HelloWorld

#: Activate the venv
source activate HelloWorld

Now either start the emulator or plug in a phone and we can run with

enaml-native run-android

If all went well the app should start and display your apps name. If you run into issues, you can ask for help on gitter.

Note: If you get errors, try installing the latest dev version by cloning git clone https://github.com/codelv/enaml-native.git and building with conda build enam-native then installing it with conda install -c local enaml-native.

Next steps

You can now make changes to your source code or continue to learn the basics.

Your app's code resides in the src directory. Any files here get installed on the app.

The view.enaml contains the UI that is shown, and main.py is the startup script.

Installing packages

To use 3rd-party python packages in your app they must first be built for
Android or iOS
using conda-mobile.

Once built, they can simply be installed into your apps environment:

  1. Add the packages to the environment.yml file under the dependencies section
  2. Run enaml-native install

Note: The enaml-native install command is just a wrapper for conda install, you can also use conda install directly.

Once installed you can rebuild the app and your new packages should be available on the app!

Faster Development

Since rebuilding the app every time you need to make a change is very slow,
enaml-native includes a few dev tools to help speed things up.

Update src/main.py and change the dev= line to say dev=server like

def main():
     with enaml.imports():
        from activity import MainActivity

    Application = get_application()
    app = Application(
        debug=False,  # Uncomment to debug the bridge
        dev='server',  # Set to 'server', 'remote', an IP address
        activity=MainActivity(),
    )
    app.start()

Now rebuild the app with enaml-native run-android. Find the IP of your device (over wifi) and go to that ip in your browser at port http://192.168.x.y:8888 and it'll show an editor just like the playground app.

Note: You can also debug using port forwarding over adb with adb forward tcp:8888 tcp:8888

For other development modes, see Debugging