Matcha

用 Go 构建原生移动应用。(Build native mobile apps in Go.)

  • Owner: gomatcha/matcha
  • Platform: Linux, Mac, Windows
  • License:: Apache License 2.0
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Matcha -- 用 Go 编写 iOS 和 Android 应用程序

gomatcha.io

Matcha 正处于早期开发阶段! 有许多粗糙的边缘和API可能仍然会改变。如果您发现任何错误,请提交问题。

什么是 Matcha?

Matcha 是一个用 Go 构建 iOS 和 Android 应用和框架的软件包。Matcha 提供了一个类似于 ReactNative 的 UI 组件库,并通过反射暴露了与 Objective-C 和 Java 代码的绑定。该库还为常见的应用任务提供了 Go API。

示例

settings-example insta-example todo-example

安装 -- macOS

Matcha 需要安装以下组件。

  • Go 1.8 以上
  • Xcode 8.3 以上
  • Android Studio 2.3+ (含 SDK 26, NDK 和 Android 支持)

首先安装Xcode和Android Studio。说明可以在 https://developer.apple.com/download/https://developer.android.com/studio/install.html 找到。

在启动 Android Studio 之前,您可能需要运行以下内容,以允许它读取您的GOPATH(https://stackoverflow.com/a/14285335)。这也必须在重启时完成。

launchctl setenv GOPATH $GOPATH

打开 Android Studio 的 SDK 管理器,在 SDK 平台标签下,安装 Android 8 平台(API 26)。并在 SDK Tools 选项卡中,安装 NDK 和 Android Support Repository。

通过在 ~/.bash_profile 中添加以下内容,配置 ANDROID_HOME 环境变量,使其指向 Android SDK。Android SDK 通常位于 ~/Library/Android/sdk,这取决于你的安装。

export ANDROID_HOME=<SDK location>

获取项目并安装 matcha 命令。

go get gomatcha.io/matcha/...

接下来我们用下面的命令构建 iOS 和 Android 的 Go 标准库。输出安装在 $GOPATH/pkg/matcha。如果你的路径不包含 $GOPATH/bin,你可能需要用 $GOPATH/bin/matcha 替换这些调用。

matcha init

现在构建示例项目。输出安装在 $GOPATH/src/gomatcha.io/matcha/ios/MatchaBridge/MatchaBridge/MatchaBridge.a 和 $GOPATH/src/gomatcha.io/matcha/android/matchabridge.aar。

matcha build gomatcha.io/matcha/examples

现在我们可以打开 iOS 的示例项目了。

open $GOPATH/src/gomatcha.io/matcha/examples/ios-app/SampleApp.xcworkspace

在 Xcode 的 General > Signing 下设置开发团队,并在右上方的目标下拉菜单中选择 SampleApp。然后运行 App!

对于 Android,只需打开 Android Studio 示例项目并点击运行!

open -a /Applications/Android\ Studio.app $GOPATH/src/gomatcha.io/matcha/examples/android-app/SampleApp

安装 -- Linux

Matcha 需要安装以下组件,Linux 上不支持 iOS 构建。

  • Go 1.8 以上
  • Android Studio 2.3+ (含 SDK 26、NDK 和 Android 支持库)

首先安装 Android Studio。说明可以在https://developer.android.com/studio/install.html 上找到。

打开 Android Studio 的 SDK 管理器,在 SDK 平台选项卡下,安装 Android 8 平台(API 26)。并在 SDK 工具选项卡中,安装 NDK 和 Android Support Repository。
通过在 ~/.bash_profile 中添加以下内容,配置 ANDROID_HOME 环境变量,使其指向 Android SDK。Android SDK 通常位于 ~/Android/SDK,这取决于你的安装。

export ANDROID_HOME=<SDK location>

另外,在你的 ~/.bash_profile 中添加以下内容来修改你的 PATH,以包含 Java 编译器(如果还没有的话)。javac 通常可以在 /usr/local/android-studio/jre/bin 找到。

export PATH=${PATH}:<Java Compiler location>

获取项目并安装 matcha 命令。

go get gomatcha.io/matcha/...

接下来我们用下面的命令构建 Android 的 Go 标准库。输出安装在 $GOPATH/pkg/matcha。如果你的路径不包含 $GOPATH/bin,你可能需要用 $GOPATH/bin/matcha 替换这些调用。

matcha init

现在构建示例项目。输出安装在 $GOPATH/src/gomatcha.io/matcha/android/matchabridge.aar。

matcha build gomatcha.io/matcha/examples

现在打开 Android Studio 示例项目并点击运行!

<Android Studio location>/bin/studio.sh $GOPATH/src/gomatcha.io/matcha/examples/android-app/SampleApp

安装 -- Windows

Matcha 需要安装以下组件,Windows 上不支持 iOS 构建。

  • Go 1.8+
  • Android Studio 2.3+ (含 SDK 26, NDK 和 Android 支持库)

首先安装 Android Studio。说明可以在 https://developer.android.com/studio/install.html 上找到。

打开 Android Studio 的 SDK 管理器,在 SDK 平台选项卡下,安装 Android 8 平台(API 26)。并在 SDK 工具选项卡中,安装 NDK 和 Android Support Repository。

将 ANDROID_HOME 环境变量配置为指向 Android SDK。Android SDK 通常位于 %USERPROFILE%AppData/Local/Android/Sdk,这取决于你的安装。

setx ANDROID_HOME <SDK location>

javac 通常可以在 C:\\Program Files\Android\Android Studio\jrebin 找到。

setx PATH %PATH%;<Java Compiler location>

获取项目并安装 matcha 命令。

go get gomatcha.io/matcha/...

接下来我们用下面的命令构建 Android 的 Go 标准库。输出安装在 $GOPATH/pkg/matcha。如果你的路径不包含 $GOPATH/bin,你可能需要用 $GOPATH/bin/matcha 替换这些调用。

matcha init

现在构建示例项目。输出安装在 $GOPATH/src/gomatcha.io/matcha/android/matchabridge.aar。

matcha build gomatcha.io/matcha/examples

现在打开 Android Studio 示例项目并点击运行!

试试吧

联系作者


(The first version translated by vz on 2020.08.22)

Main metrics

Overview
Name With Ownergomatcha/matcha
Primary LanguageGo
Program languageGo (Language Count: 5)
PlatformLinux, Mac, Windows
License:Apache License 2.0
所有者活动
Created At2017-08-01 00:46:03
Pushed At2018-09-13 22:07:28
Last Commit At2017-11-08 20:53:53
Release Count2
Last Release Namev0.2.0 (Posted on )
First Release Namev0.1.0 (Posted on )
用户参与
Stargazers Count3.5k
Watchers Count85
Fork Count163
Commits Count398
Has Issues Enabled
Issues Count34
Issue Open Count21
Pull Requests Count31
Pull Requests Open Count0
Pull Requests Close Count2
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Matcha - iOS and Android apps in Go

gomatcha.io

Matcha is in early development! There are many rough edges and APIs may still
change. Please file issues for any bugs you find.

What is Matcha?

Matcha is a package for building iOS and Android applications and frameworks in
Go. Matcha provides a UI component library similar to ReactNative and exposes
bindings to Objective-C and Java code through reflection. The library also
provides Go APIs for common app tasks.

Examples

settings-example
insta-example
todo-example

Installation - macOS

Matcha requires the following components to be installed.

  • Go 1.8+
  • Xcode 8.3+
  • Android Studio 2.3+ (with SDK 26, NDK and Android Support)

Start by installing Xcode and Android Studio. Instructions can be found at
https://developer.apple.com/download/ and
https://developer.android.com/studio/install.html.

You may need to run the following before starting Android Studio to allow it to read
your GOPATH (https://stackoverflow.com/a/14285335). This also must be done on
reboot.

launchctl setenv GOPATH $GOPATH

Open Android Studio's SDK Manager and under the SDK Platforms tab, install
the Android 8 Platform (API 26). And in the SDK Tools tab, install NDK and the
Android Support Repository.

Configure the ANDROID_HOME enviromental variable to point to the Android SDK by
adding the following to your ~/.bash_profile. The Android SDK is
often located at ~/Library/Android/sdk depending on your install.

export ANDROID_HOME=<SDK location>

Fetch the project and install the matcha command.

go get gomatcha.io/matcha/...

Next we build the Go standard library for iOS and Android with the following command.
The output is installed at $GOPATH/pkg/matcha. If your
path doesn't contain $GOPATH/bin, you may need to replace these calls with
$GOPATH/bin/matcha.

matcha init

Now build the example project. The output is installed at $GOPATH/src/gomatcha.io/matcha/ios/MatchaBridge/MatchaBridge/MatchaBridge.a and $GOPATH/src/gomatcha.io/matcha/android/matchabridge.aar.

matcha build gomatcha.io/matcha/examples

We can now open the sample iOS project.

open $GOPATH/src/gomatcha.io/matcha/examples/ios-app/SampleApp.xcworkspace

Set the Development Team in Xcode under General > Signing and select SampleApp in
the target dropdown in the upper right. Then run the App!

For Android, simply open the sample Android Studio project and hit run!

open -a /Applications/Android\ Studio.app $GOPATH/src/gomatcha.io/matcha/examples/android-app/SampleApp

Installation - Linux

Matcha requires the following components to be installed. iOS builds are not
supported on Linux.

  • Go 1.8+
  • Android Studio 2.3+ (with SDK 26, NDK and Android Support Library)

Start by installing Android Studio. Instructions can be found at
https://developer.android.com/studio/install.html.

Open Android Studio's SDK Manager and under the SDK Platforms tab, install
the Android 8 Platform (API 26). And in the SDK Tools tab, install NDK and the
Android Support Repository.

Configure the ANDROID_HOME enviromental variable to point to the Android SDK by
adding the following to your ~/.bash_profile. The Android SDK is often located
at ~/Android/Sdk depending on your install.

export ANDROID_HOME=<SDK location>

Additionally add the following to your ~/.bash_profile to modify your PATH to
include the Java compiler if it does not already. javac can often be found at
/usr/local/android-studio/jre/bin.

export PATH=${PATH}:<Java Compiler location>

Fetch the project and install the matcha command.

go get gomatcha.io/matcha/...

Next we build the Go standard library for Android with the following command.
The output is installed at $GOPATH/pkg/matcha. If your
path doesn't contain $GOPATH/bin, you may need to replace these calls with
$GOPATH/bin/matcha.

matcha init

Now build the example project. The output is installed at $GOPATH/src/gomatcha.io/matcha/android/matchabridge.aar.

matcha build gomatcha.io/matcha/examples

Now open the sample Android Studio project and hit run!

<Android Studio location>/bin/studio.sh $GOPATH/src/gomatcha.io/matcha/examples/android-app/SampleApp

Installation - Windows

Matcha requires the following components to be installed. iOS builds are not
supported on Windows.

  • Go 1.8+
  • Android Studio 2.3+ (with SDK 26, NDK and Android Support Library)

Start by installing Android Studio. Instructions can be found at
https://developer.android.com/studio/install.html.

Open Android Studio's SDK Manager and under the SDK Platforms tab, install
the Android 8 Platform (API 26). And in the SDK Tools tab, install NDK and the
Android Support Repository.

Configure the ANDROID_HOME enviromental variable to point to the Android SDK.
The Android SDK is often located at %USERPROFILE%\AppData\Local\Android\Sdk
depending on your install.

setx ANDROID_HOME <SDK location>

Modify your PATH to include the Java compiler if it does not already. javac can
often be found at C:\Program Files\Android\Android Studio\jre\bin.

setx PATH %PATH%;<Java Compiler location>

Fetch the project and install the matcha command.

go get gomatcha.io/matcha/...

Next we build the Go standard library for Android with the following command.
The output is installed at $GOPATH/pkg/matcha. If your path doesn't contain
$GOPATH/bin, you may need to replace these calls with $GOPATH/bin/matcha.

matcha init

Now build the example project. The output is installed at $GOPATH/src/gomatcha.io/matcha/android/matchabridge.aar.

matcha build gomatcha.io/matcha/examples

Now open the sample Android Studio project and hit run!