Build error using nux build -target=ios on macOS
prologic opened this issue Β· comments
What version of Go are you using (go version
)?
$ go version go version go1.18.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="/Users/prologic/go/bin" GOCACHE="/Users/prologic/Library/Caches/go-build" GOENV="/Users/prologic/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/prologic/go/pkg/mod" GONOPROXY="github.com/aucloud" GONOSUMDB="github.com/aucloud" GOOS="darwin" GOPATH="/Users/prologic/go" GOPRIVATE="github.com/aucloud" GOPROXY="https://goproxy.mills.io/" GOROOT="/usr/local/Cellar/go/1.18.2/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.18.2/libexec/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.18.2" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/prologic/tmp/samples/hello/go.mod" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8h/c9gl4gms3fjb0kyf7nb42ybh0000gn/T/go-build4085119584=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
$ git clone https://github.com/nuxui/samples.git
$ cd samples/hello
$ go mod tidy
$ nux build -target=ios -bundleid="hello.nuxui" .
nux: go build -ldflags=-w -o=/var/folders/8h/c9gl4gms3fjb0kyf7nb42ybh0000gn/T/gomobile-work-4157362954/ios/arm64 nuxui.org/samples/hello failed: exit status 2
# nuxui.org/nuxui/nux/internal/darwin
../../../go/pkg/mod/nuxui.org/nuxui@v0.0.6/nux/internal/darwin/NSCursor.go:9:9: fatal error: 'Cocoa/Cocoa.h' file not found
#import <Cocoa/Cocoa.h>
^~~~~~~~~~~~~~~
1 error generated.
What did you expect to see?
No error. A successful build.
I expect nux build
to know how to find the required C dependencies on my system.
NB: I have the latest versions of XCode Command-line Tools as well as XCode and can build iOS apps (for example with Flutter) just fine.
What did you see instead?
$ nux build -target=ios -bundleid="hello.nuxui" .
nux: go build -ldflags=-w -o=/var/folders/8h/c9gl4gms3fjb0kyf7nb42ybh0000gn/T/gomobile-work-4157362954/ios/arm64 nuxui.org/samples/hello failed: exit status 2
# nuxui.org/nuxui/nux/internal/darwin
../../../go/pkg/mod/nuxui.org/nuxui@v0.0.6/nux/internal/darwin/NSCursor.go:9:9: fatal error: 'Cocoa/Cocoa.h' file not found
#import <Cocoa/Cocoa.h>
^~~~~~~~~~~~~~~
1 error generated.
@prologic you used nuxui@v0.0.6, update to 0.0.9
Really?! π€ I could have sworn I re-installed with @latest
π
$ nux version
nux version unknown: cannot test nux binary: exit status 1, no required module provides package nuxui.org/nuxui/cmd/nux: go.mod file not found in current directory or any parent directory; see 'go help modules'
Any way we can bake the version information into the binary?
In fact I have no way to confirm this currently, so I'll just build from source for now:
$ go install nuxui.org/nuxui/cmd/nux@latest
go: finding module for package golang.org/x/tools/go/packages
go: finding module for package golang.org/x/mod/modfile
go: found golang.org/x/mod/modfile in golang.org/x/mod v0.5.1
go: found golang.org/x/tools/go/packages in golang.org/x/tools v0.1.12
Okay I've installed/built from master:
(β |local:default)
prologic@Jamess-iMac
Wed Aug 03 11:39:16
~/tmp/nuxui
(master) 0
$ nux version
gomobile version +d790175 Tue Aug 2 17:59:24 2022 +0800 (android,ios,iossimulator,macos,maccatalyst); androidSDK=/Users/prologic/Library/Android/sdk/platforms/android-31
Unfortunately it's the same result:
(β |local:default)
prologic@Jamess-iMac
Wed Aug 03 11:40:08
~/tmp/samples/hello
(master) 0
$ nux build -target=ios -bundleid="hello.nuxui" .
nux: go build -ldflags=-w -o=/var/folders/8h/c9gl4gms3fjb0kyf7nb42ybh0000gn/T/gomobile-work-816573289/ios/arm64 nuxui.org/samples/hello failed: exit status 2
# nuxui.org/nuxui/nux/internal/darwin
../../../go/pkg/mod/nuxui.org/nuxui@v0.0.6/nux/internal/darwin/NSCursor.go:9:9: fatal error: 'Cocoa/Cocoa.h' file not found
#import <Cocoa/Cocoa.h>
^~~~~~~~~~~~~~~
1 error generated.
@prologic change mod file manualy
module nuxui.org/samples/hello
go 1.18
require nuxui.org/nuxui v0.0.9
then:
go mod tidy
Pretty sure I update the samples
repo too locally. Lemme double check...
Ooops my mistake:
$ cat go.mod
module nuxui.org/samples/hello
go 1.18
require nuxui.org/nuxui v0.0.6
Apparently I did not, sorry! π€
I didn't make it clearπ
Nope all good! It was my bad π€¦ββοΈ
Successfully built the "hello" sample!
Also successfully installed it to my iPhone π₯³
So far so good π Nice work!