All Episodes

April 27, 2025 41 mins

Geoff spent some time trying Swift Wasm (Web Assembly) and wanted to discuss his findings and thoughts. We love to highlight projects using the Swift language and welcome anyone working on a project to reach out to us at compileswift.com/contact.

Mentioned in this episode
Swift Wasm on GitHub
Swiftwasm.org
Hummingbird Episode

Become a Patreon member and help this Podcast survive
https://www.patreon.com/compileswift

Follow on Mastodon
https://iosdev.space/@Compileswift

Thanks to our monthly supporters
  • flanker
  • Jay Wilson
  • Adam Wulf
  • bitSpectre
★ Support this podcast on Patreon ★
Mark as Played
Transcript

Episode Transcript

Available transcripts are automatically generated. Complete accuracy is not guaranteed.
Geoff (00:01):
Hold on. I'm still, like, too tickled to actually make
enough words out of my mouth.

Peter (00:09):
What's up, everybody? Welcome to the compiles riff
podcast. Yes. We we nailed it.We got it.
We've been practicing. It'staken a little while. This
episode, we are gonna be talkingabout SwiftWASM or depending on
how you wanna pronounce it. Butfirst of all, Geoff, how are
doing, buddy? What's what's beengoing on in your world?

Geoff (00:29):
Hey, Peter. I've been doing just great. I've been
playing with some new stuff, andI think that's what we're gonna
talk about tonight.

Peter (00:34):
We are. You have been playing with some something that
I've not messed around with atall. So I'm gonna have
questions. Unsurprisingly, youare gonna be the subject matter
expert on this. You are anexpert by now.
You had a couple of hours.Right?

Geoff (00:49):
Definitely, yeah. About three hours that I put in.

Peter (00:53):
Yeah. Like like like all good frameworks, you become an
expert once you've installed it.You've installed the packages.
You've done a hello world.You're an expert now.
Yeah. Right? That that's how

Geoff (01:03):
it works. Yeah.

Peter (01:04):
That's what I found.

Geoff (01:05):
Ask me anything. I gotcha.

Peter (01:06):
There you go. Alright. So tell us, what have you been
messing around with today?

Geoff (01:12):
So, yeah, this is actually something that I've
played around with in the past.Several years ago, I did a joke
stream. I I do two joke streamsa year. Do my annual April Fools
Day stream and my annualHalloween stream where I I do
something a little bitridiculous. And several years

(01:33):
ago, was like, oh, I'm gonnashow everybody how to build a
app for Windows in Swift.
And I I this was several yearsago at this point for one of the
Halloween streams. And the waythat I did it was I was like,
oh, I'm gonna use Swift WASM forpeople who are not familiar with
this. This is a way of compilingSwift to run-in the browser.

(01:58):
Okay. On the front end.

Peter (01:59):
Not to be confused. But Yeah. I was gonna say not to be
confused. We're we're not sayingserver side. Right?
Let me

Geoff (02:05):
be Not server side. No. This is client side Swift on the
in the browser. Anyway, so theshenanigans around the the Swift
for Windows app were that I wasbuilding a Swift WebAssembly
app, then running it inside ofElectron and running that on
Windows. And that was that wasthe It's horrible, you know, mad

(02:29):
science way of building aWindows app in Swift and
something akin to Swift UI atthe time.

Peter (02:37):
I I mean, if that doesn't scream performance, I don't know
what does for

Geoff (02:41):
it. Fantastic. Anyway, so that was that was what I had
played with several years ago.And I, you know, it seemed like
Swift Web Assembly was aninteresting project, but not
really ready production yet. Andthere wasn't too much effort
behind it, and and it seemedlike it was just like, okay.
This is kinda it's fun to see,but it's not really serious yet.

Peter (03:04):
And to be clear, this is an open source project. Right?
Yeah. Yeah. Yeah.

Geoff (03:07):
This was an open source project that some people were
kinda just patching together toto get it to work. Anyway, fast
forward to last Friday, and inand and, you know, this is gonna
sound silly when I was like, oh,this is what finally made it
sound serious. In the wonderfuliOS dev weekly newsletter, there
was a link to a game calledFlappy Swift, which was Flappy

(03:33):
Bird written in Swift running inthe browser.

Peter (03:35):
Oh, shocking. Using If that's not marketing, I don't
know who it is.

Geoff (03:39):
Of course not. Yeah. Using SwiftWasm. And so I took a
look at that, and it seems likethey've improved a lot of the
problems that existed withSwiftWasm in the past, and we'll
get into what those problems areand how they fix them. But it
also turns out that there's beena lot of work in making this an

(03:59):
official project for the Swiftteam.
And so a lot of this has nowbeen actually upstreamed into
the main Swift compiler andbeing able to do a lot of this
work from a standard version ofSwift. Whereas before, it was
very much you had to kind of goinstall your own custom tool
chain, this is now inside thestandard Swift tool chain. And

(04:23):
so I went, okay. This is itseems like a lot has changed
since the last time I looked atthis. Let's go take a look at it
again and see how it is thesedays.
And that's what we're gonna talkabout.

Peter (04:35):
Alright. So we know a while ago, Apple was posting
positions for folks who werebasically interested in working
with them, for them, Swift onWindows. And and and, I guess,
making that sort of an officialpart of the platform, which is
nothing but good news in in myopinion. I you know, I'd love
Swift everywhere. I'm sure mostof us would.

(04:57):
But this is not part of thatproject. Right? This was this is
a separate thing still, but itjust happens to now be part of
the official tool chain. Did Idid I understand that correctly?

Geoff (05:08):
Yeah. This is not quite as fully supported yet as, say,
Windows is as an officialplatform for Swift that it it's
not yet an official supportedbuild target. But it is
something that they are workingon getting it to that point
where they are all of the stuffto support WebAssembly is

(05:33):
upstream. It's all part of themain Swift tool chain, and they
are working towards everythingthat they need to make it a
fully supported platform. It'sjust not there yet.

Peter (05:43):
Got it. Still nothing but good news, though. Yeah. Any
direct any movement in any ofthese directions, I think, is a
good thing personally. You know,people anytime you I feel like
we can project Swift as theSwift language and somewhat

Geoff (06:01):
I don't want

Peter (06:01):
to say disassociate, but make it clear that, hey, Swift,
it doesn't just mean Appledevices. Right? Because that's a
problem. Correct. Yeah.

Geoff (06:09):
Yeah. And definitely, think this is another approach
to it. I mean, we've talkedabout Swift on the server in the
past. And so with this, you cankind of have an entire front end
and back end, both sides of thecoin app built entirely in
Swift. And you can have built itentirely on Linux, never

(06:30):
touching a Mac.
You can run it always only everon Linux, never touching a Mac.
And, you know, everybody in theworld can use this app and can
have distributed to them as longas it's just running in a
browser. So there's no reasonfor this to touch Apple at all
anymore if you really don't wantto.

Peter (06:49):
So a a a little side note there. All those people out
there that are like, you know,and every other day it's us too,
x code. Yeah. You don't need itfor this. Yep.

Geoff (07:01):
You you not only do you not need it, you actually cannot
use it for this yet. If you Oh,interesting. Get into the Swift
developer or sorry. If you getinto the Swift WASM
documentation, one of the veryfirst things that they do, and
this is this is kind of where Iwas like, this is not not a %
official yet. Okay.

(07:21):
You install the official Swiftcompiler tool chain, And that's
the same Swift compiler toolchain that you would use on
Linux. That's the same Swiftcompiler tool chain you would
use anywhere else. It is comingfrom swift.org. It's it's the
standard Swift tool chain.However, none of this works with
the tool chain that isdistributed with Xcode yet.

(07:42):
And thankfully, Apple's madethis relatively easy in recent
days. They introduced a new toolcalled Swiftly, which works, you
know, kinda like RVM or PYM orany of those types of tools. It
allows you to install and managedifferent installations of Swift
itself. And so you use that inorder to install the tool chain

(08:04):
that you need.

Peter (08:05):
I actually like this idea that it is separate from
anything, for example, thatXcode may use, and I can manage
it that way because, you know,like many of us, have multiple
versions of Xcode. It suggeststhat maybe I could have multiple
versions of this to switchbetween, which, again, you know,

(08:26):
I'm actually very interested intrying this out on Linux.
Something like that. I like thatself contained idea. Keeps the
installation simple.
Keeps cleanup simple as well.Right?

Geoff (08:36):
Absolutely. And, yeah, to further go in on this, you know,
I didn't do it on Linux becauseI don't have a Linux install up
and working that I can dodevelopment on. I think the only
Linux install in my house is theSteam Deck. Yep. But I did do
all of this on my Mac in Emacs.
I did not use Xcode at all. Ididn't use any Mac specific tool

(09:01):
chain for doing any of thisdevelopment. It was it was all
done inside Emacs with the eGLUTand Swift LSP work to give me,
you know, autocomplete, stufflike that. And, yeah, it worked
great.

Peter (09:15):
Hey, folks. If you like what you're hearing in this
podcast and you wanna help thispodcast to continue going
forward and having great guestsand great conversations, I
invite you to become a Patreonsupporter. You can go to
patreon.com/compileswift, whereyou will get ad free versions of
the podcast along with othercontent. Walk us through, and

(09:38):
I'm sure it'll be quick, thevery simple install process for
these tools then. Right?
Go to go to swift.org. Youdownload it from there,
following the instructions foryour appropriate platform, I'm
guessing, and then code editorof choice. Did I miss anything?
I mean, that sounds prettypretty straightforward.

Geoff (09:55):
No. No. That that that's basically right. Yeah. Go
install Swiftly, the new Swiftversion manager.

Peter (10:03):
Link in the show notes, folks.

Geoff (10:05):
That's fairly straightforward install. Get
that installed. Use that toinstall the latest version of
Swift. In fact, actually, thefirst time that you run Swiftly,
it just goes ahead and goes, I'mjust gonna install the latest
version for You don't have topick a special SwiftWasm
version. You just installlatest.
And from there, it's exactly thesame as building any other non

(10:28):
Xcode Swift package. You justrun Swift package in it, and
that sets up a package. And thenwhat's different to get it to
build for Wasm is you just passin a specific Swift SDK
parameter, and you say, I wannabuild this for Wasm. And it just
goes ahead and runs that build,And you have a dot WASM file

(10:49):
there.

Peter (10:49):
Okay.

Geoff (10:50):
And then you need a different tool. This is where it
gets a little bit complicated,is you need a different tool to
run WASM code locally. I've notyet gotten into the point where
we're able to run this in abrowser yet, but there are
command line tools that can runWebAssembly code and on the
command line, basically.

Peter (11:10):
Okay. So when you did this, when you were trying this
out earlier today as we'rerecording this, how did you run
it then? You was you you andwe'll get into what you built.
But you were running it at thethe terminal as a terminal app
then? Or because I I I saw ascreenshot that you shared.
So at some point, you

Geoff (11:30):
Most so the very first version of it that I built was
just, you know, the the bogstandard hello world

Peter (11:35):
Mhmm.

Geoff (11:35):
Command. It's literally what's what's very neat is the
documentation for SwiftWasm hasyou change zero Swift code
whatsoever. You literally runSwift package in it. That gives
you a standard hello worldprogram. That just gives you a
standard hello world program.
You know, if you run this onyour machine today, in your

(11:58):
terminal today, it will give youthe same hello world. You just
swift run. It'll it'll printhello world. All this is doing
is saying, hey, that standardpackage that you always get, if
you just compile it with thisextra flag, you'll get a version
of it that you can run-inWebAssembly.

Peter (12:13):
Okay.

Geoff (12:14):
And so then, yeah, you talked about where am I actually
running this. They do link toanother tool called WasmTime,
and that tool is there to runWebAssembly code on the command
line and use command lineoutput. That is what I did to
run the original Hello Worldproject. Not in the browser yet.

(12:34):
Browser takes a little bit morework, But just making sure that
you have built actualWebAssembly code and you are
able to run this actualWebAssembly code, they have you
do all of that on the commandline.

Peter (12:45):
Okay. Alright. Maybe no promises here, folks. But maybe
at some point, one of us willtry and get a video showing how
this all works. In fact,actually, it's probably a good
excuse because it's been a verylong time since I made a video
on YouTube.
And I'm actually thinking Iwanna try this on my Linux

(13:06):
install on my laptop to validatewhy I've got it installed on the
laptop. So, maybe I'll try anddo that. No promises on the
timeline, but maybe I'll try andmake that happen. Moving on,
you've got all your toolsinstalled, you had everything
else ready to run. You ran theHello World, and everything was
good.
So tell us what you actually,you know, built with it and and

(13:29):
as an exploration here. I guessyou were doing this as forgive
me if you already mentioned it,but kind of a proof of concept
of this is a thing that could beused for for doing this. Right?
Yeah. So what did you what didyou build?

Geoff (13:41):
Basically, just wanting to play with the technology a
little more, man.

Peter (13:44):
Like, we ever need excuses as developers. Right?
You know? Like, oh, look. Shinylight.
Let's install it.

Geoff (13:49):
Yeah. So yeah. I I basically just wanted to get
out, like, okay. Let's see whatI can build for the browser and
see what I can run-in thebrowser. And so that's the next
step of everything is, okay.
Let's get this WebAssembly codeand let's talk to the browser in
some way. And so one currentlimitation of WebAssembly, and
this is true whether you'rewriting in Swift. This is true

(14:11):
if you're writing Pythoncompiled to WebAssembly, any
language that exists. You doneed interop with JavaScript to
really control anything in thebrowser because WebAssembly does
not have access to the DOM. Andso you can't actually output
anything to the browser withouthaving some integration with

(14:32):
JavaScript.

Peter (14:33):
So are we talking about, like, JavaScript as a as a
bridge between the two toessentially, what, add the
interaction between the Wasm andand the browser? Is that

Geoff (14:47):
correct? Yeah. There there is a need for JavaScript
to act as a bridge between thetwo. However, thankfully, the
Swift Wasm project has produceda Swift framework that handles a
lot of that for you and kind ofintegrates a JavaScript bridge
into Swift itself using theSwift dynamic member lookup

(15:08):
stuff. And so you're able tohave Swift code that is
interacting with JavaScriptdirectly.
And you can you use thisJavaScript kit, you import that,
and you're then able to interactwith DOM objects inside of Swift
code. And so you don't actuallyneed to write any JavaScript

(15:30):
code in order to have thatbridge there. It is all going
over JavaScript. It's notcompiled down to native
WebAssembly in that point, butit is you yourself are not
required to write any JavaScriptcode. Good.

Peter (15:44):
Perfect. That was gonna be my next question because I'm
sure, like, everybody, I'm like,oh god. Now I gotta write
JavaScript, but the answer isno.

Geoff (15:53):
The the the answer, you do need to write two lines of
JavaScript. You you and Even Ican do

Peter (15:59):
that without That's true. There you are. Yeah. Yeah.

Geoff (16:01):
Yeah. One thing that you do need from the website is you
need the actual area that youload it. And so what you do need
is you need to write an HTMLpage, basic HTML, whatever you
need there. And then it's got ascript tag. And inside that
script tag are your two lines ofJavaScript.

(16:22):
You need to import your Wasmmodule, and you need to tell
that module to run. So it'sbasically import, run. And those
are the two lines of JavaScriptyou need to write. And after
that, everything else is insideof your Swift code.

Peter (16:38):
Okay. So, I mean, that actually should be very familiar
to just about anybody that'scertainly done any web work.
Right? At some point, there'sgonna be essentially, you know,
whatever you wanna call it in inwhatever world you live, insert
this between the div tags andiframe or whatever. It's kind of
the same thing.
Right? Just inject this contenthere. Right? Yep. So do I need

(17:03):
to be running a local server ofsome kind for this, or does it
just spin it up?
What what was your experiencethere?

Geoff (17:13):
You do need a basic file server. It doesn't need to be
anything complicated. You don'tneed a whole server. They
actually just say NPX serve athing. I don't think Python is
still pre installed on a machineanymore, but that was also a
thing that you could always doin the past.
It's like Python dash m simpleHTTP server and then host
everything in a certain folder.You you need something that can

(17:37):
just

Peter (17:37):
host Serve up a page. Files in a folder. Got

Geoff (17:39):
it. You you don't you don't need to build yeah. You
don't need to build anythingwith Express or you anything
like that. You don't need awhole back end server. You just
need, can I run can I host basicHTML files?
Like, that that's like Well,that's good. I used one called I
used one called Kadi. I it's myfavorite. It's just, like, super
simple to use and superperformant. You just install it.

(18:01):
You say caddy file server. Boom.You're done and it's hosted.

Peter (18:04):
Okay. So don't wanna jump ahead here, but it sounds like
that will actually makedistribution of this thing a lot
easier as well.

Geoff (18:11):
Yeah. Because all you have to do is be able to host
dot JS file and a dot HTML file.That's that's your distribution.
Like Okay. That's all

Peter (18:19):
you need. Enough. Yeah. Alright. Alright.
Sorry. Yeah. I distracted youthere. So, yeah, back to to what
you were building. Go go for it.
Yeah.

Geoff (18:26):
Yeah. So, again, mostly, I was just playing with what it
is that Swift was able to do.But after getting the hello
world of command line workingand then get and then getting a
hello world in the browserworking, I wanted to see, okay,
what is some code that I havethat could, in theory, just work

(18:47):
and wouldn't require any sort ofrewriting. And so I went to my
app Bark, and I already had somecode there that was running both
on iOS and then also in myserver on Linux. And that that's
the barcode rendering code sothat I can, a, render it on the

(19:07):
local app as as you would expectin in SwiftUI.
But then I also have a differentversion of that that renders out
to PNG so that I can generateApple Wallet passes. And so it's
like, okay. I've already gotthis running on iOS and on Linux
on the server. It should befairly straightforward to have
this code running in the browseras well. And that way, you know,

(19:31):
I could have a, you know, webapp version of Bark and have
that displaying your yourbarcodes, however.
I don't have a real plan to doanything like that, but it was
just more like, what is the codethat can do something obviously
cool and probably won't take toomuch effort to port it to
SwiftWasm?

Peter (19:50):
Well, the other thing there too is when I'm playing
with new technologies, and thatI do like to go with something
that I've either built before,where it's like, okay, I know
what this thing should do, and Iknow how I build it to do it.
And essentially just can I portthis over to whatever this new
technology is without, you know,having to turn this into a

(20:14):
project plan or anything likethat, because it's building what
I've done before? Now, just andmaybe I'm a little too early
here, in which case we'll comeback to it, but can you use the
code from your app to in this?Or is it basically, no, you do
you you had to rewrite? BecauseI mean, is swift at the end of

(20:35):
the day.
Right? Alright. Here it is. Theone thing that I cannot do
without every day, and that ismy coffee. Anyone that knows me
or anyone that's listened to anyof my podcasts or anything else
knows that I absolutely cannotoperate without my coffee, and I
love good coffee.
So here's the deal. I'm gonnagive you one free bag of coffee

(20:56):
by going topeterwhidom.com/coffee. There is
a wonderful company out therethat follows the fair trade
practices, helps out a lot ofindependent roasters of all
sizes, and the operation issimple. What you do is you're
gonna go to toPeterWhidom.com/coffee. You sign

(21:17):
up there.
You get a free bag of coffeesent to you. Yes. In return,
they say thank you to me bygiving me some coffee, but
that's not the reason I'm doingthis. The reason I'm doing this
is because I have found so manygood coffees that I just would
never have come across, heardabout, or experienced without

(21:38):
this service. Trade coffee is isjust fantastic.
You know, there are plenty ofplaces out there. We all know
them that supply coffee, goodcoffee. You can go to the store,
get the coffee, but there isnothing better than discovering
new independent roasters andsupporting them, discovering new
flavors of coffee, new grindsfor you can set it up. It's very

(22:01):
smart. You tell it the kind ofcoffee you like, and over time,
it gets better and better as ittrains in on your selections and
your choices and gives youexactly the coffee you're
looking for and recommending newones that that will be very
similar.
Every time I get a new packet ofcoffee, I go through and
afterwards, I try the coffee. Igo through the service and I

(22:22):
say, look, I loved this coffee.I thought this coffee was okay.
Or I say, look. I've this wasreally not for me.
And every time I do that, itmakes the service a little more
accurate on the next selectionfor me. So, again, just go to
PeterWhidom.com/coffee. Get yourfree bag of coffee today. If
you're a coffee lover, you'regonna really appreciate this

(22:42):
service. I have been using itfor years at this point and
thoroughly recommend it.

Geoff (22:49):
Yep. It is swift at the end of the day. So the only
changes that I had to make whenpulling it over were removing
the parts of it that werespecific to other frameworks.

Peter (22:59):
Okay.

Geoff (23:00):
And so what I'm gonna say there is some parts of this code
did render specifically toSwiftUI. Mostly that was not
really relevant becauseobviously a lot of this is
running on Linux, which is notthere. But some of the code that
was on Linux that I pulled overwas directly reliant on
Hummingbird code. Hummingbirdbeing the Swift on the server

(23:23):
framework that we've talkedabout

Peter (23:24):
in past. Link in the show

Geoff (23:24):
notes. And so I needed to remove any references to
Hummingbird as well. And so onceI had done that, I really didn't
need to do anything else. I justneeded to remove, hey, this
reference is SwiftUI. Hey, thisreference is Hummingbird.
And once I had those referencesremoved, it more or less just
worked.

Peter (23:44):
Okay. So if people have followed your advice in the past
not my advice. Nobody everfollowed my advice. If they
followed your advice in the pastwith separation of concerns and
everything, you couldpotentially take the all
important business logic, overfrom whatever another platform,
another app, but you you couldessentially work with that.

Geoff (24:07):
Yep. And so that's what I'd done in the past. And I was
already just doing some kind of,like, basic removed from the
actual display encoding of thebarcodes. Okay. So I encoded the
barcodes down to basicallyvector drawing calls.
And then turning those vectordrawing calls into an actual

(24:31):
display, that part is separatedout. And so all of the stuff
that encodes the code to vectordrawing calls, that I was able
to just pull straight over.

Peter (24:41):
Cool.

Geoff (24:42):
On the app itself, those vector drawing calls then get
turned into SwiftUI, usesSwiftUI's paths and rects and
all of that in order to renderit out on the screen. In my
Linux code, in my server sidecode, sorry. I render it out to
SVG, and then I just take thatSVG and I use a converter

(25:04):
program on my Linux box to justconvert that SVG to a PNG and
use that PNG for the AppleWallet Pass. Okay. What I was
able to do in this case was takethat intermediary SVG, And
because you can just put SVGs inline in HTML, I just took that

(25:25):
SVG code that was output, sentit straight to HTML.
And I said, you know, put a divin here, fill that div with this
SVG. There it is. It's displayedon screen. And that just worked.
I just took this SVG code that Iwas already spitting out anyway
for my Apple Wallet code andjust put that directly on screen

(25:48):
in HTML.
And it works. And it displaysthe barcode in a web browser.

Peter (25:54):
Great. Yeah. No. Actually, so you essentially
removed a step. Right?
Yeah.

Geoff (26:00):
Yeah. I really did. Yeah. Because I I was already
rendering it to SVG in order tothen convert that SVG to PNG.
And probably couldn't do that inthe local browser because, you
know, where are you writing thattemporary

Peter (26:14):
PNG to? Yeah.

Geoff (26:15):
Yeah. But, yeah, I could just display the SVG directly
because that's just HTML code.And, yeah, that worked exactly
as I expected. Awesome.

Peter (26:26):
So I I did I did catch a little bit of the stream. I was
I was lurking in the backgroundwhile I was eating. All told,
what what are we talking herethen? Like, two, three hours
from from beginning to Yeah.

Geoff (26:41):
Two two hours two hour yeah. Two hours from nothing
running to displaying a barcodeon the screen. And honestly, it
was less than that because twohours included stream request to
support a specific type ofbarcode that it was not
supporting on the server side.So I would say it was probably

(27:04):
all told maybe ninety minutesbetween, you know, not having
touched this at all to having itinstalled, having done the
command line hello world, havingdone the browser hello world, to
having a barcode on screen.

Peter (27:17):
And so I'm not gonna name names. I can guess who it was.
And does the number fourseventeen? Exactly.

Geoff (27:26):
So I mean, honestly, that that does go into something else
that I did work. The PDF fourseventeen code for rendering
barcodes sorry. PDF fourseventeen is a type of barcode.
You've seen it on the back ofyour driver's license. If you
have a driver's license, youknow what it looks like.
We're not gonna get into thecomplicated ways of rendering

(27:47):
that barcode. Anyway, that coderelies on a different library
that I've written that I can useacross iOS and Linux. And that
library itself relies onsomebody else's third party
library to handle it's a BigIntlibrary so that I can handle

(28:09):
gigantic numbers. And all ofthat code, all I did was just
say, This is a dependency for myapp, my SwiftWasm app. And it
was able to pull in thosedependencies and compile them
for SwiftWasm as well.
And I didn't need to do anythingto those other dependencies. It

(28:30):
just worked. I was just able topull in standard Swift
dependencies and compile themfor WebAssembly and run them in
the browser.

Peter (28:37):
Interesting. So I do want to ask a question there, because
you mentioned that. And and, youknow, you did say that when you
essentially initialize a projectfor this, it's kind of by way
of, creates, what, a Swiftpackage. So does this can I use
Swift packages, you know, fromSwift package management so on?

(28:57):
I can just pull those in like Iwould any other dependency even.
Assuming that that's That's what

Geoff (29:03):
the it's just that they don't rely on any Apple
frameworks that only run on iOSor whatever. Yeah. As long as
they are PureShift frameworksthat you can pull in with Swift
Package Manager and run them onan arbitrary OS. Yeah. They just
work.

Peter (29:19):
Nice. So follow-up question to that. Because we're
not using, we have the benefitof not using Xcode and the
downside, which is we don't havethe debugger, how is your
debugging experiences with this?Presumably using like you said,
you used Emacs, but my codeeditor of choice, how what's the

(29:43):
debugging experience like?

Geoff (29:45):
Yeah. So I I know they do have a pretty cool looking
Chrome extension for debuggingWebAssembly code for debugging,
specifically Swift WebAssemblycode. Okay. And it looks like
you can set breakpoints. Itlooks like you can view the
stack trace, etcetera, etcetera.
I did not have cause to use thatin this stream because mostly

(30:07):
all of the code that I had wasalready existing code, so it was
already debugged. I got all thebugs out of it, you know, when I
read

Peter (30:15):
it Yeah.

Geoff (30:16):
Several months ago. So I wasn't doing anything
complicated enough or new enoughin this to need a debugger right
now. It does look like they havea fairly cool debugging system,
but yeah, I did not have time toget into it.

Peter (30:33):
So it sounds like then, and this is just an observation
from the outside, it sounds likeif you're someone who's familiar
with debugging web code, I mean,Chrome tools, right, probably
familiar territory for thosekind of folks. But

Geoff (30:48):
we we

Peter (30:48):
don't know for sure, but it sounds like if you're doing
that in the Chrome DevTools,you're probably on a home turf
there. Yeah.

Geoff (30:57):
Yeah. And, I mean, it like I said, it it looks like
you can do everything that youwould do with normal web code.
You just do it in dot Swiftfiles instead. Set breakpoints,
print stuff, do whatever youwant.

Peter (31:10):
Alright. So you had a good successful experience. You
you got your app working andeverything else. Are there any
gotchas or or downsides? And Iget it.
You're you're obviously notlooked into everything on this.
But from your sort of earlystatus of of getting this and
trying it out, what do youthink? Are there any downsides
to this that really stood out?

Geoff (31:31):
Yeah. So there's there's still quite a few limitations on
the Swift code that you canwrite and deploy in WebAssembly.
If you go look at theirdocumentation, there's a bunch
of things that they basicallysay, Like, you can't touch this
part of code. I think the bigone that people would be missing
is all of the networking stuff.So you don't have URL session.
You don't have any of thosekinds of friends. You have to go

(31:55):
through JavaScript bridge to donetwork requests and whatnot.
The other thing that's reallymissing is any sort of
multithreading support. So youhave the Swift async await
concurrency stuff, but it's allstill jumping around on a single
thread. Okay.
So there's no realmultithreading in SwiftWASM.

(32:17):
Code that you've written that isusing async await, it will
technically work. It's gonna beslower. It's gonna not really

Peter (32:26):
Won't be performant?

Geoff (32:28):
It's not it's not going to be actually concurrent, I
guess, the thing that I'm tryingto say. Any code that you've
written that is depending ondispatch, for example, that just
won't compile. Yeah. You do nothave dispatch at all. You don't
have any anything like that.

Peter (32:42):
Question on that then. So for things like that, I mean,
will it tell you and try to helpyou and say, hey, this is not
gonna happen.

Geoff (32:50):
No. It it it will just fail.

Peter (32:51):
Okay. That's what I was gonna ask. It's like, you don't
wanna deploy it and, like Yeah.Am I just assuming that it's
working?

Geoff (32:58):
No. No. No. It it'll fail. Okay.
Cool. Time for a break.

Peter (33:03):
Hey, everybody. It's Peter Widom here from the
compulsive podcast. I wanna tellyou about Setapp. Setapp is a
service that provides asubscription fee of just $10 a
month, and you get access toover 200 Mac applications, and
it's also available now on iOSas part of that deal. I use the

(33:23):
service because it just has aton of really good first rate
apps that I use all the time.
And for me, it's invaluable as adeveloper to have access to
tools for things like APIs, forplanning projects, writing
emails, writing documentation,and you get all of these things,
including database apps, all ofthat kind of stuff right there

(33:46):
on the Setapp service for just$10 a month. You can use as many
or as few applications as youneed. If you're interested in
checking this out, go toPeterWidham.com, p e t e r w I t
h a m Com forward / set app, s et a p p. And you can see the
details there, and it's got alink that you can go over and

(34:08):
start using the service and seehow it works out for you. I
strongly recommend this to everyMac user.

Geoff (34:15):
Break time over. So that that's the the that's the stuff
that's missing. Is it is thingslike that. The other big one
that's missing that I I didn'tquite understand why this one
was missing is timer. It's justmissing on WebAssembly.
Yeah. That one seemed weird. Idon't know why that's happening.
Maybe that's related to themultithreading stuff. Nothing's
like counting ticks in

(34:36):
the background.
Yeah. But, yeah, that's just unavailable. So that that
one's also not available there.And so that would kind of a
bummer if you're relying on thatto to do stuff.

Peter (34:46):
That that actually is quite a big one. Yeah.

Geoff (34:51):
Yeah. The other big downside that I think is mostly
fixed, and this is a large partof why I wanted to try this out
again, but have not gotten tothis yet. And this counts as
maybe definitely a downside, andmaybe definitely partially like,

(35:12):
just a complication is in thestandard build that you get from
SwiftWasm, the WASM files thatit generates that people would
have to download on your end aregigantic.

Peter (35:26):
Oh.

Geoff (35:28):
The file that I did to display that little barcode,
take take a guess at the fileOh, gosh.

Peter (35:35):
Okay. So I'm gonna go what I think would be like a
real outside number and say 400k. It's like a crazy number.

Geoff (35:45):
You're off by a couple or order of magnitude? Yeah.

Peter (35:47):
Oh my god. Really?

Geoff (35:49):
That was 62 megabytes. Oh, okay. That's

Peter (35:56):
Crunch that cell phone network.

Geoff (35:58):
They have have, theory, fixed this using the newly
supported relatively newlysupported Swift for embedded
frameworks. So Okay. Using Swiftfor, say, the Arduino, any of
those kinds of things. Thatsaid, that is kind of a separate
way of building things. And soit requires a lot more setup to

(36:23):
actually make that build happen.
And I did not have the time toget into that today. It does
look like it is relativelypossible. And the FlappySwift
project that I mentioned at thetop of the stream, that was only
a hundred k Okay. Which is stilllarge, but not unreasonable
large, especially for a fullgame

Peter (36:43):
being there. Right.

Geoff (36:46):
Yeah, it it definitely takes a lot more setup to
actually get it to that point.Whereas, yeah, the standard
build, the thing that took me notime at all to get set up, 62
megs. It's it's a littleridiculous.

Peter (36:59):
So You know what, though? I'm gonna give them I'm gonna
give them the now here of, okay.It's not early days, but fair to
say optimization has not been apriority. But I am surprised
that a lot of these things,these kind of tools in that now,
when they do an export releasebuild, they do a lot of

(37:21):
crunching to reduce the filesize. But maybe they've just
chosen to focus on either areasat this point.
Let's hope. If you do

Geoff (37:31):
the embedded Swift tool chain, it is supposed to be much
smaller. It just that is notstraightforward to get hooked up
the way that just the standardSwift build works.

Peter (37:42):
Definitely download and cache that file. Right? Damn.
Yeah. Jeez.
Okay. Well, that that definitelycounts as a downside, but maybe
only in the near future. Nextcouple of years. Alright,
anything else that we've notcovered on this? Would you
recommend okay, so

Geoff (38:04):
I do recommend checking it

Peter (38:05):
was gonna say, recommend checking it out. Clearly sounds
like it's like, you probablydon't wanna think about this for
production heavy usage or at allat this stage. Is that a fair?

Geoff (38:18):
If the embedded stuff works the way that it's supposed
to and you can get to the, like,one off Like, you you can get
that into, a build script thatyou can run on your CI and have
it doing everything that youneed to do so that you don't
have to ever touch it again. Itmight be worth looking into.
Like I said, that one that I sawthat kick started this again,

(38:41):
100 k for an actual game thatyou can play in your browser.

Peter (38:46):
Not bad. Think that's exactly right.

Geoff (38:47):
And I mean, if you've got that all written in Swift and
that's code that you can have,your standard code and you can
reuse code, you can do anythinglike that, I think it's worth
looking into. Like I said Orlike you said, it is early days.
I'm sure it will evolve in thefuture. There's a lot of things
that are manual now, like theJavaScript bridge that probably

(39:11):
people will start buildingframeworks for. But I I I'm
excited about it, at least.

Peter (39:17):
Cool. I mean, I don't know about JavaScript frame. You
know, I've noticed that there'speople are reluctant to invent
JavaScript frameworks. So I Idon't know if that'll happen,
but maybe.

Geoff (39:29):
Sure.

Peter (39:31):
Oh my gosh. That'd be a hundred by next week. Yeah.
Alright. Cool.
This has been fascinating,Geoff. I I hope we've given
folks something to think about.For those of you that love to
explore and play with things,like every engineer ever, I
think, give it a go. Try it out.Folks, we would love to hear
your thoughts on this.

(39:51):
If you've used this tool or ifyou are someone working on this
project, we are we wanna throwthis invite out to you. We would
love to have you come on thepodcast and talk about it. That
would be great. Other than that,Geoff, where can folks find you?

Geoff (40:07):
You can find me, as always, on cocoatype.com.

Peter (40:09):
There you go. And you can find me

Geoff (40:11):
Got links to all the places.

Peter (40:12):
Yep. And you can find me at peterwitham.com. You can find
this podcast, the compile swiftpodcast at compileswift.com.
That's what we got for you,folks. Check out the show notes.
There'll be a whole bunch oflinks in there. Check out the
Discord as well. And if youwanna go the extra mile and
support us on Patreon, like somany of you folks have, Shout

(40:32):
out to you you supporters. Thankyou so much. We greatly
appreciate it.
It really does make all thedifference. You can go to
Patreon.com/compileswift, andyou get an ad free version of
the podcast episodes, andsometimes we like to throw out
some extras in there for you aswell. Plus, of course, we've got

(40:52):
great members over there. That'sit, folks. We will speak to you
in the next episode.
Goodbye.
Advertise With Us

Popular Podcasts

Stuff You Should Know
My Favorite Murder with Karen Kilgariff and Georgia Hardstark

My Favorite Murder with Karen Kilgariff and Georgia Hardstark

My Favorite Murder is a true crime comedy podcast hosted by Karen Kilgariff and Georgia Hardstark. Each week, Karen and Georgia share compelling true crimes and hometown stories from friends and listeners. Since MFM launched in January of 2016, Karen and Georgia have shared their lifelong interest in true crime and have covered stories of infamous serial killers like the Night Stalker, mysterious cold cases, captivating cults, incredible survivor stories and important events from history like the Tulsa race massacre of 1921. My Favorite Murder is part of the Exactly Right podcast network that provides a platform for bold, creative voices to bring to life provocative, entertaining and relatable stories for audiences everywhere. The Exactly Right roster of podcasts covers a variety of topics including historic true crime, comedic interviews and news, science, pop culture and more. Podcasts on the network include Buried Bones with Kate Winkler Dawson and Paul Holes, That's Messed Up: An SVU Podcast, This Podcast Will Kill You, Bananas and more.

The Joe Rogan Experience

The Joe Rogan Experience

The official podcast of comedian Joe Rogan.

Music, radio and podcasts, all free. Listen online or download the iHeart App.

Connect

© 2025 iHeartMedia, Inc.