golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.02k stars 17.54k forks source link

x/mobile/cmd/gomobile: bind -target=ios app.sdk/lightControl fail #31670

Open orange-jacky opened 5 years ago

orange-jacky commented 5 years ago

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

go version go1.12.4 darwin/amd64

Does this issue reproduce with the latest release?

yes, always

What operating system and processor architecture are y, ou using (go env)?

GOARCH="amd64" GOBIN="/Users/fredlee/Documents/develop/go/workspace/bin" GOCACHE="/Users/fredlee/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/fredlee/Documents/develop/go/workspace" 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/34/z2z_vp1573g5014m8k7wys100000gn/T/go-build760905676=/tmp/go-build -gno-record-gcc-switches -fno-common"

go env Output
$ go env

What did you do?

What did you expect to see?

macbookpro:lightControl fredlee$ gomobile bind -o android/lightControl.aar -target=android app.sdk/lightControl macbookpro:lightControl fredlee$ gomobile bind -target=ios app.sdk/lightControl

What did you see instead?

macbookpro:lightControl fredlee$ gomobile bind -o android/lightControl.aar -target=android app.sdk/lightControl macbookpro:lightControl fredlee$ gomobile bind -target=ios app.sdk/lightControl gomobile: darwin-arm: go build -tags ios -buildmode=c-archive -o /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/lightControl-arm.a gobind failed: exit status 2 gobind In file included from LightControl_darwin.m:9: /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:87:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:88:22: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:89:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:90:25: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:95:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:96:26: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:99:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:100:22: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:101:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:102:17: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:109:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:110:19: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:111:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:112:19: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:113:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:114:19: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:115:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:116:19: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-626724909/src/gobind/LightControl.objc.h:272:4: error: expected a type fatal error: too many errors emitted, stopping now [-ferror-limit=]

jdiegodcp commented 5 years ago

Was it working fine before? If so what change did you do to have this issue?

orange-jacky commented 5 years ago

Was it working fine before? If so what change did you do to have this issue?

by add my code one by one, i find that this problem, could you tell me how to fix it?

type S struct{ A byte } macbookpro:Downloads fredlee$ gomobile bind -target=ios golang.org/x/mobile/example/bind/lightControl gomobile: darwin-arm: go build -tags ios -buildmode=c-archive -o /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-389231512/lightControl-arm.a gobind failed: exit status 2 gobind In file included from LightControl_darwin.m:9: /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-389231512/src/gobind/LightControl.objc.h:119:4: error: expected a type /var/folders/34/z2z_vp1573g5014m8k7wys100000gn/T/gomobile-work-389231512/src/gobind/LightControl.objc.h:120:19: error: expected a type LightControl_darwin.m:146:4: error: expected a type LightControl_darwin.m:153:19: error: expected a type LightControl_darwin.m:149:2: error: unknown type name 'byte'; did you mean 'Byte'? /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk/usr/include/MacTypes.h:687:41: note: 'Byte' declared here LightControl_darwin.m:149:14: error: use of undeclared identifier 'byte' LightControl_darwin.m:150:9: error: implicit conversion of 'Byte' (aka 'unsigned char') to 'id' is disallowed with ARC LightControl_darwin.m:150:9: error: incompatible integer to pointer conversion returning 'Byte' (aka 'unsigned char') from a function with result type 'id' [-Werror,-Wint-conversion]

meanwhile type S struct{ A [1]byte }

macbookpro:Downloads fredlee$ gomobile bind -target=ios golang.org/x/mobile/example/bind/lightControl

it works

orange-jacky commented 5 years ago

type S struct{ A int8 }

it still works

triztian commented 5 years ago

I think only int, int8, int32 and int64 signed integers are supported, byte is an alias to uint8 which is unsigned.

Reference:

bcmills commented 5 years ago

CC @hyangah

joshuajiangdev commented 2 years ago

Just wanna check in to see if we have any updates of how to bind a lib contains byte type?

beansgum commented 2 years ago

I'm currently experiencing this compilation error when generating a library for ios.

error: unknown type name 'byte'; did you mean 'Byte'?"

I'm able to bypass the error by changing byte to Byte in here and here then I compile gobind and place it in my bin directory, this fixes the error for me.

triztian commented 2 years ago

Try replacing byte with uint8 in your go code.