Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Develop in Swift Tutorials (developer.apple.com)
58 points by Austin_Conlon on April 4, 2024 | hide | past | favorite | 57 comments



I think swift 6 will be the version where this language finally exists, or will remain a niche for always, until it get replaced by another (hopefully open, hopefully truely cross-platform) tech.

Apple was a great place to start the language but its now completely really detrimental to it, largely due to its impact on the ecosystem (objc compatibility, xcode, focus on iOS only, etc).

I believe swift core team should now reorganize around a community of people working in various major companies, not just apple.


Picking up Swift in 2024 seems like a bit of a sucker move if I’m honest.

A language that only runs on a tiny fraction of hardware, has crappy documentation, has poor interoperability, a questionable developer toolchain that only runs on one platform and then to top it off anything you want to release with it basically has to go through an extortion racket where the worlds richest company is going to take 30% of your revenue and has the ability to shut you down at any point, for any reason and provides no meaningful recourse.

Honestly it’s a terrible choice.


Swift runs on microcontrollers now; you gotta update your knowledge. https://www.swift.org/blog/embedded-swift-examples/


Basically, anything that comes from a swift.org link is cross-platform and will run perfectly well just about anywhere.

If you've got something coming from developer.apple.com it will be specific to the Apple ecosystem. And of course this learning resource is Apple-specific since it is coming from developer.apple.com.


Swift the language is open source and runs on pretty much anything.

Also it’s quite a nice language to work with and developing native iOS apps is an enjoyable hobby.

I wouldn’t want to tie my pay cheque to it though for sure.


Are you suggesting iOS developers should use another language (Flutter? Objective-C?), or that it’s a sucker move to become an iOS developer?


I think they did a pretty good job of explaining that they meant the latter.


I mean, a tiny amount of overall unique hardware but the iPhone alone has been and continues to be the best selling computer of all time.

And users of their hardware tend to be the most dedicated to the platform and willing to pay for software. And they have more money than the overall average "computer user".

Nothing to brush off.


I've built my career on Apple platforms and honestly this is basically what people have said about it since the beginning.

I'll offer a counter and say that if you like the Apple ecosystem, there's never been a better time to get started. SwiftUI is an amazingly great way to build apps – and again, I've been doing this for a very long time so I'm speaking from experience here.

For smaller developers, the revenue share can be as low as 15%.

Also, for anyone weighing the decision keep in mind that while iOS may not represent the largest marketshare in the world, their users are well known to spend more money on the platform compared to other platforms.


“As low as 15%”

Great! That’s so much cheaper than the 0% you can get on other platforms.

This used to be acceptable when Apple was innovating and providing extra value, today it doesn’t fly.


What other platforms provide what Apple provides at 0%?

As a hobbyist I love having international commerce largely papered over and abstracted away. There’s no need to worry about exchange rates, taxes, hosting, or bandwidth. This is well worth the 15% to me.


You’re really delusional if you think you can get 0% on any platform ever…


Let’s do a test. Write a hello world application and make a subscription for it for $1/mo. Publish it in git and offer it on the web, Windows, iOS and Android.

Beyond your time investment, which platforms costs more than $0?


All of them.


I think you’re mistaken in regards to Apple. https://www.forbes.com/sites/siladityaray/2024/01/17/apples-...


First iOS support 2 platforms since iOS 2: the web and the App Store. You deploy for the web, you deploy for iOS. (Direct quotes from a WWDC.)

Now assuming you’re talking about the App Store I don’t get your point anyway. For all platforms you’re gonna have to pay something at some point so all of them cost more than 0$.


And how many features are unavailable for the web? It’s not apples to apples.

The point is that you don’t need to pay if you’re hosting a github pages pwa. The backend costs are shared.

There’s a reason Apple got into the credit card business, the extra a fee for every transaction model has been their core for a very long time, it was natural.


> I've built my career on Apple platforms and honestly this is basically what people have said about it since the beginning.

Do you have recommendations for learning Objective-C for a front-end web developer?

I'm starting with "Objective-C Programming: The Big Nerd Ranch Guide" but would appreciate resources recommended by someone who's built a "career on Apple platforms".

My apologies for so open-ended a question.


Hmm, well – Objective-C holds a place in my heart. It's not for everyone, but it's really where I got my start and I think it's a beautiful language and had an incredibly unique community around it that started with all the NeXT folks.

I'd be curious why Objective-C now? Still has its place for some things. It's interoperability with C++ for instance, especially if you're dealing with things like Metal or certain real time audio libraries.

It's also probably a niche in terms of maintaining legacy stuff. Like being a Fortran developer and having your pick of contracts because nobody remembers it anymore and some crucial piece of infra relies on it.

But, Big Nerd Ranch guid is how I learned! And again, by doing projects. Just pick something you want to build with it and see it through to the end. Like writing, it's best to plough through and just get SOMETHING that works end to end, knowing that it'll be your first draft and you'll get it better on the second Tim around.

Good luck!


Is there a reason you want to learn Objective-C instead of Swift?

My advice would be to swim with the current and choose Swift and SwiftUI unless you have a good reason not to.

Some of the newer frameworks don’t support Objective-C and I only see that trend continuing.


> Is there a reason you want to learn Objective-C instead of Swift?

My goal is to write native software for macOS, which I understand to be more amenable to Objective-C.

I am also interested in Swift but want to focus on Objective-C for my first projects.


Is swiftUI is still quite a flux state? And not can be done by it?


I haven’t had any issues with it or needed to revert to UiKit, but I’m still fairly new to developing for the Apple ecosystem, so your mileage may vary.


Thank you, I always wanted to learn to develop for apple OSes. This one sounds like a sure source of truth.

I heard of 100 Days of Swift[1] as well. Do people have feedback on the matter?

[1] https://www.hackingwithswift.com/100/swiftui/1


Yes, 100 Days of Swift (and, really, anything by Paul Hudson (@twostraws)) is really good and recommended all over the place.

One more resource I'd add for a beginner, the book The Swift Programming Language: https://docs.swift.org/swift-book/documentation/the-swift-pr...


All of Paul Hudson’s stuff is great.


I also recommend asking GPT-4-Turbo for SwiftUI guidance.


One of my more unpopular opinions is that Swift would’ve made a good successor to Java for server development. Syntactically I feel it is in that smalltalk-inspired vein and feels like a pretty elegant balance of simplicity and robustness (strong typing, concurrency friendly primitives etc etc). And the reference counting based memory management is really interesting for servers where consistent latency is desirable. I know there’s a working group on it and a small community, but it never seemed to take off and get the kind of Linux optimization needed for high performance. Am I wrong?


I built my first iOS app in 2010. Today, it's fantastically easier to get started. A night and day comparison. My biggest piece of advice: pick something you're interested in, build it, see how it comes out, and then do it again. You'll learn way more with a project you're interested in to motivate you.


The only issue that I've had with SwiftUI -and it's a showstopper- is that SwiftUI makes writing fairly basic apps insanely easy, but really has problems, when I try to veer off the beaten path (which describes pretty much every single one of my projects).

Apple has always enabled staying in their desired UI and workflow, but I've usually been able to find a way to coerce the system to do what I need.

That appears to not be the case, with SwiftUI. You need to follow The Rules. Workarounds are crazy complex.

But I love working in Swift. It's just that I ship [UI|App|Watch]Kit.


You'll definitely have a much more pleasant time following conventions – which arguably provides the best user experience. But for those times when you just really have to have something non-conventional, I've found that the UIViewRepresentable fallback works well. Just easier in those circumstances to not try and mix the two approaches, but separate them.

Example in a recent app was it was easier for me to use a UIScrollView for the image panning and zooming functionality it offers. Simple matter of wrapping that one element in the Representable.

Generally, for me it's been a ginormous productivity booster. I can rip apart and re-design a SwiftUI app and it doesn't break. That was always a lot more of a challenge with pre-SwiftUI apps.


It's not just non-conventional UI.

For example, I wrote a dashboard app for the social app we wrote. Part of it, is a map, displaying the geographic distribution of users.

It needed to be affected in a number of ways, and SwiftUI completely fell down. I spent over a week, trying all kinds of crazy stuff, and then gave up, and coded up the map screen in about four hours, with UIKit.

Since this is a central feature of the dashboard, it meant that I had to also toss the previous week's SwiftUI work, and start from scratch with UIKit.

I'm not very happy with UIViewRepresentable, and I eagerly await native SwiftUI API elements.


I’ve wrapped MapKit in a UIViewRepresentable without any problem, what was your specific issue? UIKit and SwiftUI are both built on top of CALayers, SwiftUI is just way more opinionated. Once you grasp this the difference between the two APIs feels superficial, like a mere style preference.


It's a long story, and not one I feel like rehashing.

Not a big deal. I basically like the philosophy of SwiftUI, and want it to work, but I feel as if it still has quite a ways to go, before it is ready for the kind of stuff I do.

The documentation, in particular, is pretty ... sparse. That's a cardinal sin, if you are publishing a framework (I've written frameworks, and spent a huge amount of time on documentation).

I'm quite aware of the enormity of the task at hand. I sometimes wonder if the folks that started on that path really understood what they were getting themselves into. It's a real rabbithole.

I really dislike AutoLayout, but I've also gotten quite good at it. UIKit/AppKit with AutoLayout can do just about anything.


I'm working on some porting-apple-code-to-Linux and it's quite a pain, many info is proprietary so google/chatgpt won't help you, neither does apple, there is no tech support, posts to its community forum has been zero responses for the last year.

While I understand many love development with Apple, I decided never to touch anything to do with it. Linux, even Microsoft, are much easier to get things done and not locked up to a closed ecosystem.


I will echo what others have said here - Apple have failed on the original goals of Swift.

- It is no longer simple, Swift 4 onwards have been piling the complexity higher than I previously thought possible. I would never recommend it as a language to teach. I would have with Swift 3, but 4 to now - absolutely not - too complex.

- It was never open, but the language features dropped on the community to support SwiftUI cemented the fact that outside contributors are not treated with any respect. Worth reading - this is from the guy who created the language! https://mjtsai.com/blog/2022/02/22/why-latter-left-the-swift...

- Swift on the server is dead. Swift on other platforms has dreadfully poor support. It would and should be rejected for anything outside of iOS apps.

Kotlin or Rust are much much better choices that live in the same space that Swift projects would be considered for.


It really strikes me as odd how often I see the "Swift got too complex" criticism. IMO, all Swift got was all the best features of programming languages, designed as good as or better than in almost all other languages. It feels like calling Swift too complex is like calling a box of tools too complex. You don't need to understand all of them to use any of them, and the easiest tools in the box are those that are perfect for 90% of jobs.

Enormous caveat for SwiftUI, but that's not part of the language, it's a framework. The parts of the language that enable it are perfectly nice.


Swift has some of the simplest code for what it’s trying to accomplish. Any complexity is opt-in.

Error handling is great and works well with async. Protocols and enums are amazing. It’s keeping up with new patterns and techniques such as implementing move semantics and actors. As well as c and c++ interop, and so on.

Support is coming for other OSs.

Kotlin constantly clashes with java. It almost feels like typescript + JavaScript.

Rust doesn’t allow for shared mutability making common/simple patterns for making apps much more difficult. I like rust but it has its own place.


How effective would it be to shove all of the swift/swiftui/OS-dev docs into vector store and RAG it with a LLM?


It’s been done a few times now. In looking for more SwiftUI docs, I’ve used a GPT from OpenAI’s gpt store where someone’s uploaded a bunch of their docs.


Anyone developping in Swift on Linux ? How much of an uphill battle is it ?


I’m developing a full backend using Vapor. Fluent (Vapor’s ORM) is a bit raw but that’s being worked on, otherwise it’s very pleasant. Vapor’s community (on Discord) is great!

I compile in a Docker, and deploy the resulting image (multi-step docker file, first step for compilation, second step copy the resulting binaries).

Installing Swift on Linux is a one-liner now if you want to avoid Docker https://swift-server.github.io/swiftly/. EDIT: Two-liners actually: first install swiftly then install Swift…


It’s in Fedora’s repos.

“sudo dnf install swiftlang” is all it takes to get started.

https://developer.fedoraproject.org/tech/languages/swift/swi...


I have in several capacities over the past few years.

VSCode works pretty well with the sswg extension (powered by sourcekit-lsp). Devcontainers are particularly nice if you are into that sort of thing (I develop in a Linux container on a macOS host). I actually find it easier to experiment with new toolchains (for example, the nightlies) in the Linux container than on my host machine (which requires more manual setup).


Wonder which linux container - docker, Lima, vm …


Thank you, but no thank you. I don’t need to promote a proprietary ecosystem charging yearly fees with my addition.

PWAs or nothing.


I feel like I haven't seen PWA's in a while. Are there any you recommend as feeling like native apps?


That depends. You’ll start encountering dark patterns when the address bar and underlying Safari browser appears and ruins the experience.

PWAs are the alternative App Store we need, not a just a bandaid.


No


VSCode.dev


They hated Jesus because he told them the truth.


I wonder who Jesus is in this scenario.


It’s a meme.

https://knowyourmeme.com/memes/most-people-rejected-his-mess...

The parent is right that web technology is the most democratic solution, but native fanatics will never accept the truth.


I am forced to use web “apps” for work, and they are (still) terrible. It might be the best way to reach maximum people, but that does not make it a good way.


I am forced to use “apps” for everything, and they are (still) terrible. It might be the best way to access platform apis, but that does not make it a good way.


Most “apps” are wrappers around web pages though, or written in cross-platform technologies, making them not really apps.


Gee, silly me, mobile developer who is unable to recognize when I see native application instead of web wrapper.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: