golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.07k stars 17.68k forks source link

x/mobile/bind: after binding ios framework for go-ipfs it has only skipped fields. #31737

Closed mNizhurin closed 5 years ago

mNizhurin commented 5 years ago

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

$ go version go1.12.4 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/max/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/max/.go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
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/kh/8ts9nvy534b3b0n8fwzpqrwm0000gn/T/go-build592238090=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go get github.com/ipfs/go-ipfs/cmd/ipfs go get -d github.com/ipfs/go-ipfs/cmd/ipfs/... gomobile bind -target=ios github.com/ipfs/go-ipfs/core

What did you expect to see?

Framework with .h file containing interface for classes, constructors and methods to work with ipfs.

What did you see instead?

As you can see, all methods and properties are skipped because of unsupported type:

CoreIpfsNode.h:

@property(strong, readonly) _Nonnull id _ref;

- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (nonnull instancetype)init;
// skipped field IpfsNode.Identity with unsupported type: github.com/libp2p/go-libp2p-peer.ID

// skipped field IpfsNode.Repo with unsupported type: github.com/ipfs/go-ipfs/repo.Repo

// skipped field IpfsNode.Pinning with unsupported type: github.com/ipfs/go-ipfs/pin.Pinner

// skipped field IpfsNode.Mounts with unsupported type: github.com/ipfs/go-ipfs/core.Mounts

// skipped field IpfsNode.PrivateKey with unsupported type: github.com/libp2p/go-libp2p-crypto.PrivKey

// skipped field IpfsNode.PNetFingerprint with unsupported type: github.com/ipfs/go-ipfs/core/node.PNetFingerprint

// skipped field IpfsNode.Peerstore with unsupported type: github.com/libp2p/go-libp2p-peerstore.Peerstore

// skipped field IpfsNode.Blockstore with unsupported type: github.com/ipfs/go-ipfs-blockstore.GCBlockstore

// skipped field IpfsNode.Filestore with unsupported type: *github.com/ipfs/go-ipfs/filestore.Filestore

// skipped field IpfsNode.BaseBlocks with unsupported type: github.com/ipfs/go-ipfs/core/node.BaseBlocks

// skipped field IpfsNode.GCLocker with unsupported type: github.com/ipfs/go-ipfs-blockstore.GCLocker

// skipped field IpfsNode.Blocks with unsupported type: github.com/ipfs/go-blockservice.BlockService

// skipped field IpfsNode.DAG with unsupported type: github.com/ipfs/go-ipld-format.DAGService

// skipped field IpfsNode.Resolver with unsupported type: *github.com/ipfs/go-path/resolver.Resolver

// skipped field IpfsNode.Reporter with unsupported type: github.com/libp2p/go-libp2p-metrics.Reporter

// skipped field IpfsNode.Discovery with unsupported type: github.com/libp2p/go-libp2p/p2p/discovery.Service

// skipped field IpfsNode.FilesRoot with unsupported type: *github.com/ipfs/go-mfs.Root

// skipped field IpfsNode.RecordValidator with unsupported type: github.com/libp2p/go-libp2p-record.Validator

// skipped field IpfsNode.PeerHost with unsupported type: github.com/libp2p/go-libp2p-host.Host

// skipped field IpfsNode.Bootstrapper with unsupported type: io.Closer

// skipped field IpfsNode.Routing with unsupported type: github.com/libp2p/go-libp2p-routing.IpfsRouting

// skipped field IpfsNode.Exchange with unsupported type: github.com/ipfs/go-ipfs-exchange-interface.Interface

// skipped field IpfsNode.Namesys with unsupported type: github.com/ipfs/go-ipfs/namesys.NameSystem

// skipped field IpfsNode.Provider with unsupported type: github.com/ipfs/go-ipfs/provider.Provider

// skipped field IpfsNode.Reprovider with unsupported type: *github.com/ipfs/go-ipfs/exchange/reprovide.Reprovider

// skipped field IpfsNode.IpnsRepub with unsupported type: *github.com/ipfs/go-ipfs/namesys/republisher.Republisher

// skipped field IpfsNode.AutoNAT with unsupported type: *github.com/libp2p/go-libp2p-autonat-svc.AutoNATService

// skipped field IpfsNode.PubSub with unsupported type: *github.com/libp2p/go-libp2p-pubsub.PubSub

// skipped field IpfsNode.PSRouter with unsupported type: *github.com/libp2p/go-libp2p-pubsub-router.PubsubValueStore

// skipped field IpfsNode.DHT with unsupported type: *github.com/libp2p/go-libp2p-kad-dht.IpfsDHT

// skipped field IpfsNode.P2P with unsupported type: *github.com/ipfs/go-ipfs/p2p.P2P

// skipped field IpfsNode.Process with unsupported type: github.com/jbenet/goprocess.Process

/**
 * Flags
 */
@property (nonatomic) BOOL isOnline;
@property (nonatomic) BOOL isDaemon;
// skipped method IpfsNode.Bootstrap with unsupported parameter or return types

/**
 * Close calls Close() on the App object
 */
- (BOOL)close:(NSError* _Nullable* _Nullable)error;
// skipped method IpfsNode.Context with unsupported parameter or return types
hyangah commented 5 years ago

That is the limitation of x/mobile/bind. Not ideal, but is it not possible to write a wrapper library for go-ipfs including APIs meaningful for mobile applications and using the supported types as listed in https://godoc.org/golang.org/x/mobile/cmd/gobind#hdr-Type_restrictions?

mNizhurin commented 5 years ago

@hyangah, so you say this must be done on the side of go-ipfs?

hyangah commented 5 years ago

@mNizhurin that's one way. Another way is that the mobile app developer who wants to use the go library writes a small wrapper containing only needed types and interfaces, and bind the wrapper.

bcmills commented 5 years ago

Seems like there isn't anything left to do on the x/mobile/bind side, so closing.