MyGoRe vs. Go All The Way: New Developments in Mobile Development

April 2021, Tax Season

Go Vs. Flutter Vs. React Native: The Current State Of App Development

So I've been doing a lot of React Native lately. Yes, I've been a bit of a Flutter fanboy for some time, but you go with the tool that's best for the job, not your favorite. 

For example, a friend suggested I make an app with a camera with selfie information. Long story short, it turns out the Flutter camera package is out of date and slow to pick up in Flutter 2. The React Native RNCamera function? Works great. 

Go figure. Meanwhile, doing a project using the Flutter Calendar library works great.


Meanwhile still, playing around with Go by Google, I came across a spectacular library called Fyne. Basically, it's taken all the hard work out of making desktop apps, and promises to take on mobile apps as well. But I'll get into that in a second. 

Right now, I'm going to go through the gotchas and the specific procedure for setting this stuff up. Hopefully, I will save you the time I wasted beating my head against the wall. You know, like I did with some out of date packages.

First, it is super important that you're in your go/bin folder when you run the go get command in Terminal. Installing any package will be the hugest pain in the butt if you don't. And you're going to have enough pain in a second.
But once you get Fyne installed in the bin, you can now make a folder where you always do your coding, and make a main.go file.
The starter recipe is right here, OK? I'm not going to do that thing where I paste the readMe from their website all over mine just to get hits. I have ethics, people.
So make that one file, paste in your starter recipe, and run
go run main.go

in your terminal from that folder to look at your handiwork. To make an executable when you're satisfied with that, run
sudo go build -o execName main.go

Yes, that's really all.
There's a whole lot more to Fyne than is just there. To demonstrate forms, I made a fake order tracking system that looks like this:


If there are any ex-co-workers of mine out there...yeah. Good times, huh?!
You can also see how the file structure looks with the Fyne executable in go/bin, and then your desktop app folder. One file makes everything happen. One.
Making apps should have always been that simple...but now it is.
And the code, ah...To make a form, do this:   

searchCriteria := widget.NewForm() 
firstNameSearch := widget.NewEntry() //and last name, order, etc. 
searchCriteria.Append("First Name", firstNameSearch) // and so forth

 
And searchCriteria, or whatever your form is going to be called, goes in the VBox which flex-distributes vertically, duh.

Wow, could it be easier?! Anyone who's diddled even a bit with Javascript or Python (e.g. everybody) can understand that, right? I thought GTK+ was amazing, because it is....but I just love this.

And now...mobile. Here's where things get hard, because of course here.

Remember how Go Mobile was going to be the thing? Well, that's where Fyne comes in. Fyne is a user-friendly, fast 'n easy approach to making mobile apps with just Go. Wouldn't that be something? So it serves as a wrapper to the Go Mobile library, which makes the most basic apps. Fyne takes it one step further.

That's how it works in a good and just world. So how do we turn this humble desktop app into a mobile app?

First, run the following command in go/bin to make the fyne command work:   

sudo /your/path/to/go/bin/fyne install

Yes, it should just be the fyne install command, but on OSX Mojave I have trouble getting it to run without copying the full path. My go env details seem fine...?

Now for some real fun. You'll probably get an error because NDK isn't installed there. I used Android Studio to install it and to make sure both NDK and CMake are operational. DO NOT FORGET to install the SDK Command Line tool with the SDK Manager! I only use Android Studio for Flutter, but I use Atom for React Native and Go. I like my things where I like them, you know? Besides, Android Studio barely does Kotlin - it doesn't know what Go is, and getting it set up is going to be a big project, so lets' move on for now...
...because it's time to use the ever-popular sudo nano /etc/paths thing to add the NDK Home address to my $PATH. I just mention that because NOTHING WORKS IF YOU DON'T DO IT AND YET NOBODY MENTIONS IT IN DOCS AND IT'S IMPOSSIBLE TO FIND THAT DETAIL ONLINE
!!!
*pant pant*
*calming breaths*
*chews some CBD*
*is still mad*

Anyway, you get your NDK Path with echo $ANDROID_NDK_HOME. How do you edit it? Uhh...in the $PATH? (I'm not yelling, it's case sensitive. They're yelling!)

NARRATOR
It wasn't the $PATH...

ME
So add that and $PATH is now updated, I think. BTW it's echo $PATH | tr ':' '\n' to make it look nice and orderly. Of course, there's a Stack Overflow for that.

...so finally we can run this one liner to make our app into a mobile app: 

sudo /your/path/to/go/bin/fyne package -os android -appID my.app.name

JUST KIDDING - Android Studio didn't install it where we need it for this exercise, so you'll STILL get a warning that NDK is not found. So we have to go here and install the command line tools. Don't forget to quit Terminal and restart it after these installations so it knows you made changes, because that's not inconvenient at all.

Now you cd to your project folder and run

sdkmanager --install "ndk;21.3.6528147" --channel=3

...and you get an error saying sdkmanager is mangled. 

...

I am therefore leaving immediately for Nepal where i ...

NARRATOR
Maybe you should learn bartending?

ME
Not helpful, Morgan.

NARRATOR
Would it be helpful to point out that there are several of...that thing you're having trouble with in that mess you call a folder system? And that they have different dates?

ME
....
In fact, yes, a working copy of sdkmanager had downloaded, but I had to manually drag that sht to the correct folders for it to work. (Pro tip: there's no shame in using the Finder GUI. No one will think less of you as a person if you do that.) Thanks, narrator!

And sdkmanager install, and update, and what the hell just rm -r gomobile and do the exact procedure to init and bind again with the ndk path specified...

...and gomobile will never acknowledge the existence of any so-called NDK installation on my Mac. Ever. Period. FU.

Ralph Rolling Down AHill GIF - Ralph RollingDownAHill ...

Fun fact: Fyne DID build for iOS, except that I don't have a Apple Developer account yet. So it's there, and - fingers crossed - the simulator can run it.

So it works...but Android NDK doesn't. And that is the ONE problem holding me back. And nobody in Stack Overflow or even the Github bug tracking chats has the slightest idea how to fix it.

Sigh. Meanwhile, in my React Native project folder, I run sudo expo init and it builds everything. It instructs me if I need to run npm audit or something. Or if there's a dependency you don't have yet, sudo expo install a-dependency. And then npm run android | web | ios and it's on my phone doing stuff so we can get on with life.

As simple as making an exec in Go.

It's understandable that it's still pretty difficult to get a new technology working on your computer at this point in time. The public internet is just 38 years old. Yes, Compuserve text chats count.

Think of where, say movies were after 38 years in existence. Cool, we're figuring out how to make them in color with sync sound! And special effects with mirrors and painted glass! Where could we possibly go from here?!

Or television - hey, we just made something called cable TV, so you don't have to stand up and turn a knob to turn off whatever utter garbage one of the three TV stations (plus PBS, which only children and NERDS watched then) is pumping into your home via an aluminum antenna nailed to your roof - and another one on top of your TV that you have to wiggle just so so the picture doesn't look like crap. Cable TV eliminates those problems, avoids dumb censor rules, and gives you dozens of channels to choose from! Where could we possibly go from here?!

So in the new mobile/"social" internet, the field of options to make stuff is crowded now. You've got the Javascript 3 - Angular, React, and Vue (which isn't even Javascript, really) - plus Flutter, and now Go. Plus Python for the data nerds, and their kids who want to learn to code. We have a wealth of choices in making all things code related or even peripheral very easy for anyone to do.

Where could we possibly go from here?!

...once we figure out why that tool doesn't work.


PS: Potential happy ending: fyne-cross library (install like above) and install Docker. Hope your desktop has enough hard drive. Thank goodness mine still does.
Sanity restored...for now...

PPS: Title refers to this blog post.

Comments

  1. I found this in depth exploration of Fyne. Dig it: https://www.fatalerrors.org/a/go-daily-library-of-fyne.html

    ReplyDelete
  2. I write more about code on Quora. Enjoy before it becomes fancy reddit and we all have to evacuate:
    https://www.quora.com/profile/Mario-Caiti/answers/Computer-Programming

    ReplyDelete
  3. This blog post is 1553 words. Measure your content productivity in wordcount with this free app: https://thewordcounter.com/

    ReplyDelete

Post a Comment