Skip to content

NBSChain/Go_iosTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go_iosTest Xcode集成go语言集成sdk

#必要条件
go语言环境
gomobile
Xcode

#go语言代码 保存路径:golang.org/x/mobile/example/bind/hello/hello.go
package hello
import "fmt"

func Greetings(name string) string {
return fmt.Sprintf("Hello, %s!", name)
}

#对go代码进行封装
1 获取代码path
$ go get -d golang.org/x/mobile/example/bind/hello
2 进行集成封装
$ cd $GOPATH/src/golang.org/x/mobile/example/bind
$ gomobile bind -target=ios golang.org/x/mobile/example/bind/hello
此命令在hello路径下生成Hello.framework

#在Xcode中集成Hello.framework
打开新建工程Go_iosTest
拖拽hello.framework文件到xcode项目内
在需要的地方#import "Hello/hello.h"引入头文件
HelloGreetings(@"") 调取go模块方法并传递参数

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published