cmd/gomobile: add missing checks for the NDK and Xcode
Fixes golang/go#24571
Change-Id: I8d08548b4a4d6f9490a8bfd80c80a6408fde089b
Reviewed-on: https://go-review.googlesource.com/102896
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/cmd/gomobile/bind.go b/cmd/gomobile/bind.go
index 3105db6..e5e1e57 100644
--- a/cmd/gomobile/bind.go
+++ b/cmd/gomobile/bind.go
@@ -130,6 +130,9 @@
case "android":
return goAndroidBind(gobind, pkgs, targetArchs)
case "darwin":
+ if !xcodeAvailable() {
+ return fmt.Errorf("-target=ios requires XCode")
+ }
// TODO: use targetArchs?
return goIOSBind(gobind, pkgs)
default:
diff --git a/cmd/gomobile/bind_androidapp.go b/cmd/gomobile/bind_androidapp.go
index 06b7f0c..145df64 100644
--- a/cmd/gomobile/bind_androidapp.go
+++ b/cmd/gomobile/bind_androidapp.go
@@ -6,6 +6,7 @@
import (
"archive/zip"
+ "errors"
"fmt"
"go/build"
"io"
@@ -22,6 +23,10 @@
return fmt.Errorf("this command requires ANDROID_HOME environment variable (path to the Android SDK)")
}
+ if !hasNDK() {
+ return errors.New("no Android NDK path is set. Please run gomobile init with the ndk-bundle installed through the Android SDK manager or with the -ndk flag set.")
+ }
+
// Run gobind to generate the bindings
cmd := exec.Command(
gobind,