cmd/gomobile: make the minimum iOS sdk version configurable
Fixes #27680
Change-Id: I8af5c120aaa2ddbf03fc8832b60c293aca77b1e6
GitHub-Last-Rev: 22f5d033fc29b94b4fea8c4b77f4cdcd2f66226c
GitHub-Pull-Request: golang/mobile#21
Reviewed-on: https://go-review.googlesource.com/135415
Reviewed-by: Elias Naur <elias.naur@gmail.com>
diff --git a/cmd/gomobile/build.go b/cmd/gomobile/build.go
index a41e581..8737210 100644
--- a/cmd/gomobile/build.go
+++ b/cmd/gomobile/build.go
@@ -47,6 +47,9 @@
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 6.1.
+
The -bundleid flag is for -target ios only and sets the bundle ID to use
with the app; defaults to "org.golang.todo".
@@ -218,17 +221,18 @@
// "Build flags", used by multiple commands.
var (
- buildA bool // -a
- buildI bool // -i
- buildN bool // -n
- buildV bool // -v
- buildX bool // -x
- buildO string // -o
- buildGcflags string // -gcflags
- buildLdflags string // -ldflags
- buildTarget string // -target
- buildWork bool // -work
- buildBundleID string // -bundleid
+ buildA bool // -a
+ buildI bool // -i
+ buildN bool // -n
+ buildV bool // -v
+ buildX bool // -x
+ buildO string // -o
+ buildGcflags string // -gcflags
+ buildLdflags string // -ldflags
+ buildTarget string // -target
+ buildWork bool // -work
+ buildBundleID string // -bundleid
+ buildIOSVersion string // -iosversion
)
func addBuildFlags(cmd *command) {
@@ -237,6 +241,7 @@
cmd.flag.StringVar(&buildLdflags, "ldflags", "", "")
cmd.flag.StringVar(&buildTarget, "target", "android", "")
cmd.flag.StringVar(&buildBundleID, "bundleid", "org.golang.todo", "")
+ cmd.flag.StringVar(&buildIOSVersion, "iosversion", "6.1", "")
cmd.flag.BoolVar(&buildA, "a", false, "")
cmd.flag.BoolVar(&buildI, "i", false, "")
diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index a5dc19e..f2ec576 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -113,10 +113,10 @@
fallthrough
case "arm64":
clang, cflags, err = envClang("iphoneos")
- cflags += " -miphoneos-version-min=6.1"
+ cflags += " -miphoneos-version-min=" + buildIOSVersion
case "386", "amd64":
clang, cflags, err = envClang("iphonesimulator")
- cflags += " -mios-simulator-version-min=6.1"
+ cflags += " -mios-simulator-version-min=" + buildIOSVersion
default:
panic(fmt.Errorf("unknown GOARCH: %q", arch))
}