mobile

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: BSD-3-Clause Imports: 45 Imported by: 0

Documentation

Overview

Gomobile is a tool for building and running mobile apps written in Go.

To install:

$ go install golang.org/x/mobile/cmd/gomobile@latest
$ gomobile init

At least Go 1.16 is required. For detailed instructions, see https://golang.org/wiki/Mobile.

Usage:

gomobile command [arguments]

Commands:

bind        build a library for Android and iOS
build       compile android APK and iOS app
clean       remove object files and cached gomobile files
init        build OpenAL for Android
install     compile android APK and install on device
version     print version

Use 'gomobile help [command]' for more information about that command.

Build a library for Android and iOS

Usage:

gomobile bind [-target android|ios|iossimulator|macos|maccatalyst] [-bootclasspath <path>] [-classpath <path>] [-o output] [build flags] [package]

Bind generates language bindings for the package named by the import path, and compiles a library for the named target system.

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

For -target android, the bind command produces an AAR (Android ARchive) file that archives the precompiled Java API stub classes, the compiled shared libraries, and all asset files in the /assets subdirectory under the package directory. The output is named '<package_name>.aar' by default. This AAR file is commonly used for binary distribution of an Android library project and most Android IDEs support AAR import. For example, in Android Studio (1.2+), an AAR file can be imported using 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.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 instruction sets (arm, arm64, 386, amd64). A subset of instruction sets can 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. The generated Objective-C types can be prefixed with the -prefix flag.

For -target android, the -bootclasspath and -classpath flags are used to control the bootstrap classpath and the classpath for Go wrappers to Java classes.

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'.

Compile android APK and iOS app

Usage:

gomobile build [-target android|ios|iossimulator|macos|maccatalyst] [-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).

For -target android, if an AndroidManifest.xml is defined in the package directory, it is added to the APK output. Otherwise, a default manifest is generated. By default, this builds a fat APK for all supported instruction sets (arm, 386, amd64, arm64). A subset of instruction sets can 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.

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.

If the package directory contains an assets subdirectory, its contents are copied into the output.

Flag -iosversion sets the minimal version of the iOS SDK to compile against. The default version is 13.0.

Flag -androidMinSDK sets the minimum supported Android SDK (uses-sdk/android:minSdkVersion in AndroidManifest.xml). The default and minimum is 23.

Flag -androidTargetSDK sets the target Android SDK version (uses-sdk/android:targetSdkVersion in AndroidManifest.xml). The default is 29.

The -bundleid flag is required for -target ios and sets the bundle ID to use with the app.

The -o flag specifies the output file name. If not specified, the output file name depends on the package built.

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'.

Remove object files and cached gomobile files

Usage:

gomobile clean

Clean removes object files and cached NDK files downloaded by gomobile init

Build OpenAL for Android

Usage:

gomobile init [-openal dir]

If a OpenAL source directory is specified with -openal, init will build an Android version of OpenAL for use with gomobile build and gomobile install.

Compile android APK and install on device

Usage:

gomobile install [-target android] [build flags] [package]

Install compiles and installs the app named by the import path on the attached mobile device.

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. For documentation, see 'go help build'.

Print version

Usage:

gomobile version

Version prints versions of the gomobile binary and tools

Index

Constants

View Source
const (
	MinAndroidSDK           = 23
	DefaultAndroidTargetSDK = 29
)
View Source
const ContentsJSON = `` /* 914-byte string literal not displayed */
View Source
const DebugCert = `` /* 1676-byte string literal not displayed */

A random uninteresting private key. Must be consistent across builds so newer app versions can be installed.

Variables

View Source
var (
	OIDPKCS7         = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7}
	OIDData          = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 1}
	OIDSignedData    = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 2}
	OIDSHA1          = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 26}
	OIDRSAEncryption = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 1}
)

Various ASN.1 Object Identifies, mostly from rfc3852.

View Source
var (
	GoMobilePath string                       // $GOPATH/pkg/gomobile
	AndroidEnv   map[string]map[string]string // android arch -> map[string]string
	AppleEnv     map[string]map[string]string // platform/arch -> map[string]string
	AppleNM      string
)

General mobile build environment. Initialized by envInit.

View Source
var (
	GOOS   = runtime.GOOS
	GOARCH = runtime.GOARCH
)
View Source
var (
	AreGoModulesUsedResult struct {
		// contains filtered or unexported fields
	}
	AreGoModulesUsedOnce sync.Once
)
View Source
var ApplePlatforms = []string{"ios", "iossimulator", "macos", "maccatalyst"}
View Source
var InfoplistTmpl = template.Must(template.New("infoplist").Parse(`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleExecutable</key>
	<string>main</string>
	<key>CFBundleIdentifier</key>
	<string>{{.BundleID}}</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>{{.Name}}</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>{{ .Version }}</string>
	<key>CFBundleGetInfoString</key>
	<string>{{ .InfoString }}</string>
	<key>CFBundleShortVersionString</key>
	<string>{{ .ShortVersionString }}</string>
	<key>CFBundleIconFile</key>
	<string>{{ .IconFile }}</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
</dict>
</plist>
`))
View Source
var ManifestTmpl = template.Must(template.New("manifest").Parse(`
<manifest
	xmlns:android="http://schemas.android.com/apk/res/android"
	package="{{.JavaPkgPath}}"
	android:versionCode="1"
	android:versionName="1.0">

	<application android:label="{{.Name}}" android:debuggable="true">
	<activity android:name="org.golang.app.GoNativeActivity"
		android:label="{{.Name}}"
		android:configChanges="orientation|screenSize|keyboardHidden">
		<meta-data android:name="android.app.lib_name" android:value="{{.LibName}}" />
		<intent-filter>
			<action android:name="android.intent.action.MAIN" />
			<category android:name="android.intent.category.LAUNCHER" />
		</intent-filter>
	</activity>
	</application>
</manifest>`))
View Source
var NDK = NDKConfig{
	"arm": {
		Arch:           "arm",
		ABI:            "armeabi-v7a",
		MinAPI:         16,
		ToolPrefix:     "arm-linux-androideabi",
		ClangPrefixVal: "armv7a-linux-androideabi",
	},
	"arm64": {
		Arch:           "arm64",
		ABI:            "arm64-v8a",
		MinAPI:         21,
		ToolPrefix:     "aarch64-linux-android",
		ClangPrefixVal: "aarch64-linux-android",
	},

	"386": {
		Arch:           "x86",
		ABI:            "x86",
		MinAPI:         16,
		ToolPrefix:     "i686-linux-android",
		ClangPrefixVal: "i686-linux-android",
	},
	"amd64": {
		Arch:           "x86_64",
		ABI:            "x86_64",
		MinAPI:         21,
		ToolPrefix:     "x86_64-linux-android",
		ClangPrefixVal: "x86_64-linux-android",
	},
}
View Source
var NmRE = regexp.MustCompile(`[0-9a-f]{8} t _?(?:.*/vendor/)?(golang.org/x.*/[^.]*)`)
View Source
var ProjPbxprojTmpl = template.Must(template.New("projPbxproj").Parse(`// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 46;
	objects = {

/* Begin PBXBuildFile section */
		254BB84F1B1FD08900C56DE9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 254BB84E1B1FD08900C56DE9 /* Images.xcassets */; };
		254BB8681B1FD16500C56DE9 /* main in Resources */ = {isa = PBXBuildFile; fileRef = 254BB8671B1FD16500C56DE9 /* main */; };
		25FB30331B30FDEE0005924C /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 25FB30321B30FDEE0005924C /* assets */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
		254BB83E1B1FD08900C56DE9 /* main.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = main.app; sourceTree = BUILT_PRODUCTS_DIR; };
		254BB8421B1FD08900C56DE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
		254BB84E1B1FD08900C56DE9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
		254BB8671B1FD16500C56DE9 /* main */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = main; sourceTree = "<group>"; };
		25FB30321B30FDEE0005924C /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = main/assets; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXGroup section */
		254BB8351B1FD08900C56DE9 = {
			isa = PBXGroup;
			children = (
				25FB30321B30FDEE0005924C /* assets */,
				254BB8401B1FD08900C56DE9 /* main */,
				254BB83F1B1FD08900C56DE9 /* Products */,
			);
			sourceTree = "<group>";
			usesTabs = 0;
		};
		254BB83F1B1FD08900C56DE9 /* Products */ = {
			isa = PBXGroup;
			children = (
				254BB83E1B1FD08900C56DE9 /* main.app */,
			);
			name = Products;
			sourceTree = "<group>";
		};
		254BB8401B1FD08900C56DE9 /* main */ = {
			isa = PBXGroup;
			children = (
				254BB8671B1FD16500C56DE9 /* main */,
				254BB84E1B1FD08900C56DE9 /* Images.xcassets */,
				254BB8411B1FD08900C56DE9 /* Supporting Files */,
			);
			path = main;
			sourceTree = "<group>";
		};
		254BB8411B1FD08900C56DE9 /* Supporting Files */ = {
			isa = PBXGroup;
			children = (
				254BB8421B1FD08900C56DE9 /* Info.plist */,
			);
			name = "Supporting Files";
			sourceTree = "<group>";
		};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
		254BB83D1B1FD08900C56DE9 /* main */ = {
			isa = PBXNativeTarget;
			buildConfigurationList = 254BB8611B1FD08900C56DE9 /* Build configuration list for PBXNativeTarget "main" */;
			buildPhases = (
				254BB83C1B1FD08900C56DE9 /* Resources */,
			);
			buildRules = (
			);
			dependencies = (
			);
			name = main;
			productName = main;
			productReference = 254BB83E1B1FD08900C56DE9 /* main.app */;
			productType = "com.apple.product-type.application";
		};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
		254BB8361B1FD08900C56DE9 /* Project object */ = {
			isa = PBXProject;
			attributes = {
				LastUpgradeCheck = 0630;
				ORGANIZATIONNAME = Developer;
				TargetAttributes = {
					254BB83D1B1FD08900C56DE9 = {
						CreatedOnToolsVersion = 6.3.1;
						DevelopmentTeam = {{.TeamID}};
					};
				};
			};
			buildConfigurationList = 254BB8391B1FD08900C56DE9 /* Build configuration list for PBXProject "main" */;
			compatibilityVersion = "Xcode 3.2";
			developmentRegion = English;
			hasScannedForEncodings = 0;
			knownRegions = (
				en,
				Base,
			);
			mainGroup = 254BB8351B1FD08900C56DE9;
			productRefGroup = 254BB83F1B1FD08900C56DE9 /* Products */;
			projectDirPath = "";
			projectRoot = "";
			targets = (
				254BB83D1B1FD08900C56DE9 /* main */,
			);
		};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
		254BB83C1B1FD08900C56DE9 /* Resources */ = {
			isa = PBXResourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				25FB30331B30FDEE0005924C /* assets in Resources */,
				254BB8681B1FD16500C56DE9 /* main in Resources */,
				254BB84F1B1FD08900C56DE9 /* Images.xcassets in Resources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXResourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
		254BB8601B1FD08900C56DE9 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_ENABLE_MODULES = YES;
				CLANG_ENABLE_OBJC_ARC = YES;
				CLANG_WARN_BOOL_CONVERSION = YES;
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
				CLANG_WARN_UNREACHABLE_CODE = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
				COPY_PHASE_STRIP = NO;
				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
				ENABLE_NS_ASSERTIONS = NO;
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				MTL_ENABLE_DEBUG_INFO = NO;
				SDKROOT = iphoneos;
				TARGETED_DEVICE_FAMILY = "1,2";
				VALIDATE_PRODUCT = YES;
				ENABLE_BITCODE = NO;
				IPHONEOS_DEPLOYMENT_TARGET = 15.0;
			};
			name = Release;
		};
		254BB8631B1FD08900C56DE9 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				INFOPLIST_FILE = main/Info.plist;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				PRODUCT_NAME = "$(TARGET_NAME)";
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
		254BB8391B1FD08900C56DE9 /* Build configuration list for PBXProject "main" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				254BB8601B1FD08900C56DE9 /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
		254BB8611B1FD08900C56DE9 /* Build configuration list for PBXNativeTarget "main" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				254BB8631B1FD08900C56DE9 /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
/* End XCConfigurationList section */
	};
	rootObject = 254BB8361B1FD08900C56DE9 /* Project object */;
}
`))
View Source
var TmpDir string

Functions

func ABI

func ABI(goarch string) string

ABI maps GOARCH values to Android ABI strings. See https://developer.android.com/ndk/guides/abis

func AndroidPkgName

func AndroidPkgName(name string) string

AndroidPkgName sanitizes the go package name to be acceptable as a android package name part. The android package name convention is similar to the java package name convention described in https://docs.oracle.com/javase/specs/jls/se8/html/jls-6.html#jls-6.5.3.1 but not exactly same.

func AppleCopyAssets

func AppleCopyAssets(c *config.Config, pkg *packages.Package, xcodeProjDir string) error

func ArchClang

func ArchClang(goarch string) string

func ArchNDK

func ArchNDK() string

func AreGoModulesUsed

func AreGoModulesUsed() (bool, error)

func Build

func Build(c *config.Config) error

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 (TODO: apple platforms list).

For -target android, if an AndroidManifest.xml is defined in the package directory, it is added to the APK output. Otherwise, a default manifest is generated. By default, this builds a fat APK for all supported instruction sets (arm, 386, amd64, arm64). A subset of instruction sets can 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.

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.

If the package directory contains an assets subdirectory, its contents are copied into the output.

func BuildEnvInit

func BuildEnvInit(c *config.Config) (cleanup func(), err error)

func BuildImpl

func BuildImpl(c *config.Config) (*packages.Package, error)

BuildImpl builds a package for mobiles based on the given config info. BuildImpl returns a built package information and an error if exists.

func CheckNDKRoot

func CheckNDKRoot(c *config.Config, ndkRoot string, targets []config.Platform) error

CheckNDKRoot returns nil if the NDK in `ndkRoot` supports the current configured API version and all the specified Android targets.

func Clean

func Clean() (err error)

Clean removes object files and cached NDK files downloaded by gomobile init

func CompatibleNDKRoots

func CompatibleNDKRoots(c *config.Config, ndkForest string, targets []config.Platform) ([]string, error)

CompatibleNDKRoots searches the side-by-side NDK dirs for compatible SDKs.

func CopyFile

func CopyFile(c *config.Config, dst, src string) error

func DetectTeamID

func DetectTeamID() (string, error)

DetectTeamID determines the Apple Development Team ID on the system.

func DoCopyAll

func DoCopyAll(dst, src string) error

func EnvClang

func EnvClang(c *config.Config, sdkName string) (clang, cflags string, err error)

func EnvInit

func EnvInit(c *config.Config) (err error)

func ExtractPkgs

func ExtractPkgs(c *config.Config, nm string, path string) (map[string]bool, error)

func GetModuleVersions

func GetModuleVersions(c *config.Config, targetPlatform string, targetArch string, src string) (*modfile.File, error)

GetModuleVersions returns a module information at the directory src.

func GoAndroidBuild

func GoAndroidBuild(c *config.Config, pkg *packages.Package, targets []config.Platform) (map[string]bool, error)

GoAndroidBuild builds the given package for the given Android targets.

func GoAppleBuild

func GoAppleBuild(c *config.Config, pkg *packages.Package, targets []config.Platform) (map[string]bool, error)

GoAppleBuild builds the given package with the given bundle ID for the given iOS targets.

func GoBuild

func GoBuild(c *config.Config, src string, env map[string]string, args ...string) error

func GoBuildAt

func GoBuildAt(c *config.Config, at string, src string, env map[string]string, args ...string) error

func GoCmd

func GoCmd(c *config.Config, subcmd string, srcs []string, env map[string]string, args ...string) error

func GoCmdAt

func GoCmdAt(c *config.Config, at string, subcmd string, srcs []string, env map[string]string, args ...string) error

func GoEnv

func GoEnv(name string) string

func GoInstall

func GoInstall(c *config.Config, srcs []string, env map[string]string, args ...string) error

func GoModCachePath

func GoModCachePath() (string, error)

func GoModTidyAt

func GoModTidyAt(c *config.Config, at string, env map[string]string) error

func Install

func Install(c *config.Config) error

Install installs the app named by the import path on the attached mobile device. It assumes that it has already been built.

On Android, the 'adb' tool must be on the PATH.

func IsAndroidPlatform

func IsAndroidPlatform(platform string) bool

func IsApplePlatform

func IsApplePlatform(platform string) bool

func IsSupportedArch

func IsSupportedArch(platform, arch string) bool

func ManifestLibName

func ManifestLibName(data []byte) (string, error)

ManifestLibName parses the AndroidManifest.xml and finds the library name of the NativeActivity.

func NDKRoot

func NDKRoot(c *config.Config, targets ...config.Platform) (string, error)

NDKRoot returns the root path of an installed NDK that supports all the specified Android targets. For details of NDK locations, see https://github.com/android/ndk-samples/wiki/Configure-NDK-Path

func NDKVersion

func NDKVersion(ndkRoot string) string

NDKVersion returns the full version number of an installed copy of the NDK, or "" if it cannot be determined.

func PackagesConfig

func PackagesConfig(c *config.Config, t *config.Platform) *packages.Config

func PlatformArchs

func PlatformArchs(platform string) []string

func PlatformOS

func PlatformOS(platform string) string

PlatformOS returns the correct GOOS value for platform.

func PlatformTags

func PlatformTags(platform string) []string

func RFC1034Label

func RFC1034Label(name string) string

RFC1034Label sanitizes the name to be usable in a uniform type identifier. The sanitization is similar to xcode's rfc1034identifier macro that replaces illegal characters (not conforming the rfc1034 label rule) with '-'.

func SetupMoltenFramework added in v0.0.3

func SetupMoltenFramework() error

SetupMoltenFramework creates the MoltenVK.framework file in the user's library if it doesn't already exist.

func SignPKCS7

func SignPKCS7(rand io.Reader, priv *rsa.PrivateKey, msg []byte) ([]byte, error)

SignPKCS7 does the minimal amount of work necessary to embed an RSA signature into a PKCS#7 certificate.

We prepare the certificate using the x509 package, read it back in to our custom data type and then write it back out with the signature.

func Symlink(c *config.Config, src, dst string) error

func WriteFile

func WriteFile(c *config.Config, filename string, generate func(io.Writer) error) error

func WriteGoMod

func WriteGoMod(c *config.Config, dir, targetPlatform, targetArch string) error

WriteGoMod writes go.mod file at dir when Go modules are used.

func XCodeAvailable

func XCodeAvailable() bool

Types

type ActivityXML

type ActivityXML struct {
	Name     string        `xml:"name,attr"`
	MetaData []MetaDataXML `xml:"meta-data"`
}

type Certificate

type Certificate struct {
	TBSCertificate     TBSCertificate
	SignatureAlgorithm pkix.AlgorithmIdentifier
	SignatureValue     asn1.BitString
}

Certificate is defined in rfc2459, section 4.1.

type ContentInfo

type ContentInfo struct {
	Type asn1.ObjectIdentifier
}

type InfoplistTmplData

type InfoplistTmplData struct {
	BundleID           string
	Name               string
	Version            string
	InfoString         string
	ShortVersionString string
	IconFile           string
}

type IssuerAndSerialNumber

type IssuerAndSerialNumber struct {
	Issuer       pkix.RDNSequence // pkix.Name
	SerialNumber int
}

type ManifestTmplData

type ManifestTmplData struct {
	JavaPkgPath string
	Name        string
	LibName     string
}

type ManifestXML

type ManifestXML struct {
	Activity ActivityXML `xml:"application>activity"`
}

type MetaDataXML

type MetaDataXML struct {
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`
}

type NDKConfig

type NDKConfig map[string]NDKToolchain // map: GOOS->androidConfig.

func (NDKConfig) Toolchain

func (nc NDKConfig) Toolchain(arch string) NDKToolchain

type NDKToolchain

type NDKToolchain struct {
	Arch           string
	ABI            string
	MinAPI         int
	ToolPrefix     string
	ClangPrefixVal string // ClangPrefix is taken by a method
}

func (*NDKToolchain) ClangPrefix

func (tc *NDKToolchain) ClangPrefix(c *config.Config) string

func (*NDKToolchain) Path

func (tc *NDKToolchain) Path(c *config.Config, ndkRoot, toolName string) string

type Pkcs7SignedData

type Pkcs7SignedData struct {
	ContentType asn1.ObjectIdentifier
	Content     SignedData `asn1:"tag:0,explicit"`
}

type ProjPbxprojTmplData

type ProjPbxprojTmplData struct {
	TeamID string
}

type SignedData

type SignedData struct {
	Version          int
	DigestAlgorithms []pkix.AlgorithmIdentifier `asn1:"set"`
	ContentInfo      ContentInfo
	Certificates     Certificate  `asn1:"tag0,explicit"`
	SignerInfos      []SignerInfo `asn1:"set"`
}

SignedData is defined in rfc2315, section 9.1.

type SignerInfo

type SignerInfo struct {
	Version                   int
	IssuerAndSerialNumber     IssuerAndSerialNumber
	DigestAlgorithm           pkix.AlgorithmIdentifier
	DigestEncryptionAlgorithm pkix.AlgorithmIdentifier
	EncryptedDigest           []byte
}

type SubjectPublicKeyInfo

type SubjectPublicKeyInfo struct {
	Algorithm        pkix.AlgorithmIdentifier
	SubjectPublicKey asn1.BitString
}

SubjectPublicKeyInfo is defined in rfc2459, section 4.1.

type TBSCertificate

type TBSCertificate struct {
	Version      int `asn1:"tag:0,default:2,explicit"`
	SerialNumber int
	Signature    pkix.AlgorithmIdentifier
	Issuer       pkix.RDNSequence // pkix.Name
	Validity     Validity
	Subject      pkix.RDNSequence // pkix.Name
	SubjectPKI   SubjectPublicKeyInfo
}

TBSCertificate is defined in rfc2459, section 4.1.

type Validity

type Validity struct {
	NotBefore time.Time
	NotAfter  time.Time
}

Validity is defined in rfc2459, section 4.1.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer implements an APK file writer.

func NewWriter

func NewWriter(w io.Writer, priv *rsa.PrivateKey) *Writer

NewWriter returns a new Writer writing an APK file to w. The APK will be signed with key.

func (*Writer) Close

func (w *Writer) Close() error

Close finishes writing the APK. This includes writing the manifest and signing the archive, and writing the ZIP central directory.

It does not close the underlying writer.

func (*Writer) Create

func (w *Writer) Create(name string) (io.Writer, error)

Create adds a file to the APK archive using the provided name.

The name must be a relative path. The file's contents must be written to the returned io.Writer before the next call to Create or Close.

Directories

Path Synopsis
Package binres implements encoding and decoding of android binary resources.
Package binres implements encoding and decoding of android binary resources.
Package sdkpath provides functions for locating the Android SDK.
Package sdkpath provides functions for locating the Android SDK.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL