help with ivy on ios/mobile

570 views
Skip to first unread message

Rob Pike

unread,
Oct 12, 2021, 8:15:49 PM10/12/21
to golan...@googlegroups.com
Ivy (robpike.io/ivy) is the "bignum calculator" that turned into an example for running Go programs on mobile platforms. On both Android and iOS, it is available for download and runs as a Go program wrapped, somewhat clumsily, by a native (Java or Objective-C) program. See golang.org/x/mobile/example/ivy.

The mobile version has had only one minor update since maybe 2015, although the underlying Go program has become much more robust and rich. I am in the process of trying to bring the mobile versions up to scratch.

The biggest technical stumbling block I have is how the demo runs on mobile (see https://github.com/golang/go/issues/48694). As a Go program running on a real OS, one can type

) demo

and get a nice interactive demo. On mobile, because the I/O is so constrained, that just doesn't work, and in fact until recent updates the failure mode was a complaint about a missing Go installation. That has now been fixed in the latest ivy build available on GitHub, but the demo experience is still missing on iOS.

On Android, there is a Demo button that drives the demo and works pretty well, I think; at least it does in the still-available mobile version. There is no similar facility available on iOS.

I am not a competent iOS programmer and am looking for a volunteer to help me add a Demo button, like the one on Android, so that the demo experience will be available on iOS. It should be very easy to do for a programmer skilled in Objective-C. All that's needed is the glue to connect a screen button to an existing API in the mobile piece of the existing Go program (robpike.io/ivy/mobile). 

Once this is sorted, I'll make sure Android still works. Meanwhile I've got some formatting stuff to do to make the in-program help better on mobile, and then we can update the mobile apps.

I would be grateful for any assistance.

-rob

Rob Pike

unread,
Oct 14, 2021, 7:15:15 PM10/14/21
to golan...@googlegroups.com
Pinging, hoping for some help.

Thanks.

-rob

Robert Engels

unread,
Oct 14, 2021, 7:25:18 PM10/14/21
to Rob Pike, golan...@googlegroups.com
What is your timeframe? I can probably help with this. 

On Oct 14, 2021, at 6:15 PM, Rob Pike <r...@golang.org> wrote:


--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/CAOXNBZRnn%3D1ufOcxNp-z1Zcinj_u6wfu_Mz0n23rFHhcBag3rw%40mail.gmail.com.

Rob Pike

unread,
Oct 14, 2021, 8:01:13 PM10/14/21
to Robert Engels, golan...@googlegroups.com
Thanks for offering. I'm hoping to have iOS app ready to ship by early November.

-rob

Robert Engels

unread,
Oct 14, 2021, 8:05:33 PM10/14/21
to Rob Pike, golan...@googlegroups.com
I can do it. 

On Oct 14, 2021, at 7:01 PM, Rob Pike <r...@golang.org> wrote:



Rob Pike

unread,
Oct 14, 2021, 8:15:50 PM10/14/21
to Robert Engels, golan...@googlegroups.com
Thanks. I think what I need is clear enough. Using the latest commit
at robpike.io/ivy, and the latest golang.org/x/mobile, please build a
Demo button next to the Help button on the iOS app, as there is on
Android.

Here is the script I use to build the iOS app (we used to call this a
"program"), thanks to some helpful folks at Apple. I think some of the
steps are needless, but they worked.

git clone https://github.com/robpike/ivy.git
git clone https://github.com/golang/mobile.git
brew install golang # I skipped this, and you can too, but you need
at least 1.17.
go install golang.org/x/mobile/cmd/gomobile@latest
go install golang.org/x/mobile/cmd/gobind@latest
export PATH=~/go/bin/:$PATH
mkdir work; cd work
go mod init work
go get -d golang.org/x/mobile/bind@latest
go get -d robpike.io/ivy/mobile
gomobile bind -target=ios,iossimulator,maccatalyst,macos robpike.io/ivy/mobile
cd ../mobile/example/ivy/ios
ditto ../../../../work/Mobile.xcframework/ Mobile.xcframework/
open ivy.xcodeproj

The new code should all be in the mobile repo. The hook to run the
demo is in robpike.io/mobile/mobile.go and is very easy to use.

-rob

Robert Engels

unread,
Oct 14, 2021, 11:03:08 PM10/14/21
to Rob Pike, golan...@googlegroups.com
Will do. I am booked through the weekend but will get on it next week. Glad to help.

> On Oct 14, 2021, at 7:15 PM, Rob Pike <r...@golang.org> wrote:
>
> Thanks. I think what I need is clear enough. Using the latest commit
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/CAOXNBZRk9nvFmSQiUcZ2PkV2qseu4t-LVHdmVDd1LKpA6PDxOg%40mail.gmail.com.

Rob Pike

unread,
Oct 15, 2021, 1:16:54 AM10/15/21
to Robert Engels, golan...@googlegroups.com
Thanks so much.

-rob

robert engels

unread,
Oct 16, 2021, 7:58:45 PM10/16/21
to Rob Pike, golan...@googlegroups.com
Rob,

You email makes reference to golang.org/x/mobile/example/ivy

That does not exist?


On Oct 12, 2021, at 7:15 PM, Rob Pike <r...@golang.org> wrote:


Ian Lance Taylor

unread,
Oct 16, 2021, 9:01:27 PM10/16/21
to robert engels, Rob Pike, golan...@googlegroups.com
On Sat, Oct 16, 2021 at 4:58 PM robert engels <ren...@ix.netcom.com> wrote:
>
> Rob,
>
> You email makes reference to golang.org/x/mobile/example/ivy
>
> That does not exist?

You can see it at
https://go.googlesource.com/mobile/+/refs/heads/master/example/ivy/

Ian



> On Oct 12, 2021, at 7:15 PM, Rob Pike <r...@golang.org> wrote:
>
> golang.org/x/mobile/example/ivy
>
>
> --
> You received this message because you are subscribed to the Google Groups "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/E71A8523-0E44-4D4B-96B9-5EF0FCD4038F%40ix.netcom.com.

robert engels

unread,
Oct 16, 2021, 9:10:04 PM10/16/21
to Rob Pike, golan...@googlegroups.com
Also, I don’t see how the demo will work. There is no stdin/stdout interface under iOS. I think you would need to create an html UI with an embedded http server to do this.

Have you ever had this working under iOS?

Ian Lance Taylor

unread,
Oct 16, 2021, 9:17:38 PM10/16/21
to robert engels, Rob Pike, golan...@googlegroups.com
On Sat, Oct 16, 2021 at 6:10 PM robert engels <ren...@ix.netcom.com> wrote:
>
> Also, I don’t see how the demo will work. There is no stdin/stdout interface under iOS. I think you would need to create an html UI with an embedded http server to do this.
>
> Have you ever had this working under iOS?

Yes. Ivy used to be in the Apple app store. Maybe it still is, I don't know.

Ian


> On Oct 16, 2021, at 6:58 PM, robert engels <ren...@ix.netcom.com> wrote:
>
> Rob,
>
> You email makes reference to golang.org/x/mobile/example/ivy
>
> That does not exist?
>
>
> On Oct 12, 2021, at 7:15 PM, Rob Pike <r...@golang.org> wrote:
>
> golang.org/x/mobile/example/ivy
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/E71A8523-0E44-4D4B-96B9-5EF0FCD4038F%40ix.netcom.com.
>
>
> --
> You received this message because you are subscribed to the Google Groups "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/11A49A72-921F-43C5-8562-511225BDA096%40ix.netcom.com.

robert engels

unread,
Oct 16, 2021, 9:27:27 PM10/16/21
to Ian Lance Taylor, Rob Pike, golan...@googlegroups.com
Yes, now that I can see the example code, I see how it is being done. I will need to review some more. At first glance I don’t see how the ‘demo’ will work though, becauseI don’t see the ‘example’ providing an io.Reader()/Writer() interface that can be passed to the demo.Run()

Rob Pike

unread,
Oct 16, 2021, 10:22:03 PM10/16/21
to robert engels, Ian Lance Taylor, golan...@googlegroups.com
The Android version I'm told (I haven't seen the code) read the file
and passed it line by line through the Next method of the mobile.Demo
type. Now with embedding the asset is already there. It should be
easy. The reason I haven't done that is that I don't know Objective-C
and especially don't know the libraries and execution environment.

But yes, on mobile there is no stdin/stdout, which shocked me when I
realized it, but then I've done zero programming for mobile.

-rob

robert engels

unread,
Oct 17, 2021, 12:46:01 AM10/17/21
to Rob Pike, Ian Lance Taylor, golan...@googlegroups.com
I was able to get the example to run. I have XCode 13 and some of the configuration is no longer valid.

I will work on the button next week.

Rob Pike

unread,
Oct 17, 2021, 12:59:08 AM10/17/21
to robert engels, Ian Lance Taylor, golan...@googlegroups.com
Great!

-rob

Robert Engels

unread,
Oct 20, 2021, 9:42:30 AM10/20/21
to Rob Pike, Ian Lance Taylor, golan...@googlegroups.com
Hi,

I’m pretty close to finished. Both the Android and iOS apps were horribly out of date so couldn’t be built with later toolchains.

It is also a lot more than simply ‘adding a button’ due to the way the ‘demo’ operates.

Should be ready in a day or two and I will send some PRs.

Robert

> On Oct 16, 2021, at 11:59 PM, Rob Pike <r...@golang.org> wrote:
>
> Great!
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/CAOXNBZTrnT60p9TqC5NnVHEojUuwqjjFDSccijwhWq17VhsOHw%40mail.gmail.com.

Ian Lance Taylor

unread,
Oct 20, 2021, 1:16:39 PM10/20/21
to Robert Engels, Rob Pike, golang-dev, Hyang-Ah Hana Kim
On Wed, Oct 20, 2021 at 6:42 AM Robert Engels <ren...@ix.netcom.com> wrote:
>
> I’m pretty close to finished. Both the Android and iOS apps were horribly out of date so couldn’t be built with later toolchains.
>
> It is also a lot more than simply ‘adding a button’ due to the way the ‘demo’ operates.
>
> Should be ready in a day or two and I will send some PRs.

Note that Hana (CC'ed) recently sent some changes for Ivy on Android
(https://golang.org/cl/356729 and friends).

Ian

robert engels

unread,
Oct 20, 2021, 1:30:11 PM10/20/21
to Ian Lance Taylor, Rob Pike, golan...@googlegroups.com, Hyang-Ah Hana Kim
Ugh. I basically duplicated all of that work...
> --
> You received this message because you are subscribed to the Google Groups "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/CAOyqgcVxPH_WdUxt7CSzLEe_LxuA2xdmETu7o32S4jLst5Omvw%40mail.gmail.com.

robert engels

unread,
Oct 21, 2021, 9:11:34 PM10/21/21
to Ian Lance Taylor, Rob Pike, golan...@googlegroups.com, Hyang-Ah Hana Kim

robert engels

unread,
Oct 21, 2021, 9:35:29 PM10/21/21
to Ian Lance Taylor, Rob Pike, golan...@googlegroups.com, Hyang-Ah Hana Kim
Sorry, missed a change, new PR is https://go-review.googlesource.com/c/mobile/+/357874

robert engels

unread,
Oct 21, 2021, 9:41:30 PM10/21/21
to Ian Lance Taylor, Rob Pike, golan...@googlegroups.com, Hyang-Ah Hana Kim
Sorry, wrong link, https://go-review.googlesource.com/c/mobile/+/357875

Been a while since I’ve used git… :)

Rob Pike

unread,
Oct 22, 2021, 6:48:12 PM10/22/21
to robert engels, Ian Lance Taylor, golan...@googlegroups.com, Hyang-Ah Hana Kim
Thanks so much for doing this. Is there another commit waiting to be
pushed? The file demo.ivy is still in the change.

-rob

robert engels

unread,
Oct 23, 2021, 12:08:43 AM10/23/21
to Rob Pike, Ian Lance Taylor, golan...@googlegroups.com, Hyang-Ah Hana Kim

robert engels

unread,
Oct 23, 2021, 12:11:03 AM10/23/21
to Rob Pike, Ian Lance Taylor, golan...@googlegroups.com, Hyang-Ah Hana Kim
I am not sure why there is a merge conflict - all of the changes are mine. I assume it is because the earlier commit has not been accepted.

Rob Pike

unread,
Oct 23, 2021, 1:08:21 AM10/23/21
to robert engels, Ian Lance Taylor, golan...@googlegroups.com, Hyang-Ah Hana Kim
I'll let Hana Kim review the first one, but overall it looks good to me.

I've +2ed the second one.

Thanks again. Can't wait to get this out.

-rob
Reply all
Reply to author
Forward
0 new messages