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: gomobile bind: add flag to disable package name prefix in iOS classes #32573

Open
ealymbaev opened this issue Jun 12, 2019 · 6 comments
Labels
FeatureRequest 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

@ealymbaev
Copy link

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

$ go version
go version go1.12.5 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ealymbaev/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ealymbaev/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/ealymbaev/projects/go-fee-rate-kit/go.mod"
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/k6/bvkt3fss5y16k_y3vyftfq1h0000gp/T/go-build635284137=/tmp/go-build -gno-record-gcc-switches -fno-common"

When binding an iOS framework with:

gomobile bind -target ios some-package

in generated header files all classes DO have prefix of package name. I tried using -prefix flag, but it adds even additional prefix to class names.

I need a way to remove package name prefix, so the class name remain exactly the same as in Go code.

@gopherbot gopherbot added this to the Unreleased milestone Jun 12, 2019
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jun 12, 2019
@hyangah
Copy link
Contributor

hyangah commented Jun 12, 2019

Is it not possible to directly use the gobind instead of gomobile bind and replace/modify the generated names to your liking?

BTW we chose to include the package names in name generation because in Go, package names are important part of exported names (e.g. Go code uses fmt.Fprintf, not Fprintf), and even choosing the right package name is often discussed in various Go best-practice docs. e.g. https://blog.golang.org/package-names

@FiloSottile FiloSottile added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 14, 2019
@triztian
Copy link

triztian commented Jul 25, 2019

I think requiring a prefix (defaulting to the package name) is ok, however being able to completely override it would be nice:

in generated header files all classes DO have prefix of package name. I tried using -prefix flag, but it adds even additional prefix to class names.

I've found myself in the situation in which I'd like to have different prefix but to do so I've got to rename the package abc statements in all of the files.

@ToJen
Copy link

ToJen commented Jun 26, 2020

Is there a solution or work around to this? Android doesn't have this issue?

@MaggieNgWu
Copy link

Is there a solution around to this?

@Artanidos
Copy link

Artanidos commented Jun 11, 2023

Is there a solution or work around to this? Android doesn't have this issue?

Same issue on Android.
I have to do imports like this:

import lib.Lib
import database.Database

In Kotlin and Java we normally use a reverse uri for package names to avoid naming conflicts:

import at.crowdware.lib
import at.crowdware.database

@yfwz100
Copy link

yfwz100 commented Aug 29, 2023

Is there any progress? Now it conflicts with android's code generation strategy. In Android, the imported client doesn't have prefix while iOS has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest 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

10 participants