go iOS.App()

5,047 views
Skip to first unread message

minux

unread,
Nov 27, 2014, 2:05:23 AM11/27/14
to golang-nuts
Hi gophers,

I'm happy to announce that the iOS port of Go recently gained full
cgo and external linking support.

I've also got a simple C based application working on a real iPad.

The port lives in ios3 branch of https://bitbucket.org/minux/goios.
Read misc/ios/README for some rudimentary documentation.

The port is Go 1.4+, and it's based on upstream dev.cc branch.
I intend to propose for inclusion into Go 1.5 after finding a way
to test it (either build each test as an App, or use the open source
xnu/arm port). Brad mentioned that inclusion of iOS support might
happen in Go 1.5 in his talk the state of the gopher
I believe it really will happen.

The iOS port is my first Go OS port, but it's the only one that takes
almost 3 years to complete. :)

Go build iOS Apps. Let's see when can we see a Go based App in
the store.

Minux

Dave Cheney

unread,
Nov 27, 2014, 2:13:50 AM11/27/14
to golan...@googlegroups.com
Fantastic work (and determination)!

Dmitry Vyukov

unread,
Nov 27, 2014, 2:15:45 AM11/27/14
to minux, golang-nuts
rock'n'roll!
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Tahir

unread,
Nov 27, 2014, 3:55:26 AM11/27/14
to golan...@googlegroups.com
Yay !!!

ben.d...@stickyeyes.com

unread,
Nov 27, 2014, 4:48:30 AM11/27/14
to golan...@googlegroups.com
Holy cr*p thats awesome


On Thursday, November 27, 2014 7:05:23 AM UTC, minux wrote:

Elias Naur

unread,
Nov 27, 2014, 7:15:52 AM11/27/14
to golan...@googlegroups.com
Yeah!

jbergm...@gmail.com

unread,
Nov 27, 2014, 11:13:21 AM11/27/14
to golan...@googlegroups.com
Do you have any example apps in your repository?

Brad Fitzpatrick

unread,
Nov 27, 2014, 1:52:08 PM11/27/14
to minux, golang-nuts
I should re-announce more of your work if it motivates you so much.  :-)

As for builders, I'd prefer to use real iOS devices. We don't run the Windows buildbots on ReactOS, for instance.

The builder can be totally custom, like the Android one effectively is. It can build each package's test binary by itself, link in a GUI to respond to the UIKit event loop (so it doesn't get killed), and run the OS X CLI deploy tool to push e.g. the fmt.test binary packaged as an app to the iPad (and have it start running immediately and then report its result in logs we can watch from OS X, or to a server).

I'm happy to help as much as I can when it's time for builders.


--

minux

unread,
Nov 27, 2014, 4:46:12 PM11/27/14
to jbergm...@gmail.com, golang-nuts
On Thu, Nov 27, 2014 at 11:13 AM, <jbergm...@gmail.com> wrote:
Do you have any example apps in your repository?
No. But basically you can test by renaming the main function of the original
app to iosmain, rearranging the files into a single directory, and adding a new
main.go:

package main

/*
// adjust LDFLAGS if necessary
#cgo LDFLAGS: -framework UIKit -framework Foundation -framework CoreGraphics
extern void iosmain(int argc, char *argv[]);
*/
import "C"

func main() {
       C.iosmain(0, nil)
}

And go build should build a working app, just like the original.

I haven't tried http://godoc.org/github.com/mkrautz/objc, but I think that's a good
start.

Stephen Gutekanst

unread,
Nov 27, 2014, 5:30:18 PM11/27/14
to golan...@googlegroups.com
Wow! This is both extremely impressive and unexpected!

It will be great to see what mobile applications pop up with both Android and iOS support.

Thank you so much for your constant work on this!

Sebastien Douche

unread,
Nov 27, 2014, 6:43:23 PM11/27/14
to minux, golang-nuts
On Thu, Nov 27, 2014 at 8:04 AM, minux <mi...@golang.org> wrote:
> I'm happy to announce that the iOS port of Go recently gained full
> cgo and external linking support.

Wow!

> The iOS port is my first Go OS port, but it's the only one that takes
> almost 3 years to complete. :)

Next port: 1.5 year ;).



--
Sebastien Douche <sdo...@gmail.com>
Twitter: @sdouche / G+: +sdouche

minux

unread,
Nov 27, 2014, 6:53:32 PM11/27/14
to Sebastien Douche, golang-nuts
On Thu, Nov 27, 2014 at 6:42 PM, Sebastien Douche <sdo...@gmail.com> wrote:
> The iOS port is my first Go OS port, but it's the only one that takes
> almost 3 years to complete. :)
Next port: 1.5 year ;).
1.5 years is still too long. I think a new OS port is worth at most 2 weeks of
dedicated work. A new architecture port will take significantly longer, 6 man
months. :)

Rob Pike

unread,
Nov 27, 2014, 7:02:37 PM11/27/14
to minux, Sebastien Douche, golang-nuts
Ken and I ported Plan 9 to the SPARC in 6 days over one fun Christmas break.

I wrote the disassembler (for the debugger) and Ken wrote the assembler, so we could cross-check each other's work. The hardest problem other than fighting register windows occurred when we both misread the definition of an instruction the same incorrect way.

-rob

Govert Versluis

unread,
Nov 28, 2014, 5:26:33 AM11/28/14
to golan...@googlegroups.com, mi...@golang.org, sdo...@gmail.com
Wow, great work here! I didn't think this port was already anywhere near this level of ready.
For some reason that reminds me of the anecdote in the third paragraph of the introduction of this page: http://cm.bell-labs.com/who/ken/trust.html
"That brings me to Dennis Ritchie. Our collaboration has been a thing of beauty. In the ten years that we have worked together, I can recall only one case of miscoordination of work. On that occasion, I discovered that we both had written the same 20-line assembly language program. I compared the sources and was astounded to find that they matched character-for-character. The result of our work together has been far greater than the work that we each contributed."
 

Charlie Drage

unread,
Nov 28, 2014, 5:30:32 AM11/28/14
to minux, golang-nuts
This is incredible!

On an un-related note, Android Go will be introduced in 1.5 correct?

--------------------------------------------
Charlie Drage
GPG [FE8E 8D18] [charliedrage.com/public.key]
--------------------------------------------

On Thu, Nov 27, 2014 at 8:04 AM, minux <mi...@golang.org> wrote:

--

Manlio Perillo

unread,
Nov 28, 2014, 11:43:18 AM11/28/14
to golan...@googlegroups.com

Il giorno giovedì 27 novembre 2014 08:05:23 UTC+1, minux ha scritto:
Hi gophers,

I'm happy to announce that the iOS port of Go recently gained full
cgo and external linking support.


Hi.

This is unrelated, but will a Go application be a first class citized on iOS?
It isn't on Android, as far as I know.

> [...]


Thanks   Manlio Perillo 

minux

unread,
Nov 28, 2014, 7:00:50 PM11/28/14
to Brad Fitzpatrick, golang-nuts
On Thu, Nov 27, 2014 at 1:51 PM, Brad Fitzpatrick <brad...@golang.org> wrote:
I should re-announce more of your work if it motivates you so much.  :-)
Thanks!

As for builders, I'd prefer to use real iOS devices. We don't run the Windows buildbots on ReactOS, for instance.
Yeah, it seems I've found a perfect solution for that: https://github.com/phonegap/ios-deploy
I'd still want to set up a xnu-on-arm builder for testing native development though.

We can document that the port target two environments: cross compile for real iOS and native
on the xnu/arm port. The fact that it works on jailbroken iDevices is purely a coincidence. ;)

Note: the xnu/arm port is different from ReactOS as it's based on the real xnu kernel, not a
clean-room reimplementation. The added code is just the arm architecture specifics that
Apple doesn't open source.

The builder can be totally custom, like the Android one effectively is. It can build each package's test binary by itself, link in a GUI to respond to the UIKit event loop (so it doesn't get killed), and run the OS X CLI deploy tool to push e.g. the fmt.test binary packaged as an app to the iPad (and have it start running immediately and then report its result in logs we can watch from OS X, or to a server).

I'm happy to help as much as I can when it's time for builders.
Thank for the offer! I really appreciate any help for getting this port upstreamed.

minux

unread,
Nov 28, 2014, 7:01:46 PM11/28/14
to Rob Pike, Sebastien Douche, golang-nuts
On Thu, Nov 27, 2014 at 7:01 PM, Rob Pike <r...@golang.org> wrote:
Ken and I ported Plan 9 to the SPARC in 6 days over one fun Christmas break.
Cool! Still a long way to go for me. ;-)

I wrote the disassembler (for the debugger) and Ken wrote the assembler, so we could cross-check each other's work. The hardest problem other than fighting register windows occurred when we both misread the definition of an instruction the same incorrect way.
Interesting. I'm curious about which instruction you both misread?

minux

unread,
Nov 28, 2014, 7:04:52 PM11/28/14
to Charlie Drage, golang-nuts
On Fri, Nov 28, 2014 at 5:29 AM, Charlie Drage <cha...@charliedrage.com> wrote:
On an un-related note, Android Go will be introduced in 1.5 correct?
It's possible to build Android apps using Go with 1.4 and the go.mobile sub-repository
now if you're brave enough (build tools are lacking, but essential parts are all there)

If it's a OpenGL based game, it's possible to write everything in Go; if it's a regular app,
the GUI part will still need to be written in Java.

minux

unread,
Nov 28, 2014, 7:09:04 PM11/28/14
to Manlio Perillo, golang-nuts
On Fri, Nov 28, 2014 at 11:43 AM, Manlio Perillo <manlio....@gmail.com> wrote:
This is unrelated, but will a Go application be a first class citized on iOS?
Go isn't supported by Apple officially, but nor do any other languages, other than Objective C,
Swift or Javascript, that could be used to develop iOS apps.
It isn't on Android, as far as I know.
Go support for Android is official. Whether it can be called first class citizen depends on your
view.

Jason Toffaletti

unread,
Nov 28, 2014, 8:28:10 PM11/28/14
to golan...@googlegroups.com
I'd be happy to provide iOS devices as builders if and when they're needed.

matt

unread,
Nov 29, 2014, 7:00:11 PM11/29/14
to golan...@googlegroups.com
All this android and ios love surely means that the go ARM compiler could do with some love?

bronze man

unread,
Jan 23, 2015, 2:35:36 AM1/23/15
to golan...@googlegroups.com, jbergm...@gmail.com
I have tried this way,but it is not work.
I got a  Mach-O executable arm file,but I do not know how to send that file to a read itouch and run it.
Could you please tell me how to run it on real device without jailbreak?
I can write a object-c app and run it on real device .

I have tried built a ios app and replace the execute file in that app , and run again: Then I got "App installation failed,No code signature found".

minux

unread,
Jan 23, 2015, 3:18:46 AM1/23/15
to bronze man, jbergm...@gmail.com, golang-nuts


On Jan 23, 2015 2:35 AM, "bronze man" <bronz...@gmail.com> wrote:
> I have tried this way,but it is not work.
> I got a  Mach-O executable arm file,but I do not know how to send that file to a read itouch and run it.
> Could you please tell me how to run it on real device without jailbreak?
> I can write a object-c app and run it on real device .
>
> I have tried built a ios app and replace the execute file in that app , and run again: Then I got "App installation failed,No code signature found".

You need to codesign the binary produced by the Go toolchain.

Please see updates README here:
https://go-review.googlesource.com/#/c/2127/7/misc/ios/README

It also includes notes on how to run arbitrary Go program on non-jailbroken iDevices.

bronze man

unread,
Jan 23, 2015, 11:14:59 AM1/23/15
to golan...@googlegroups.com, bronz...@gmail.com, jbergm...@gmail.com
Thanks for your document.
I read and did as it said,and I got following:
(lldb)     script fruitstrap_connect_url="connect://127.0.0.1:12345"
(lldb)     command script import "/tmp/fruitstrap_e35943dde9f557e4b37482e2789f96127e6d2392.py"
(lldb)     command script add -f fruitstrap_e35943dde9f557e4b37482e2789f96127e6d2392.connect_command connect
(lldb)     command script add -s asynchronous -f fruitstrap_e35943dde9f557e4b37482e2789f96127e6d2392.run_command run
(lldb)     command script add -s asynchronous -f fruitstrap_e35943dde9f557e4b37482e2789f96127e6d2392.autoexit_command autoexit
(lldb)     command script add -s asynchronous -f fruitstrap_e35943dde9f557e4b37482e2789f96127e6d2392.safequit_command safequit
(lldb)     connect
Process 0 connected
(lldb)     run
Process 1004 stopped
success

runtime: panic before malloc heap initialized

runtime stack:
runtime.throw(0x40ef770, 0x33)
/Users/xxx/dev/golang/goios/src/runtime/panic.go:508 +0x8c fp=0x4263af4 sp=0x4263ae8
runtime.mallocinit()
/Users/xxx/dev/golang/goios/src/runtime/malloc1.go:199 +0x1ec fp=0x4263b7c sp=0x4263af4
runtime.schedinit()
/Users/xxx/dev/golang/goios/src/runtime/proc1.go:119 +0x40 fp=0x4263ba0 sp=0x4263b7c
runtime.rt0_go(0x4263bec, 0x1, 0x4263cc0, 0x0, 0x4263d1f, 0x4263d42, 0x4263d59, 0x4263d7c, 0x4263d8f, 0x4263d9e, ...)
/Users/xxx/dev/golang/goios/src/runtime/asm_arm.s:70 +0xa8 fp=0x4263be0 sp=0x4263ba0
Process 1004 exited with status = 2 (0x00000002) 

minux

unread,
Jan 23, 2015, 11:21:48 AM1/23/15
to bronze man, jbergm...@gmail.com, golang-nuts

How much memory is available for you device?

--

bronze man

unread,
Jan 23, 2015, 11:30:02 AM1/23/15
to golan...@googlegroups.com, bronz...@gmail.com, jbergm...@gmail.com
It panic on itouch 5 with runtime: panic before malloc heap initialized, or cannot reserve arena virtual address space stuff.
It works on iphone 5c.
Thanks for your great job!

bronze man

unread,
Jan 23, 2015, 11:55:43 AM1/23/15
to golan...@googlegroups.com, bronz...@gmail.com, jbergm...@gmail.com

I have built a go ios hello world project to help others.

https://github.com/bronze1man/goIosHelloWorld

minux

unread,
Jan 24, 2015, 10:28:46 PM1/24/15
to golang-nuts
Keith has written some pretty good blog posts detailing his journey
building iOS app with Go (and Xcode), and they includes answers
to some common questions using the iOS port (for example, how
to generate static library for the Go part of your app and include it
into Xcode project?)


Thanks, Keith!

bronze man

unread,
Jan 26, 2015, 9:33:37 AM1/26/15
to golan...@googlegroups.com
Is there any progress to ios/arm64 ?
I need to upload my app to appstore after feb,2015.

But apple says they need to build as arm64 .
So I give up golang,turn back to objective-c to finish my app.

David Crawshaw

unread,
Jan 26, 2015, 9:48:57 AM1/26/15
to bronze man, golang-nuts
There is work being done on a linux/arm64 port, which covers the bulk
of the changes. After both linux/arm64 and darwin/arm are merged, I
intend to take a look at darwin/arm64.

I don't know if it will make it in to Go 1.5. If both linux/arm64 and
darwin/arm are merged before the freeze, it will be my top priority.

Aram Hăvărneanu

unread,
Jan 26, 2015, 10:45:53 AM1/26/15
to David Crawshaw, bronze man, golang-nuts
The linux/arm64 port is progressing well. You can help or monitor
progress here: https://github.com/4ad/go

--
Aram Hăvărneanu

bronze man

unread,
Jan 26, 2015, 11:31:09 AM1/26/15
to golan...@googlegroups.com, craw...@golang.org, bronz...@gmail.com
Thanks.
Sorry,I can not help you since I do not have any linux/arm64 devices.

MichaelXu

unread,
Jan 26, 2015, 8:10:15 PM1/26/15
to golan...@googlegroups.com
Cool!

在 2014年11月27日星期四 UTC+8下午3:05:23,minux写道:
Hi gophers,

I'm happy to announce that the iOS port of Go recently gained full
cgo and external linking support.

minux

unread,
Jan 26, 2015, 8:16:28 PM1/26/15
to golang-nuts
Update: I've updated the ios3 branch of https://bitbucket.org/minux/goios
(and mirror at https://github.com/minux/goios) to latest Go tip, which means
it's not possible to build Go without a previous installed Go 1.4.

If you only build the Go port on OS X, you can stop reading now.

If you build the port natively, I've made available a tag just before the Go 1.4
requirement become mandatory.
If you build natively, you need to build that tag first (in a separate location),
and set $GOROOT_BOOTSTRAP to point to that location and continue building
the latest ios3 branch. (see golang.org/s/go15bootstrap for detailed Go 1.5
bootstrap mechanism.)

dum...@gmail.com

unread,
Jan 27, 2015, 7:13:23 PM1/27/15
to golan...@googlegroups.com
cooooool

在 2015年1月27日星期二 UTC+8上午9:16:28,minux写道:

Mike Hughes

unread,
Jan 28, 2015, 6:46:52 AM1/28/15
to golan...@googlegroups.com
Brilliant work!

I don't own any iOS devices, but this can only help expand the community, and for that I thank you!

Here's to Go On All The Things!

minux

unread,
Feb 6, 2015, 1:00:03 AM2/6/15
to golang-nuts
Update: All essential CLs have just been submitted, so Go 1.5 will
definitely come with Darwin/ARM (32-bit iOS) support.

The next step will be Darwin/ARM64.

Dave Cheney

unread,
Feb 6, 2015, 2:12:08 AM2/6/15
to golan...@googlegroups.com
This is excellent news! Thanks Minux!

Mikkel Krautz

unread,
Feb 6, 2015, 3:45:27 AM2/6/15
to minux, golang-nuts
Great news!

Thank you very much for the work you've put into this, and
congratulations with finally getting it into the tree! :-)

Lunny Xiao

unread,
Feb 7, 2015, 9:52:13 AM2/7/15
to golan...@googlegroups.com
Great!

在 2015年2月6日星期五 UTC+8下午2:00:03,minux写道:

minux

unread,
Mar 5, 2015, 1:52:12 AM3/5/15
to golang-nuts
I've just completed an experimental Darwin/ARM64 port. This time it's much
faster, six days in total, including 2 days adding PIC support to linux/arm64
and 3 days fighting with ld64 bugs. ;)

It's in the ios64 branch of goios project.
The only problem is that the arm64 toolchain doesn't maintain frame pointer
yet, so the binary generated might not be fully compliant to Apple's ARM64
ABI.

The port won't be possible without the effort of many people for the ongoing
linux/arm64 port. Thanks to them all, especially Aram, Dave and Michael.

I'd also like to thank David Crawshaw for lending a 64-bit iPad to me and
Dave for getting me access to a linux/arm64 machine.

Aram Hăvărneanu

unread,
Mar 5, 2015, 4:18:41 AM3/5/15
to minux, golang-nuts
Excellent news!

--
Aram Hăvărneanu
Reply all
Reply to author
Forward
0 new messages