Gomobile: Cannot build `rclone/librclone/gomobile` for the iOS target

What is the problem you are having with rclone?

I'm trying to build a library by using librclone for iOS with gomobile. For Android, it works perfectly. However, for iOS, the compilation will exit with some error.

The command I used is:

gomobile bind -v -target=iossimulator github.com/rclone/rclone/librclone/gomobile

However, the build cannot continue with such an error:

gomobile: iossimulator/arm64: go build -v -buildmode=c-archive -o /var/folders/cd/j79005393f7_zbyjw3zpkrlc0000gn/T/gomobile-work-1985761860/gomobile-iossimulator-arm64.a ./gobind failed: exit status 2

I started to debug gomobile and found:

# github.com/shirou/gopsutil/v3/cpu
/Users/[username]/golang/pkg/mod/github.com/shirou/gopsutil/v3@v3.21.8/cpu/cpu_darwin_cgo.go:15:10: fatal error: 'libproc.h' file not found
#include <libproc.h>
         ^~~~~~~~~~~
1 error generated.

Looks like gopsutil is not compatible with iOS?

Run the command 'rclone version' and share the full output of the command.

N/A

Which cloud storage system are you using? (eg Google Drive)

N/A

The command you were trying to run (eg rclone copy /tmp remote:tmp)

gomobile bind -v -target=iossimulator github.com/rclone/rclone/librclone/gomobile

The rclone config contents with secrets removed.

N/A

A log from the command with the -vv flag

N/A

Update: It might be related to: iOS support: fatal error: 'libproc.h' file not found · Issue #1230 · shirou/gopsutil · GitHub

To have a quick fix, remove gopstil would be a feasible solution for now.

// in osversion.go
func GetOSVersion() (osVersion, osKernel string) {

	return "", ""
}

I believe we can write some platform specific code but this does not work:

// Created `osversion_ios.go`
//go:build ios
// +build ios

package buildinfo

// GetOSVersion returns OS version, kernel and bitness
func GetOSVersion() (osVersion, osKernel string) {

	return "", ""
}

gomobile may build all dependencies in go.mod.

That looks like a good approach but you will need to add a build tag here

To stop it building on ios.

I'd suggest you return "ios", "unknown" if you can't fill in the correct details easily.

1 Like

Thanks!

I created a PR: gomobile: iOS support by imWildCat · Pull Request #5919 · rclone/rclone · GitHub

1 Like