-
Notifications
You must be signed in to change notification settings - Fork 18k
x/mobile: gobind type-checking fails with v2+ modules #33272
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
Comments
gomobile does not work in module mode. See #27234 |
@AlexRouSg Thank you for the reply yes and thank you for the link!, I was aware of this limitation, however this issue is slightly different, in the issue that you mention the build is done with
(notice the In this issue the the build is done inside a
The
And the type-check error points towards the module not being tried again (for whatever reason), in this situation the imported package After all of that I'm not denying that the root issue is the one you linked, but it could be that it's a different one. |
The issue is This will not work since there is no such package. |
cc @eliasnaur @hyangah for comments about retrying without |
I have a bit more info, after playing a bit with the source, I narrowed the error to this line: Basically a syntax-check is performed before any build is attempted, the syntax check happens without the minimal version compat that the I think it might be possible to provide an Example Excerpt: https://golang.org/pkg/go/types/#example_Info fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "fib.go", input, 0)
if err != nil {
log.Fatal(err)
}
// Type-check the package.
// We create an empty map for each kind of input
// we're interested in, and Check populates them.
info := types.Info{
Types: make(map[ast.Expr]types.TypeAndValue),
Defs: make(map[*ast.Ident]types.Object),
Uses: make(map[*ast.Ident]types.Object),
}
var conf types.Config
pkg, err := conf.Check("fib", fset, []*ast.File{f}, &info)
if err != nil {
log.Fatal(err)
} |
I've provided a working patch here, well at least for the 2 sample projects: Basically it provides a custom importer that performs an in-memory rewrite of import paths of packages that have major versions in their paths i.e: This does not add support for modules but rather it allows you to import packages that have opted into go modules and that have a To test the patch, just clone the branch from here https://github.com/triztian/mobile/tree/issue/33272 and reinstall the
You may also need to re-init gomobile but I'm not entirely sure if thats necessary:
SetupClone the sample projects into your gopath (they've been updated): Then try and build the The relevant proofs are that // github.com/triztian/gomobile-v2target/export.go:8
v2mod "github.com/triztian/gomobile-v2mod/v2"
// github.com/triztian/gomobile-v2mod/math.go:4
import "github.com/triztian/gomobile-v2mod/v2/subpkg" To build
You will need a swift compiler installed:
Successful Output:
There is a minimal swift file to test the framework and functionality: import Mobile
import Foundation
print("Testing")
MobileMain()
print("Sum call: \(MobileSum(10, 8))") I've not tested how it behaves when a |
We are discussing to support Go module at #27234 |
Is this still an issue? |
Hi @hajimehoshi I can try and repro with the latest releases, I'll give it a go most likely this weekend. Dealing with iOS 14. Thank you for checking in!. |
Assume this is not an issue anymore because there are modules that use gomobile but also in v2 mode, eg. fyne-io/fyne. Close as outdated. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, it also happens on 1.12.6
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The setup consists of 2 packages a
gomobile-v2target
(mobile
) which imports a package that isv2
suffixed, and agomobile-v2mod
(v2mod
) package that has a sub package that is imported in the root package and that is declared asv2
.The project that produces the framework can be located here:
The project that is v2 and is imported by the previous one can be found here:
Both projects exist under the
$GOPATH
and I've verified that they build successfully without usinggomobile
and withGO111MODULE=off
:Framework producer
Build Outputv2 module
Build OutputWhen trying to generate the framework with the following command:
We get the following output:
if it helps, this is the structure of my
GOPATH
:What did you expect to see?
A
Mobile.framework
bundle.What did you see instead?
The following error message:
The text was updated successfully, but these errors were encountered: