Gomobile + Swift Package Manager
gomobile + Swift Package Manager
Example Go package built into an XCFramework for Swift Package Manager, targeting iOS, macOS, and macCatalyst targets.
Calling Go from Swift
This package implements a simple API to fetch a URL using an HTTP GET
request and return the response bytes.
var error: NSErrorPointer = nil
guard let response = GoGet("https://golang.org/", error) else {
XCTFail("response == nil")
return
}
guard error == nil else {
return
}
guard let str = String(data: response, encoding: .utf8) else {
return
}
Requirements
Go 1.16, Swift 5.3, and Xcode 11 or later.
Usage
To build the XCFramework and Swift package: make build
To test: make test
Author
© Alta Software, LLC