Firebase
Hacktoberfest 2023: Building a Car Maintenance app with Firebase and SwiftUI
Mikaela has been busy juggling writing code, doing live-streamed PR / code reviews, and getting to grips with being an open source product manager for her Hacktoberfest project.
If you're interested in working on an open source project that uses SwiftUI, Widgets, Firebase, and a bunch of other cool technologies in a beginner-friendly environment, head over to the repository for details on how to get started!
Or watch one of the live streams to get up to speed with what the team of 30+ contributors is currently working on.
Enabling or disabling email enumeration protection
Google Cloud recently turned on Email Enumeration Protection by default.
This is an important step to prevent malicious actors from using a technique called Credential Stuffing to attack your users. In short, credential stuffing is the act of taking over a person's account by trying to log in using leaked (or easy to guess) credentials into as many systems as possible. And - as too many people still use the same email and password combination for many of their accounts - this strategy still works.
Disabling Email Enumeration means that if you try to log in to a user's account (say, using a REST API), you will no longer get a response INVALID_LOGIN_CREDENTIALS
(which tells you there is an account with that email address). This makes is much harder to use this attack vector, as a malicious actor can no longer know when they need to stop trying to attack an individual email address.
For more details, check out the documentation.
If you created a new Firebase project on or after September 15th, Email Enumeration protection is on by default. If you are using Anonymous Authentication to implement guest users, you might run into issues when trying to upgrade an anonymous user to an account that uses Email and Password auth. The team is aware of this issue, and we are working on a solution (for example, here is the WIP PR for the Firebase Apple SDK), and it should be solved with one of the next releases.
SwiftUI
Tutorial: Building Reusable SwiftUI Components
When I submitted my talk proposals to iOSDevUK, I also suggested my talk Building Reusable SwiftUI Components. It's a really good talk (I have been told) that walks through the process of refactoring a moderately complex List
based UI into a reusable Avatar
component that supports SwiftUI's styling API.
But the organisers, always on the look out to make iOSDevUK the best iOS/Swift conference, suggested running the talk as a workshop.
So I sat down and turned the talk into an interactive tutorial (using DocC). It's divided into four chapters that walk you through
- Basic and more advanced techniques for composing views
- How to make SwiftUI views customisable
- Making your views interactive by adding action handlers
- Using SwiftUI's styling API to make them stylable, just like the built-in views like
Button
orToggle
You can finish the tutorial in under 2.5 hours, and I promise it will take your understanding of SwiftUI to the next level.
I've even been told that you do the entire tutorial just on an iPad using Swift Playgrounds, which is pretty mind blowing.
I hope you like the tutorial - if you finish, let me know what you thought about it. Or, even better, tweet about it, so other people can benefit, too.
Create an iOS Share Extension with custom UI in Swift and SwiftUI
Documentation for creating iOS Share Extensions has been scarce: Apple's original documentation hasn't been updated since 2017 (and obviously doesn't show how to integrate with SwiftUI), and the only other articles I was able to find are this one from 2020 (no SwiftUI, though), and this one from 2021.
Henri wrote an excellent article about how to Create an iOS Share Extension with custom UI in Swift and SwiftUI, and it answers all the questions you might have:
- How to add a Share Extension target to your project
- How Activation Rules work
- How to show your own UI (in SwiftUI)
- Accessing the shared data
- And how to close your SwiftUI view (this is surprisingly hard!)
Great work, and i f you want to see this in action, you should check out Henri's app Thoughts (an Inspiration Manager)!
Tools
AspirinShot: Painless App Store screenshots with SwiftUI, in Xcode
When working on the Building Reusable SwiftUI Components tutorial, I had to create a large amount of screenshots for each of the different states of the code.
Usually, I'd have to run the app, navigate to the respective screen, and then take a screenshot - both for light and dark mode. As you might imagine, this is rather cumbersome, as I'd essentially have to do this for every single line added to the code.
Luckily, I found AspirinShot by Arnoud Joubay a while ago - it's a tool for creating beautiful screenshots for the App Store. Its original use case is slightly different than mine - it allows you to specify a backdrop, add labels, etc. But it turned out that it is flexible enough to be configured for taking exactly the kind of screenshot I needed for my tutorials.
So, no matter if you're creating DocC tutorials, or need to produce marketing screenshots for the App Store, give it a try!
Design
The secret formula for Apple's rounded corners
There is a reason why we all love rounded corners (more about this in the linked article), and what could be even better than a rounded rectangle? Yes - that's right - nested rounded rectangles! There everywhere: on buttons, in dialogs, even the hardware you use everyday likely has nested rounded rectangles.
This week, I saw a lot of posts in which people explained how to compute the correct corner radius for nesting rounded rectangles, and if you're anything like me, you will have seen enough of those posts on Twitter to know that the formula for for the corner radius of the inner rectangle is outerRadius - gap = innerRadius
.
There are plenty of articles about this design principle as well, such as this, this, or this one from 2013.
Arun went a step further and analysed the The secret formula for Apple's rounded corners. It's a fascinating, and well-designed piece of art, and I encourage every owner of an Apple device to read it.
Podcasts
The Apollo Guidance Computer 1202 Alarm
If you've listened to the 13 Minutes to the Moon podcast, you might know what the infamous 1202 alarm of the Apollo Guidance Computer is about.
But no matter if you do or if you don't, I would encourage you to watch this amazing talk by Robert Wills: Light Years Ahead. It is not just about the Apollo Guidance Computer and the nerve-racking final couple of seconds before the landing on the moon - it's also a tale about software engineering, and how the six design principles employed by the team around Margaret Hamilton) to make sure the computer wouldn't fail the mission:
- Use a high-level language
- Divide your system into jobs
- Restart on failure
- Checkpoint good state
- Hardware monitors the software
- Send telemetry
BTW - the source code for the ACG is available on GitHub.
Google IDX - VS Code in the Browser with David East — Syntax Podcast 676
My colleague David East recently was a guest on the Syntax.fm podcast to talk about IDX, Google's cloud-based IDE.
Worth a listen to get the low-down on Google's cloud IDE, and some behind-the-scenes insights!
Comment
Hi everyone!
This past week, I've had the opportunity to participate in one of my favourite iOS/Swift conferences - Swift Leeds! If you were one of the people who looked for me and didn't spot me, here is why: I used one of the SwiftLeeds Live tickets, and joined via the live stream (I might have scrubbed back to watch some of the talks after hours, but ... sssshhh - don't tell Adam!).
Anyway, it was a great experience, and loved that there were many new speakers (some of them even first-time speakers)! The team mentioned they're going to publish videos of the talks in the coming weeks, and I can wholeheartedly recommend setting aside some time for watching them.
Meanwhile, Mikaela and Paul are planning to record another episode of Swift over Coffee, and have reached out to the community for input to the question "should you be using Swift everywhere, or is it better to learn other languages, too"? There was a wide spectrum of answers, and it'll be interesting to see what Paul's and Mikaela's opinion is.
Sindre (who certainly can't be blamed for putting all his eggs in one basket - language-wise) seems to be convinced that Swift is the future of AI.
By the way, if you're interested in using Swift in Cloud Functions for Firebase, check out this Uservoice poll, and make your voice be heard.
Thanks for reading! I always love hearing from you, so if you've got any feedback (or suggestions!) just hit that reply button and let me hear your thoughts!
Peter