Skip to content

x/mobile: bind to macOS with google.golang.org/grpc would cause "framework 'CoreAudioTypes' not found" #67006

Open
@honmaple

Description

@honmaple

Go version

go version go1.22.2 darwin/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/xxx/Library/Caches/go-build'
GOENV='/Users/xxx/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/xxx/repo/golang/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/xxx/repo/golang'
GOPRIVATE=''
GOPROXY='https://proxy.golang.com.cn,direct'
GOROOT='/usr/local/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/Cellar/go/1.22.2/libexec/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/xxx/git/maple-app/wengu/server/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/44/hnrgfyfn0fsb8lqwk_0h2jvm0000gn/T/go-build642643784=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

package server

import (
	"fmt"
)

type Service struct {
}

func (srv *Service) Start(path string) error {
	fmt.Println("start")
	return nil
}
MACOSX_DEPLOYMENT_TARGET=10.14 gomobile bind -target macos -o server.xcframework

And add Server.framework to macOS project

What did you see happen?

Everything is working well.

But If add google.golang.org/grpc

import (
	"fmt"
	_ "google.golang.org/grpc"
)

It raise some error

──╼ flutter run -d macOS
Launching lib/main.dart on macOS in debug mode...
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
Undefined symbols for architecture x86_64:
  "_res_9_nclose", referenced from:
      _runtime.text in Server[x86_64][2](go.o)
  "_res_9_ninit", referenced from:
      _runtime.text in Server[x86_64][2](go.o)
  "_res_9_nsearch", referenced from:
      _runtime.text in Server[x86_64][2](go.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **

Building macOS application...                                           
Error: Build process failed

I don't know why, but it did.

What did you expect to see?

gomobile bind to macOS without errors happed

Xcode version: 15.3

└──╼ go install golang.org/x/mobile/cmd/gomobile@latest
└──╼ md5sum /Users/xxx/repo/golang/bin/gomobile
c3ae3df39ca098658b55d7a3f7677d82  /Users/xxx/repo/golang/bin/gomobile
└──╼ gomobile version
gomobile version unknown: binary is out of date, re-install it
└──╼ go install golang.org/x/mobile/cmd/gomobile@v0.0.0-20240404231514-09dbf07665ed
└──╼ md5sum /Users/xxx/repo/golang/bin/gomobile
c3ae3df39ca098658b55d7a3f7677d82  /Users/xxx/repo/golang/bin/gomobile

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-DarwinmobileAndroid, iOS, and x/mobile

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions