[mobile] cmd/gomobile: correct Apple build documentation

1 view
Skip to first unread message

race quite (Gerrit)

unread,
Aug 9, 2026, 3:10:53 PM (15 hours ago) Aug 9
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

race quite has uploaded the change for review

Commit message

cmd/gomobile: correct Apple build documentation

The gomobile build help incorrectly describes gomobile bind's
XCFramework output. Document the actual .app output produced by
gomobile build, including its .app output requirement, and clarify the
different Apple targets supported by gomobile bind.

Also fix two spelling errors, regenerate doc.go, and add a regression
test for the help text.
Change-Id: I9954e5c90362b33d15d318608df8a17b3e469191

Change diff

diff --git a/cmd/gomobile/build.go b/cmd/gomobile/build.go
index c15daa4..d1b14e4 100644
--- a/cmd/gomobile/build.go
+++ b/cmd/gomobile/build.go
@@ -24,15 +24,14 @@
var cmdBuild = &command{
run: runBuild,
Name: "build",
- Usage: "[-target android|" + strings.Join(applePlatforms, "|") + "] [-o output] [-bundleid bundleID] [build flags] [package]",
+ Usage: "[-target android|ios] [-o output] [-bundleid bundleID] [build flags] [package]",
Short: "compile android APK and iOS app",
Long: `
Build compiles and encodes the app named by the import path.

The named package must define a main function.

-The -target flag takes either android (the default), or one or more
-comma-delimited Apple platforms (` + strings.Join(applePlatforms, ", ") + `).
+The -target flag takes either android (the default) or ios.

For -target android, if an AndroidManifest.xml is defined in the
package directory, it is added to the APK output. Otherwise, a default
@@ -41,16 +40,15 @@
be selected by specifying target type with the architecture name. E.g.
-target=android/arm,android/386.

-For Apple -target platforms, gomobile must be run on an OS X machine with
-Xcode installed.
+For -target ios, gomobile must be run on an OS X machine with Xcode installed.
+The build command creates an iOS .app bundle. The output name specified by
+-o must end in .app. By default, the app contains binaries for all supported
+iOS device and simulator architectures. A subset can be selected by specifying
+the platform with an architecture name. E.g. -target=ios/arm64.

-By default, -target ios will generate an XCFramework for both ios
-and iossimulator. Multiple Apple targets can be specified, creating a "fat"
-XCFramework with each slice. To generate a fat XCFramework that supports
-iOS, macOS, and macCatalyst for all supportec architectures (amd64 and arm64),
-specify -target ios,macos,maccatalyst. A subset of instruction sets can be
-selectged by specifying the platform with an architecture name. E.g.
--target=ios/arm64,maccatalyst/arm64.
+In contrast, gomobile bind creates an XCFramework and supports selecting
+individual Apple platforms, including iOS, the iOS simulator, macOS, and Mac
+Catalyst.

If the package directory contains an assets subdirectory, its contents
are copied into the output.
diff --git a/cmd/gomobile/build_test.go b/cmd/gomobile/build_test.go
index e5e412a..0a38f13 100644
--- a/cmd/gomobile/build_test.go
+++ b/cmd/gomobile/build_test.go
@@ -109,6 +109,31 @@
}
}

+func TestBuildAppleHelp(t *testing.T) {
+ help := cmdBuild.Usage + cmdBuild.Long
+ for _, want := range []string{
+ "[-target android|ios]",
+ "creates an iOS .app bundle",
+ "-o must end in .app",
+ "gomobile bind creates an XCFramework",
+ } {
+ if !strings.Contains(help, want) {
+ t.Errorf("build help does not contain %q", want)
+ }
+ }
+
+ for _, unwanted := range []string{
+ "[-target android|ios|iossimulator|macos|maccatalyst]",
+ "-target ios will generate an XCFramework",
+ "supportec",
+ "selectged",
+ } {
+ if strings.Contains(help, unwanted) {
+ t.Errorf("build help contains %q", unwanted)
+ }
+ }
+}
+
var androidBuildTmpl = template.Must(template.New("output").Parse(`GOMOBILE={{.GOPATH}}/pkg/gomobile
WORK=$WORK
mkdir -p $WORK/lib/armeabi-v7a
diff --git a/cmd/gomobile/doc.go b/cmd/gomobile/doc.go
index c17cf4c..67a9118 100644
--- a/cmd/gomobile/doc.go
+++ b/cmd/gomobile/doc.go
@@ -52,9 +52,10 @@
the module import wizard (File > New > New Module > Import .JAR or
.AAR package), and setting it as a new dependency
(File > Project Structure > Dependencies). This requires 'javac'
-(version 1.7+) and Android SDK (API level 16 or newer) to build the
-library for Android. The environment variable ANDROID_HOME must be set
-to the path to Android SDK. Use the -javapkg flag to specify the Java
+(version 1.8+) and Android SDK (API level 16 or newer) to build the
+library for Android. The ANDROID_HOME and ANDROID_NDK_HOME environment
+variables can be used to specify the Android SDK and NDK if they are
+not in the default locations. Use the -javapkg flag to specify the Java
package prefix for the generated classes.

By default, -target=android builds shared libraries for all supported
@@ -72,21 +73,21 @@

The -v flag provides verbose output, including the list of packages built.

-The build flags -a, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work
-are shared with the build command. For documentation, see 'go help build'.
+The build flags -a, -n, -x, -gcflags, -ldflags, -overlay, -tags, -trimpath,
+and -work are shared with the build command. For documentation,
+see 'go help build'.

# Compile android APK and iOS app

Usage:

- gomobile build [-target android|ios|iossimulator|macos|maccatalyst] [-o output] [-bundleid bundleID] [build flags] [package]
+ gomobile build [-target android|ios] [-o output] [-bundleid bundleID] [build flags] [package]

Build compiles and encodes the app named by the import path.

The named package must define a main function.

-The -target flag takes either android (the default), or one or more
-comma-delimited Apple platforms (ios, iossimulator, macos, maccatalyst).
+The -target flag takes either android (the default) or ios.

For -target android, if an AndroidManifest.xml is defined in the
package directory, it is added to the APK output. Otherwise, a default
@@ -95,16 +96,15 @@
be selected by specifying target type with the architecture name. E.g.
-target=android/arm,android/386.

-For Apple -target platforms, gomobile must be run on an OS X machine with
-Xcode installed.
+For -target ios, gomobile must be run on an OS X machine with Xcode installed.
+The build command creates an iOS .app bundle. The output name specified by
+-o must end in .app. By default, the app contains binaries for all supported
+iOS device and simulator architectures. A subset can be selected by specifying
+the platform with an architecture name. E.g. -target=ios/arm64.

-By default, -target ios will generate an XCFramework for both ios
-and iossimulator. Multiple Apple targets can be specified, creating a "fat"
-XCFramework with each slice. To generate a fat XCFramework that supports
-iOS, macOS, and macCatalyst for all supportec architectures (amd64 and arm64),
-specify -target ios,macos,maccatalyst. A subset of instruction sets can be
-selectged by specifying the platform with an architecture name. E.g.
--target=ios/arm64,maccatalyst/arm64.
+In contrast, gomobile bind creates an XCFramework and supports selecting
+individual Apple platforms, including iOS, the iOS simulator, macOS, and Mac
+Catalyst.

If the package directory contains an assets subdirectory, its contents
are copied into the output.
@@ -126,8 +126,9 @@

The -v flag provides verbose output, including the list of packages built.

-The build flags -a, -i, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work are
-shared with the build command. For documentation, see 'go help build'.
+The build flags -a, -i, -n, -x, -gcflags, -ldflags, -overlay, -tags, -trimpath,
+and -work are shared with the build command. For documentation, see
+'go help build'.

# Remove object files and cached gomobile files

@@ -135,7 +136,7 @@

gomobile clean

-Clean removes object files and cached NDK files downloaded by gomobile init.
+# Clean removes object files and cached NDK files downloaded by gomobile init

# Build OpenAL for Android

@@ -158,8 +159,8 @@

Only -target android is supported. The 'adb' tool must be on the PATH.

-The build flags -a, -i, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work are
-shared with the build command.
+The build flags -a, -i, -n, -x, -gcflags, -ldflags, -overlay, -tags, -trimpath,
+and -work are shared with the build command.
For documentation, see 'go help build'.

# Print version
@@ -170,4 +171,4 @@

Version prints versions of the gomobile binary and tools
*/
-package main
+package main // import "golang.org/x/mobile/cmd/gomobile"

Change information

Files:
  • M cmd/gomobile/build.go
  • M cmd/gomobile/build_test.go
  • M cmd/gomobile/doc.go
Change size: M
Delta: 3 files changed, 59 insertions(+), 35 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: mobile
Gerrit-Branch: master
Gerrit-Change-Id: I9954e5c90362b33d15d318608df8a17b3e469191
Gerrit-Change-Number: 812520
Gerrit-PatchSet: 1
Gerrit-Owner: race quite <quit...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Hajime Hoshi (Gerrit)

unread,
12:17 AM (6 hours ago) 12:17 AM
to race quite, goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com
Attention needed from race quite

Hajime Hoshi added 2 comments

File cmd/gomobile/build_test.go
Line 112, Patchset 1 (Latest):func TestBuildAppleHelp(t *testing.T) {
Hajime Hoshi . unresolved

I don't think we need this test.

File cmd/gomobile/doc.go
Line 174, Patchset 1 (Latest):package main // import "golang.org/x/mobile/cmd/gomobile"
Hajime Hoshi . unresolved

I don't think we need this comment

Open in Gerrit

Related details

Attention is currently required from:
  • race quite
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: mobile
    Gerrit-Branch: master
    Gerrit-Change-Id: I9954e5c90362b33d15d318608df8a17b3e469191
    Gerrit-Change-Number: 812520
    Gerrit-PatchSet: 1
    Gerrit-Owner: race quite <quit...@gmail.com>
    Gerrit-Reviewer: Hajime Hoshi <hajim...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Attention: race quite <quit...@gmail.com>
    Gerrit-Comment-Date: Mon, 10 Aug 2026 04:17:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    race quite (Gerrit)

    unread,
    2:31 AM (3 hours ago) 2:31 AM
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from race quite

    race quite uploaded new patchset

    race quite uploaded patch set #2 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • race quite
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: mobile
    Gerrit-Branch: master
    Gerrit-Change-Id: I9954e5c90362b33d15d318608df8a17b3e469191
    Gerrit-Change-Number: 812520
    Gerrit-PatchSet: 2
    unsatisfied_requirement
    open
    diffy

    race quite (Gerrit)

    unread,
    2:31 AM (3 hours ago) 2:31 AM
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from race quite

    race quite uploaded new patchset

    race quite uploaded patch set #3 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • race quite
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: mobile
    Gerrit-Branch: master
    Gerrit-Change-Id: I9954e5c90362b33d15d318608df8a17b3e469191
    Gerrit-Change-Number: 812520
    Gerrit-PatchSet: 3
    unsatisfied_requirement
    open
    diffy

    race quite (Gerrit)

    unread,
    2:31 AM (3 hours ago) 2:31 AM
    to goph...@pubsubhelper.golang.org, Hajime Hoshi, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Hajime Hoshi

    race quite added 2 comments

    File cmd/gomobile/build_test.go
    Line 112, Patchset 1:func TestBuildAppleHelp(t *testing.T) {
    Hajime Hoshi . resolved

    I don't think we need this test.

    race quite

    Removed

    File cmd/gomobile/doc.go
    Line 174, Patchset 1:package main // import "golang.org/x/mobile/cmd/gomobile"
    Hajime Hoshi . resolved

    I don't think we need this comment

    race quite

    Fixed.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Hajime Hoshi
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: mobile
      Gerrit-Branch: master
      Gerrit-Change-Id: I9954e5c90362b33d15d318608df8a17b3e469191
      Gerrit-Change-Number: 812520
      Gerrit-PatchSet: 1
      Gerrit-Owner: race quite <quit...@gmail.com>
      Gerrit-Reviewer: Hajime Hoshi <hajim...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-Attention: Hajime Hoshi <hajim...@gmail.com>
      Gerrit-Comment-Date: Mon, 10 Aug 2026 06:31:44 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Hajime Hoshi <hajim...@gmail.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages