Go: compile error, gomobile bind hello example with -target=ios

Created on 24 Mar 2019  路  11Comments  路  Source: golang/go

What version of Go are you using (go version)?

$ go version
go version go1.12 darwin/amd64

Does this issue reproduce with the latest release?

yes, i've updated gomobile to the newest version

What operating system and processor architecture are you using (go env)?

go env Output

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/stargame/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/usr/local/work"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/go-build681457514=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

gomobile bind -target=ios golang.org/x/mobile/example/bind/hello

gobind

In file included from _cgo_export.c:4:
In file included from go_hellomain.go:10:
In file included from /var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/seq.h:7:
In file included from /var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/seq_darwin.h:10:
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:23:29: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:23:29: note: insert '_Nullable' if the pointer may be null
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:23:29: note: insert '_Nonnull' if the pointer should never be null
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:25:4: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:25:4: note: insert '_Nullable' if the pointer may be null
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:25:4: note: insert '_Nonnull' if the pointer should never be null
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:25:30: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:25:30: note: insert '_Nullable' if the pointer may be null
/var/folders/hz/vk6pt2sd58z8hnj41p9wntrw0000gn/T/gomobile-work-881160448/src/gobind/Universe.objc.h:25:30: note: insert '_Nonnull' if the pointer should never be null

What did you expect to see?

I would like to see the lib file could be made successfully.

What did you see instead?

the errors above
I wonder if my xcode is not a suitable version for this version of gomobile/gobind .(my xcode version: Version 9.2 (9C40b))
and I want to ask if I can set some build flag to ignore this kind of errors, and how. Thanks.

FrozenDueToAge

Most helpful comment

Seeing this as well with yesterday's release of Xcode 10.2. For now I have just disabled the warning:

diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index 31878bb..6a8c32c 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -129,6 +129,7 @@ func envInit() (err error) {
                        panic(fmt.Errorf("unknown GOARCH: %q", arch))
                }
                cflags += " -fembed-bitcode"
+               cflags += " -Wno-nullability-completeness"
                if err != nil {
                        return err
                }

All 11 comments

I also came here to report error: pointer is missing a nullability type specifier but for me it was introduced by updating to Xcode Version 10.2 (10E125). It worked before using the previous version (all running go1.12).

Seeing this as well with yesterday's release of Xcode 10.2. For now I have just disabled the warning:

diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index 31878bb..6a8c32c 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -129,6 +129,7 @@ func envInit() (err error) {
                        panic(fmt.Errorf("unknown GOARCH: %q", arch))
                }
                cflags += " -fembed-bitcode"
+               cflags += " -Wno-nullability-completeness"
                if err != nil {
                        return err
                }

@DavidCorsha
@cryptix
Thanks!! This works well.

@ReboundKay @DavidCorsha
I did as DavidCorsha said
and "go install golang.org/x/mobile/cmd/gomobile"
it works
thank you very much

I'm also seeing this after upgrading to Xcode 10.2.

@ReboundKay Maybe keep the issue open until it is fixed in gomobile? :)

I did as @DavidCorsha said. The Api.framework has been built successfully with gomobile and I put it in the xcode project. But, xcode compilation has failed with following error:

ld: '.../Api.framework/Api(go.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64

I suspect it could be because I am using go minor version 1.12.1 instead of building go from source code from master branch. https://golang.org/doc/install/source

Different issue but you can disable bitcode in your project settings as well.

As I supposed the error was because the non latest version of go language.
I have edited env.go, installed the latest source version of go and gomobile with:

brew install go --HEAD
go install golang.org/x/mobile/cmd/gomobile
gomobile bind -target=ios  -v myApi

After that, the xcode project is properly built with enabled bitcode

I re-opened this here, as I'm still seeing it: https://github.com/golang/go/issues/31284

As I supposed the error was because the non latest version of go language.
I have edited env.go, installed the latest source version of go and gomobile with:

brew install go --HEAD
go install golang.org/x/mobile/cmd/gomobile
gomobile bind -target=ios  -v myApi

After that, the xcode project is properly built with enabled bitcode

Hw do you use the --HEAD version when you
perform gomobile bind -target=ios -v myApi?

@prcela Thanks for your help. Unfortunately I'm unable to find any information on which version of go is required to enable bitcode support.

Can anybody elaborate why this is dependent on the go version?
And, is there a setting to tweak the ENABLE_BITCODE during a gomobile bind?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajstarks picture ajstarks  路  3Comments

enoodle picture enoodle  路  3Comments

jayhuang75 picture jayhuang75  路  3Comments

natefinch picture natefinch  路  3Comments

OneOfOne picture OneOfOne  路  3Comments