Hacker News

toomim said 13 days ago:

I'm into this. I've wanted to build something like this before, too, but never finished it.

This feels closer to how app building should work. If I have a web app, it should be simple to give it an icon, with notifications.

And if I want to build that, I shouldn't have to figure out all of XCode. I should be able to just quickly make a webview with native controls.

And I shouldn't need to download all of electron. An OSX webview should only need a few kb as a standalone app.

hadtodoit said 13 days ago:

Please, no. Your application belongs on the web. I can already tell when applications are written with middleware, cross-platform tools, electron, etc. because they always run like trash. They offer no benefit over a website and only open up your machine to new attack vectors. I know I'll catch flack for this, but we shouldn't lower the bar to entry here. Native app development is not significantly more difficult than web and it's drastically better for the end user.

untog said 13 days ago:

You’re welcome to not use it.

I don’t mean to sound overly negative but for small shops or individual developers there is simply no way for them to create a web, Mac and Windows version of their app at the same time. Personally, I’m glad that the likes of Electron give them the option. I’d much prefer a fully native version but I’d take Electron over nothing. You’re free to disagree of course, but no one is forcing you to install these things on your computer.

saagarjha said 13 days ago:

What if it's a massive developer and everyone in your workplace uses it?

toomim said 13 days ago:

It sounds like you didn't read the blog post: https://kofi.sexy/blog/multi

The problem this solves is that web apps don't have (1) cmd-tab icons or (2) decent notifications. And it does that without using "cross-platform tools" or "electron". That's why it's cool.

comex said 13 days ago:

The web is a cross-platform tool. It's fine for what it is, but it can't provide an experience that feels native, or runs nearly as fast as native.

ta17711771 said 13 days ago:

PWA is coming.

said 13 days ago:
hadtodoit said 13 days ago:

It sounds like you didn't read my post. My complaint was that its lazy developing to just take your web app and put it on the desktop. I was not commenting on the merits of this tool.

saagarjha said 13 days ago:

I would suggest tempering your comments with the merits of this tool rather than immediately jumping to calling them lazy.

IggleSniggle said 13 days ago:

While I don't entirely disagree with your sentiment, this is pretty distinctly not middleware/crossplatform/electron.

The closer analogy here is the iOS ecosystem, where folks ship apps that are really just Safari WebViews inside an app icon, and who would probably be perfectly happy to ship a PWA if users weren't thoroughly trained to use the AppStore.

Operyl said 13 days ago:

There are a handful of electron apps I've run into that I didn't realize were electron. For example, GD Launcher. It's not always so bad.

e_carra said 13 days ago:

Another example is VS Code, when I found out I was very surprised.

M5x7wI3CmbEem10 said 13 days ago:

so writing it twice on Swift and Java is better than once on something like Dart/Flutter?

what’s the best cross-platform strategy?

ajconway said 13 days ago:

Historically, developing an app with tools that are native to the platform provided asymptotically better user experience. So, if your goal is to perfect the UX, native is your choice.

In reality, rarely do you need to work on the UX first. It is usually more wise to sketch the idea using cross platform tools, validate the idea, then rewrite parts of it / develop new features with native technologies.

M5x7wI3CmbEem10 said 12 days ago:

my concern with not releasing it correctly the first time is that someone else picks up the idea and does it better before you can.

hadtodoit said 10 days ago:

This goes back to the argument of first to market or best. I have yet to see a definitive answer.

hadtodoit said 13 days ago:

If all you're doing is creating an MVP do whatever is easiest. But yes ideally you would have two separate codebases and obviously it's dependent on your project how much tools can be shared between the projects.

jbroman said 13 days ago:

Have you tried making an installable PWA? This should allow you to get an icon, notifications, and a separate window.

rrdharan said 13 days ago:

I don't believe you get notifications for PWAs on iOS - nor can you use service workers..

izacus said 13 days ago:

But this is macOS we're talking about - the macOS app from this guide won't run on iOS either.

aantix said 13 days ago:

The JS performance in mobile safari is pretty incredible.

What can native do currently that js/html would have difficulty with?

toomim said 13 days ago:

Did you read the article? This has nothing to do with mobile.

jitl said 14 days ago:

See also the blog post: https://kofi.sexy/blog/multi

The swift-only, programmatic approach without Xcode or the typical app framework is very cool! Assembling those parts seems like a great learning experience.

(More interesting to me than the actual functionality)

saagarjha said 13 days ago:

A couple of nitpicks about the process:

> NSMakeRect/NSMakePoint

Generally I prefer the actual constructors.

> NSWindow.BackingStoreType.buffered/NSApplication.ActivationPolicy.regular

You can just use .buffered/.regular.

> let _ = NSApplication.shared

Just _ = NSApplication.shared works: https://github.com/saagarjha/DarkNight/blob/0e3aef8559b634ce...

> Rizwan Sattar wrote a neat workaround that monkey-patches NSBundle, which I’ve translated to Swift 4 below

Don't do this, it will stop working (crash!) once you update your Swift version and the compiler is smart enough to start making direct calls. As far as I am aware, this is the correct way to do it: https://github.com/saagarjha/DetailsViewer/blob/master/Detai...

hkgumbs said 13 days ago:

Thanks, these are nice clean ups! I added a note in the blog post that points to your Swizzler example. The final version of Multi didn't end up needing that NSBundle monkey-patch though since it was a "proper app" with an Info.plist file.

saagarjha said 13 days ago:

Yeah, an actual Info.plist is much better :)

spilk said 13 days ago:

Sounds similar to the old Fluid website wrapper for MacOS X ( https://fluidapp.com/ )

gwbas1c said 13 days ago:

I love fluid apps!

One thing I've always wanted is a Chrome plugin to redirect links into a dedicated fluid application.

tribeca18 said 14 days ago:

This is really cool! The inspiration behind creating this reminds me of another app too: https://getstack.app

hundchenkatze said 14 days ago:

This is pretty neat :) I read the blog post[0] about it too, and I definitely feel your multiple chat app pains. I'm curious to hear more about why you avoided Xcode and ViewControllers. In general I know many people dislike Xcode, but I've been doing iOS dev for a while now so I guess I'm used to it (it's a love have situation for me at times)

[0] https://kofi.sexy/blog/multi

hkgumbs said 14 days ago:

Thanks! Honestly my reasoning for avoiding XCode is fairly thin—I just hadn't used it before and didn't have it installed when I started. I imagine if I took the time to learn it, it would be fine. But I do also feel a bit weird about how developing for certain platforms requires you to use a specific IDE. I thought that was part of the goal of Swift (vs ObjC), but I may be just reflecting my own biases :)

hundchenkatze said 14 days ago:

Yep the macOS + Xcode dependency is quite annoying. If you want a, kind of, in between solution, the true dependency is on the command-line tools[0]. These can be installed independent of Xcode. You could piece together your own build scripts or use something like Buck[1] to build it. If you still want a full-blown IDE, checkout AppCode[2] from JetBrains. It still depends on the aforementioned commandline-tools though.

[0] https://developer.apple.com/download/more/ (you'll need an AppleID)

[1] https://buck.build/setup/getting_started.html

[2] https://www.jetbrains.com/appcode/

* edit: formatting & it looks like Buck doesn't have macOS targets.

macintux said 13 days ago:

Make sure you see this comment (I take no blame or credit for its accuracy).


Very cool project, thanks.

cerberusss said 14 days ago:

Recently I wrote a script in Swift, on macOS. It can be developed and run without Xcode, in plain vi if you so wish. It's pretty great, and I liked it a lot.

hkgumbs said 14 days ago:

Yup, that was exactly my workflow as well! And for building CLIs it's quite nice. Once I started using AppKit though, it felt like I kept running into things that weren't quite finished.

jaflo said 14 days ago:

Did you have experience developing for MacOS before?

hkgumbs said 14 days ago:

I built a few Swift CLIs before, but this was my first time working with AppKit (the macOS GUI framework)

shp0ngle said 13 days ago:

I’m probably missing something... what’s the positive of using this instead of just opening a few browser tabs?

edit: oh I see... single notifications and simple switcher. OK, seems reasonable enough

stevewillows said 13 days ago:

pretty slick. For web apps, I've been using this as a zsh alias to launch whatsapp and a few other similar sites without any toolbars (etc)

    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --app=https://web.whatsapp.com --kiosk
econcon said 13 days ago:

Those with Mac development experience. What's the earliest way to make a screenshot app?

saagarjha said 13 days ago:

Depends on what you're trying to screenshot, but CGWindowListCreateImage is probably the function that you want in most cases.

archildress said 14 days ago:

The iOS image recognition, done on-device as I understand it, is one of the coolest things that it seems no one talks about.

rasen58 said 13 days ago:

Where does that fit into this macOS app?

ngcc_hk said 13 days ago:

Don’t get this. Anything to do with this macOS app?