Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: asset.Open does not work in iOS when called within a generated framework #37177

Open
phil-flyclops opened this issue Feb 11, 2020 · 1 comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@phil-flyclops
Copy link

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

$ go version
go version go1.13.6 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=""
GOCACHE="/Users/phil/Library/Caches/go-build"
GOENV="/Users/phil/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/phil/Projects/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/opt/go/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
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/s_/fn36m4ms5pb1dhwc8jsn35fm0000gn/T/go-build556855453=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Exported a gomobile bind produced framework which attempted to use golang.org/x/mobile/asset's Open function
https://godoc.org/golang.org/x/mobile/asset#Open

I used the platform specific output in Android and iOS projects.

What did you expect to see?

I expected that on Android I would be able to read the file at run time if it was placed in the src/main/assets directory of the Android project where our GoMobile library was being included

I expected that on iOS I would be able to read the file at run time if it was set up as a Bundle Resource in XCode for the project where our GoMobile framework was being included

What did you see instead?

On Android it was able to discover a JSON file in the src/main/assets directory with a known name without issue.

On iOS I added the file in XCode and verified it was available in the [[NSBundle mainBundle] resourcePath] directory in Objective-C at runtime. Gomobile could not discover this, and was looking in a relatively pathed /assets directory instead of the directory where Bundle Resources where placed in the app.

The source code of the iOS implementation of the function does not seem to actually use any native APIs to discover the root of where it should look for bundle resources https://github.com/golang/mobile/blob/master/asset/asset_darwin_armx.go

@gopherbot gopherbot added this to the Unreleased milestone Feb 11, 2020
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Feb 11, 2020
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 14, 2020
@dmitshur
Copy link
Contributor

/cc @hyangah @hajimehoshi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants