[mirror] Go on Mobile

Overview

Go support for Mobile devices

Go Reference

The Go mobile repository holds packages and build tools for using Go on mobile platforms.

Package documentation as a starting point:

Caution image

The Go Mobile project is experimental. Use this at your own risk. While we are working hard to improve it, neither Google nor the Go team can provide end-user support.

This is early work and installing the build system requires Go 1.5. Follow the instructions on golang.org/wiki/Mobile to install the gomobile command, build the basic and the bind example apps.

--

Contributions to Go are appreciated. See https://golang.org/doc/contribute.html.

Comments
  • cmd/gomobile: improve support for macOS and Catalyst

    cmd/gomobile: improve support for macOS and Catalyst

    This is is a follow-up from my previous PR (#65). It makes gomobile aware of GOOS=ios and adds support for specifying specific Apple platforms, instead of overloading the "ios" platform.

    Supported platforms: ios, iossimulator, macos, and maccatalyst

    These can now be specified the -target argument to gomobile, e.g.: gomobile build -target=ios,iossimulator,macos,maccatalyst

    It preserves the current behavior of -target=ios, which will build for ios and iossimulator on supported architectures (arm64 and amd64).

    It adds platform-specific build tags so Go code can discriminate between different Apple platforms like maccatalyst (UIKit on macOS).

    This PR also fixes a number of broken tests.

    TODO: cgo has a bug where c-archive builds targeting Catalyst will fail unless -tags=ios is supplied. See https://golang.org/issues/47228

    Fixes https://golang.org/issues/47212 Updates https://golang.org/issues/47228

    cla: yes 
    opened by ydnar 101
  • cmd/gomobile: support macOS and Catalyst

    cmd/gomobile: support macOS and Catalyst

    Add support for macOS (non-Catalyst) and Catalyst targets.

    The compiled library is packaged into a "fat" XCFramework file (as opposed to a Framework), which includes binaries for iOS, macOS, MacCatalyst (iOS on macOS), and iOS Simulator targets, for amd64 and arm64 architectures.

    The generated XCFramework file is suitable for distribution as a binary Swift Package Manager package: https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages

    This change is based on earlier work: https://github.com/golang/mobile/pull/45 https://github.com/golang/mobile/pull/63

    Fixes golang/go#36856

    cla: yes 
    opened by ydnar 65
  • cmd/gomobile: add missing latest tag to gobind

    cmd/gomobile: add missing latest tag to gobind

    Go install requires a version to be provided after the package name. gomobile init command is updated to reflect this new requirement

    Fixes golang/go#50994

    opened by morningsend 34
  • Support building for target catalyst

    Support building for target catalyst

    As of macOS 10.15 target catalyst can be used to build an iPad app to run on macOS. Existing .Framework built with gomobile produces the following error when targetting catalyst:

    error: Building for Mac Catalyst, but the linked framework 'Sample.framework' was built for iOS + iOS Simulator.
    You may need to restrict the platforms for which this framework should be linked in the target editor, or replace it with an XCFramework that supports both platforms. (in target 'MySampleApp' from project 'MySampleApp')
    

    ~~This PR adds a case for catalyst (although architecture is just amd64) when configuring the environment for each architecture, providing the flags needed to enable the built .Framework to be used with catalyst.~~

    Fixes https://github.com/golang/go/issues/36856

    Update 18-Jan-2021

    This PR has been updated to provide nominally working support of .xcframework generation with go1.15, which has removed support for some 32 bit architectures. See: https://github.com/dpwiese/mobile/pull/1#issuecomment-761931422. In addition, unlike https://github.com/dpwiese/mobile/pull/1 this PR doesn't require manual thinning or combining of the generated .frameworks for each of the various "architectures" - this is now done automatically.

    Todo Running go test fails with the following.

    bind_test.go:321: gomobile bind failed: exit status 1
        /var/folders/rx/h40bjl5n0s1fvr5h2w278tm80000gn/T/gomobile-test335293790/gomobile: darwin-catalyst: go build -tags ios -buildmode=c-archive -o /var/folders/rx/h40bjl5n0s1fvr5h2w278tm80000gn/T/gomobile-work-224727912/Cgopkg-amd64.a ./gobind failed: exit status 1
        go: cannot determine module path for source directory /private/var/folders/rx/h40bjl5n0s1fvr5h2w278tm80000gn/T/gomobile-work-224727912/src (outside GOPATH, module path must be specified)
    

    Note: on current master branch TestIOSBuild fails

    cla: yes 
    opened by dpwiese 26
  • bind: annotate ObjC types with nullability annotations

    bind: annotate ObjC types with nullability annotations

    This highly improves interop with Swift. It would map all pointers as implicitly unwrapped optionals, which skip all null safety checks. Adding _Nullable to pointer types makes swift map them as optionals.

    Also constructors are now nullable since it's valid to return nil from Go code.

    cla: yes 
    opened by champo 21
  • cmd/gomobile: support Catalyst and Apple Silicon

    cmd/gomobile: support Catalyst and Apple Silicon

    This PR is derived from golang/mobile#45 .

    I changed the build process and it will create 3 frameworks for ios, simulator and catalyst. Every framework has a fat library contains both arm64 and x86_64 (except ios that only needs arm64).

    Finally create one xcframework from all 3 fat frameworks and this xcframework contains every platform and architecture.

    cla: yes 
    opened by waylybaye 19
  • cmd/gomobile: remove unnecessary IsDir check

    cmd/gomobile: remove unnecessary IsDir check

    The check when looking for android platform is unnecessarily stringent in that the error would be caught by the call to os.Stat, and it fails when the android platform folder is a symlink, which is the case when developing on NixOs.

    cla: yes 
    opened by jmorag 17
  • example: add Swift Package Manager example

    example: add Swift Package Manager example

    Add an example Swift package built with gomobile for multiple Apple platforms (ios, iosimulator, macos, and maccatalyst).

    It builds an XCFramework file which is linked as a binary dependency by Swift Package Manager. The resulting Swift package can be imported into an iOS, macOS, or Catalyst app and called from Swift.

    It has tests written in Swift. To run the tests, run swift test from the example/swift-package directory.

    Depends on golang.org/cl/334689 (golang/mobile#70).

    cla: yes 
    opened by ydnar 13
  • bind/java: Do not get ApplicationContext via reflection, ask for it when needed.

    bind/java: Do not get ApplicationContext via reflection, ask for it when needed.

    Previously any library created using gobind used reflection to get the ApplicationContext. The methods used are disallowed in Android 9 causing any library to crash. However the ApplictionContext is not required and only needed when using RunOnJvm. This change adds an method to set the ApplicationContext when needed, but will not get it by default by using reflection.

    Fixes #31364

    cla: yes 
    opened by timcooijmans 12
  • example: updates for XCFramework and Mac Catalyst

    example: updates for XCFramework and Mac Catalyst

    This updates examples for the changes in golang.org/cl/334689 for .xcframework files and Mac Catalyst.

    Depends on golang.org/cl/334689

    https://go-review.googlesource.com/c/mobile/+/334689/28/example/bind/ios/README#1

    cla: yes 
    opened by ydnar 11
  • cmd/gomobile: xcframework and catalyst support

    cmd/gomobile: xcframework and catalyst support

    Talked with @waylybaye offline, I decided to continue #63 and #45.

    @waylybaye:

    I changed the build process and it will create 3 frameworks for ios, simulator and catalyst. Every framework has a fat library contains both arm64 and x86_64 (except ios that only needs arm64).

    Finally create one xcframework from all 3 fat frameworks and this xcframework contains every platform and architecture.

    Review comments at https://go-review.googlesource.com/c/mobile/+/288752 should be mostly resolved.

    cla: yes 
    opened by imWildCat 10
  • fix: In runInit, install gobind without @latest

    fix: In runInit, install gobind without @latest

    To "make sure gobind is up to date", runInit calls goInstall with "golang.org/x/mobile/cmd/[email protected]" . But it shouldn't have "@latest". This instruction can replace the gobind command in the user's $GOPATH/bin with an unexpected version. Also, it is possible that "@latest" has a breaking change with the user's application. It is better to call goInstall without "@latest" so that it will follow the directives in the user's go.mod file.

    opened by jefft0 2
  • cmd/gomobile: filter out xcrun warnings to get path

    cmd/gomobile: filter out xcrun warnings to get path

    Currently some installations of Xcode and Command Line Tools cause warnings about missing extensions which break parsing of paths returned from xcrun that gomobile depends on resulting in errors like this:

    cgo: C compiler "2022-09-07" not found: exec: "2022-09-07": executable file not found in $PATH
    

    This is caused by these warnings returned on stdout by xcrun:

     > xcrun --find clang
    2022-09-07 14:50:13.907 xcodebuild[69942:386823822] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-09-07 14:50:13.908 xcodebuild[69942:386823822] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-09-07 14:50:14.041 xcodebuild[69942:386823822] XType: com.apple.fonts is not accessible.
    2022-09-07 14:50:14.041 xcodebuild[69942:386823822] XType: XTFontStaticRegistry is enabled.
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
    

    Resulting in gomobile interpreting the date 2022-09-07 as Clang compiler.

    Resolves: https://github.com/golang/go/issues/53316

    opened by jakubgs 6
  • fix: Add attribute nonnull_error if returning pointer and error from Objective-C

    fix: Add attribute nonnull_error if returning pointer and error from Objective-C

    Consider the following Go code with a method that returns a byte array and an error:

    package example
    
    type TestClass struct {
    }
    func (req *TestClass) GetData() ([]byte, error) {
            return nil, nil
    }
    

    gobind creates an Objective-C method which returns NSData* and an error:

    - (NSData* _Nullable)getData:(NSError* _Nullable* _Nullable)error {
        ....
    }
    

    The method signature seen by Swift is func getData() throws -> Data . The problem is that Data is not optional, and when the Objective-C method returns NULL the program crashes. This is the default signature as explained in the Swift documentation: https://clang.llvm.org/docs/AttributeReference.html#swift-error

    But this is not appropriate for gobind since it is valid for Go to return a nil value. We don't want the crash. This pull request updates asSignature so that if the method returns an error and the method returns a nullable pointer to NSData or NSString, then add the nonnull_error attribute as explained in the Swift documentation.

    With this attribute, the method signature seen by Swift is func getData() throws -> Data? . When the Go function returns nil, it is returned as a nil optional value without crashing.

    opened by jefft0 4
  • Update README.md

    Update README.md

    Fixed a line break/seperator. Line break/seperator is added by 3 hyphens --- but in the previous README it was just 2 hyphens -- It ain't much, but it's honest work.

    opened by Sarthak2143 1
  • onLowMemory funktionality

    onLowMemory funktionality

    I think this change (https://github.com/fyne-io/fyne/pull/2956) should be added to gomobile too, it is only 2 rows of imports and 2 rows to release memory if Android OS send onLowMemory signal ...

    opened by MatejMagat305 8
Owner
Go
The Go Programming Language
Go
[mirror] Go on Mobile

Go support for Mobile devices The Go mobile repository holds packages and build tools for using Go on mobile platforms. Package documentation as a sta

Go 5.2k Jan 3, 2023
Mirror - Mirror is command line tool for mirroring a web page

mirror mirror is command line tool for mirroring a web page. Caution Do not abus

Yusuke Wada 10 May 29, 2022
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps.

Beaver A Real Time Messaging Server. Beaver is a real-time messaging server. With beaver you can easily build scalable in-app notifications, realtime

Ahmed 1.4k Jan 1, 2023
Uniqush is a free and open source software system which provides a unified push service for server side notification to apps on mobile devices.

Homepage Download Blog/News @uniqush Introduction Uniqush (\ˈyü-nə-ku̇sh\ "uni" pronounced as in "unified", and "qush" pronounced as in "cushion") is

Uniqush 1.5k Jan 9, 2023
Mobile Blogging System

Mobile Blogging System

mattn 18 Mar 3, 2022
A collection of cool tools used by Mobile hackers. Happy hacking , Happy bug-hunting

A collection of cool tools used by Mobile hackers. Happy hacking , Happy bug-hunting Family project Table of Contents Weapons Contribute Thanks to con

HAHWUL 445 Jan 3, 2023
:zap: Transfer files over wifi from your computer to your mobile device by scanning a QR code without leaving the terminal.

$ qrcp Transfer files over Wi-Fi from your computer to a mobile device by scanning a QR code without leaving the terminal. You can support development

Claudio d'Angelis 9k Dec 28, 2022
Magma is an open-source software platform that gives network operators an open, flexible and extendable mobile core network solution.

Connecting the Next Billion People Magma is an open-source software platform that gives network operators an open, flexible and extendable mobile core

Magma 1.5k Dec 31, 2022
HTML Canvas 2D Context API for mobile, desktop and web

canvas HTML Canvas 2D Context API for mobile, desktop and web Context2D API https://www.w3.org/TR/2dcontext/ native code implement https://github.com/

GoPlus 2 Apr 22, 2022
Mobile Money API Handyman

pesakit pesakit is a highly configurable commandline tool that comes in handy during testing and development of systems that integrate with mobile mon

TECHCRAFT TECHNOLOGIES LIMITED 2 Nov 22, 2021
A Declarative Cloud Firewall Reverse Proxy Solution with Companion Mobile App

A declarative Cloud firewall reverse proxy solution with inbuilt DDoS protection and alerting mechanism to protect your servers and keeping an eye on those malicious requests

null 14 Aug 10, 2022
Building block for mobile money api clients

base the base code for creating mobile money api clients using golang build request request := NewRequestBuilder("login request", http.MethodPost, "ht

TECHCRAFT TECHNOLOGIES LIMITED 3 Jan 4, 2022
MTN Mobile Money API Client in Go

mtnmomo-go This package provides a generic go client template for the MTN Mobile Money API Installation mtnmomo-go is compatible with modern Go releas

Ndole Studio 4 Dec 27, 2022
A mobile security hash generator using golang

Mobile Security Hash Generator Project scope This little script is my first experiment using Go. I wrote it for my friend @marcotrumpet because he nee

null 0 Oct 10, 2022
Iran National Id, Bank Card Number, Mobile Number Validator for golang

Iran IDValidator Iran National Id, Bank Card Number, Mobile Number Validator for golang Installation go get -u github.com/mohammadv184/idvalidator Us

Mohammad Abbasi 1 Dec 20, 2021
Built in user interface, LAN file transfer, such as mobile phone, computer, tablet, different operating system

Modao Built in user interface, LAN file transfer, such as mobile phone, computer, tablet, different operating systems, etc., as well as text transfer

null 0 May 7, 2022
Magma: Gives network operators an open, flexible and extendable mobile core network solution

Connecting the Next Billion People Magma is an open-source software platform tha

nikhilc 0 Dec 24, 2021
The Bhojpur MDM is a software-as-a-service product used as a Mobile Device Manager based on Bhojpur.NET Platform for application delivery.

Bhojpur MDM - Mobile Device Manager The Bhojpur MDM is a software-as-a-service product used as a Mobile Device Manager based on Bhojpur.NET Platform f

Bhojpur Consulting 0 Dec 31, 2021
Bintris - a mobile game developed in Go

?? Bintris Bintris is a mobile game developed in Go! Support me by buying this game on Google PlayStore ?? : https://play.google.com/store/apps/detail

Magnus 155 Nov 18, 2022
Mirror of Apache Calcite - Avatica Go SQL Driver

Apache Avatica/Phoenix SQL Driver Apache Calcite's Avatica Go is a Go database/sql driver for the Avatica server. Avatica is a sub-project of Apache C

The Apache Software Foundation 103 Nov 3, 2022