cmd/gomobile: allow tests to pass on ios builder

There are several tests are skipped for Android but they may still be
tested on iOS. This will leads to trybot failure.

This CL skips those tests and allow them to pass on iOS.

Furthermore, deprecated C function warning are promoted to errors on
builders, this CL also fixes a deprecated asl_log for iOS in mobileinit.

Change-Id: Ie9da57a20dd75ef3d29b393e30aef01051bab454
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/346391
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/cmd/gomobile/bind_test.go b/cmd/gomobile/bind_test.go
index 9a5ffa8..b4d0657 100644
--- a/cmd/gomobile/bind_test.go
+++ b/cmd/gomobile/bind_test.go
@@ -248,7 +248,7 @@
 }
 
 func TestBindWithGoModules(t *testing.T) {
-	if runtime.GOOS == "android" {
+	if runtime.GOOS == "android" || runtime.GOOS == "ios" {
 		t.Skipf("gomobile and gobind are not available on %s", runtime.GOOS)
 	}
 
diff --git a/cmd/gomobile/build_darwin_test.go b/cmd/gomobile/build_darwin_test.go
index cfe42c9..50cf600 100644
--- a/cmd/gomobile/build_darwin_test.go
+++ b/cmd/gomobile/build_darwin_test.go
@@ -13,6 +13,9 @@
 )
 
 func TestIOSBuild(t *testing.T) {
+	if !xcodeAvailable() {
+		t.Skip("Xcode is missing")
+	}
 	defer func() {
 		xout = os.Stderr
 		buildN = false
diff --git a/cmd/gomobile/build_test.go b/cmd/gomobile/build_test.go
index 9a34f75..eb75bc6 100644
--- a/cmd/gomobile/build_test.go
+++ b/cmd/gomobile/build_test.go
@@ -69,8 +69,8 @@
 }
 
 func TestAndroidBuild(t *testing.T) {
-	if runtime.GOOS == "android" {
-		t.Skip("not available on Android")
+	if runtime.GOOS == "android" || runtime.GOOS == "ios" {
+		t.Skipf("not available on %s", runtime.GOOS)
 	}
 	buf := new(bytes.Buffer)
 	defer func() {
@@ -189,7 +189,7 @@
 }
 
 func TestBuildWithGoModules(t *testing.T) {
-	if runtime.GOOS == "android" {
+	if runtime.GOOS == "android" || runtime.GOOS == "ios" {
 		t.Skipf("gomobile are not available on %s", runtime.GOOS)
 	}
 
diff --git a/cmd/gomobile/init_test.go b/cmd/gomobile/init_test.go
index 1849252..e7602a8 100644
--- a/cmd/gomobile/init_test.go
+++ b/cmd/gomobile/init_test.go
@@ -10,6 +10,7 @@
 	"os"
 	"os/exec"
 	"path/filepath"
+	"runtime"
 	"strings"
 	"testing"
 	"text/template"
@@ -18,6 +19,10 @@
 var gopath string
 
 func TestInit(t *testing.T) {
+	if runtime.GOOS == "android" || runtime.GOOS == "ios" {
+		t.Skipf("not available on %s", runtime.GOOS)
+	}
+
 	if _, err := exec.LookPath("diff"); err != nil {
 		t.Skip("command diff not found, skipping")
 	}
diff --git a/exp/sprite/portable/affine_test.go b/exp/sprite/portable/affine_test.go
index 908933a..4b98e7c 100644
--- a/exp/sprite/portable/affine_test.go
+++ b/exp/sprite/portable/affine_test.go
@@ -21,8 +21,8 @@
 )
 
 func TestAffine(t *testing.T) {
-	if runtime.GOOS == "android" {
-		t.Skip("testdata not available on Android")
+	if runtime.GOOS == "android" || runtime.GOOS == "ios" {
+		t.Skipf("testdata not available on %s", runtime.GOOS)
 	}
 	f, err := os.Open("../../../testdata/testpattern.png")
 	if err != nil {
@@ -104,8 +104,8 @@
 }
 
 func TestAffineMask(t *testing.T) {
-	if runtime.GOOS == "android" {
-		t.Skip("testdata not available on Android")
+	if runtime.GOOS == "android" || runtime.GOOS == "ios" {
+		t.Skipf("testdata not available on %s", runtime.GOOS)
 	}
 	f, err := os.Open("../../../testdata/testpattern.png")
 	if err != nil {
diff --git a/internal/mobileinit/mobileinit_ios.go b/internal/mobileinit/mobileinit_ios.go
index 919097c..e0d1385 100644
--- a/internal/mobileinit/mobileinit_ios.go
+++ b/internal/mobileinit/mobileinit_ios.go
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build darwin && (arm || arm64)
-// +build darwin
-// +build arm arm64
+//go:build ios
+// +build ios
 
 package mobileinit
 
@@ -16,24 +15,30 @@
 )
 
 /*
-#include <asl.h>
 #include <stdlib.h>
+#include <os/log.h>
 
-void asl_log_wrap(const char *str) {
-	asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "%s", str);
+os_log_t create_os_log() {
+	return os_log_create("org.golang.mobile", "os_log");
+}
+
+void os_log_wrap(os_log_t log, const char *str) {
+	os_log(log, "%s", str);
 }
 */
 import "C"
 
-type aslWriter struct{}
+type osWriter struct {
+	w C.os_log_t
+}
 
-func (aslWriter) Write(p []byte) (n int, err error) {
+func (o osWriter) Write(p []byte) (n int, err error) {
 	cstr := C.CString(string(p))
-	C.asl_log_wrap(cstr)
+	C.os_log_wrap(o.w, cstr)
 	C.free(unsafe.Pointer(cstr))
 	return len(p), nil
 }
 
 func init() {
-	log.SetOutput(io.MultiWriter(os.Stderr, aslWriter{}))
+	log.SetOutput(io.MultiWriter(os.Stderr, osWriter{C.create_os_log()}))
 }