Gio includes very basic support for integrating with existing mobile and browser projects.

Android

To build a Gio program as an .aar package, use the -buildmode=archive flag. For example,

$ go run gioui.org/cmd/gio -target android -buildmode archive gioui.org/apps/gophers

produces gophers.aar, ready to include in an Android project.

To display the Gio Android Activity, declare it in your AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    ...
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28" />
    <uses-feature android:glEsVersion="0x00030000"/>
    ...
    <application android:label="Gio">
        <activity android:name="org.gioui.GioActivity"
          android:theme="@style/Theme.GioApp"
          android:configChanges="orientation|keyboardHidden"
          android:windowSoftInputMode="adjustResize">
        </activity>
    </application>
    ...
</manifest>

and launch it from another Activity with

startActivity(new Intent(this, GioActivity.class));

iOS/tvOS

The gio tool can also produce a framework ready to include in an iOS or tvOS Xcode project. The command

$ go run gioui.org/cmd/gio -target ios -buildmode archive gioui.org/apps/gophers

outputs Gophers.framework with the demo program built for iOS.

To run the Gio program, use the GioAppDelegate class from your program:

@import UIKit;
@import Gio;

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([GioAppDelegate class]));
    }
}

WebAssembly

If the embedding HTML page for the Gio program contains a <div id="giowindow"> element, Gio will run in that instead of creating its own container.

About this wiki

commit 1a62cdd1c2d171d6fa3fd9818c2d5bf3ab0f803b
Author: Elias Naur <mail@eliasnaur.com>
Date:   2019-09-15T19:18:43+00:00

index.md: disable auto-generated TOC

Signed-off-by: Elias Naur <mail@eliasnaur.com>
Clone this wiki
https://git.sr.ht/~eliasnaur/gio (read-only)
git@git.sr.ht:~eliasnaur/gio (read/write)