Discover and read the best of Twitter Threads about #SwiftUI

Most recents (17)

Hope you had a great week of #WWDC23! 🎉

As a yearly tradition, I wrote a #SessionSummary tweet with my key takeaways for 23 selected sessions covered on @WWDCNotes.

Get a sense of each session & find ones that pique your interest!
And don't forget to share! 🔁

Thread 🧵🧵🧵👇 Image
What's new in Xcode 15:
🚀 Smart code completion
🌈 Image/Color Symbols
💬 Auto-extraction of Strings
🗂️ String catalog + visual editor
⚡ Quick Actions ⇧⌘A
🔖 Bookmark line/query
✏️ Editable Git staging
🧪 Test report redesign
📝 OSLog in console

More: wwdcnotes.com/notes/wwdc23/1… ImageImageImageImage
What’s new in Swift:
🔀 if/else & switch expressions -> concise code
📦 Param Packs overcome API overload limits
🛠️ Macros eliminate boilerplate
⚡ Foundation rewrite -> more performance
🔗 C++ interop, like ObjC
🎭 Actor executors for custom sync

More: wwdcnotes.com/notes/wwdc23/1… ImageImageImageImage
Read 25 tweets
❓How can I change any SF Symbol to have the plus, minus, or any badge on it in #SwiftUI?

You've seen existing symbols with badges (delete, question mark, etc).

But what if the symbol you want to use doesn't have the badge you want? Image
For example, I wanted this symbol with a plus badge: Image
💡You can OVERLAY one symbol on top of another!

For example, I added a smaller plus symbol to the lower right corner: Image
Read 6 tweets
Let's start a thread on my best finding in #SwiftUI for iOS 16 exclusively, as I've used it to write #IceCubesApp
The 1.0 about to get released on the App Store (well if Apple finally decide so) so this is a good time for that thread.

github.com/Dimillian/IceC…
1. .toolbar is more powerful than ever. You can use ToolbarTitleMenu to have a complexe menu right in the title of navigation bar. Don't forget you can also use .toolbar with keyboard placement on TextField for keyboard accessory view. A screenshot of Ice Cubes iOS application showing the toolba
2. .presentationDetents is finally available in #SwiftUI for presenting sheet. You can use medium, large, a fraction of the height of the screen and a totally custom size.
Read 8 tweets
SwiftUI helps make apps faster, and I've started to use it in all my production apps

Here are some #SwiftUI tips I've learned along the way that will help you write better SwiftUI apps ✨✨
✨ There is a strokeBorder method

Some shape like Circle conforms to InsettableShape protocol, which provides strokeBorder method.

The stroke method strokes inside and outside the border.
The strokeBorder insets the stroke by lineWidth / 2 Image
✨ Take advantage of Publisher in Combine

Both State and StateObject attaches to the lifetime identity of a SwiftUI view.

In cases where we need to adjust the stream, I prefer using ObservableObject. Here is how I debounce the Textfield text to perform searching. Image
Read 8 tweets
After working on SwiftUI using MVVM for few years, I am realizing that MVVM may not be the best fit for the job. I may end up writing a post about it but here are few thoughts about my experience.

* If you had success with MVVM and SwiftUI then more power to you!

#SwiftUI
1/N I have written many articles regarding SwiftUI and MVVM, I have written books and even created courses on SwiftUI and MVVM. But each time I implemented a solution in SwiftUI and MVVM I felt not comfortable. The main reason was that I was always fighting the framework.
2/N When you work on a large application using MVVM with SwiftUI and you want to share state then it becomes extremely hard.

The main reason is that you cannot access EnvironmentObject inside the view model. Well, you can pass it using a constructor but then it a pain.
Read 12 tweets
✨✨ SwiftUI tips

Y probably using SwiftUI in iOS 15 by now, here are 10 good practices to make good use of #SwiftUI #iosdev
✨ Take advantage of flexible frames

Sometimes we want to show a button in the corner of the screen and we use VStack, HStack with Spacer.

We can use flexible frame with maxWidth, maxHeight. It is more concise and does not have default spacing like in the stack.
✨ Use overlay with ViewBuilder

Let's say we want to show a star icon to the top right of a book cell.

Before iOS 15, overlay and background modifiers accept only View, so we need to perform logic in Group.

Now we can just specify alignment with content ViewBuilder.
Read 11 tweets
I’m a senior macOS & iOS engineer with:
🖤 12years of Objective-C
🧡 6years of Swift
❤️ 0years of SwiftUI
When I said 0years, it’s 0minutes 🙀🙀🙀

Think it’s time, what are the best resources to start learning? #swiftui
I had a successful way in the past (when moving from Obj-c to Swift) that was to take an idea, and build an app and it worked, so I think I will make an app with SwiftUI 🎉 🎉 🎉
Also, it’s time to give props to people that create content for us. 🙏 thank you @ios_dev_alb for this 👉 iosdevalb.gumroad.com/l/learnandcode…
Read 3 tweets
(1/9) How to make beautiful rounded corners in #SwiftUI, a thread: Image
(2/9) The easiest way to round corners of any SwiftUI view is to add a .cornerRadius modifier.
Here's how it looks like: Swift code: Text(".cor...
(3/9) It's okay at a first glance, but if you look closely, you may notice that it's more like two segments attached to each other rather than a single curve. If you don't see what I mean, try looking at the picture from afar or from the side. Enlarged blue rounded recta...
Read 9 tweets
What are some new things you learn about #SwiftUI lately?

Over the course of making several SwiftUI apps, I've discovered quite a few hidden magic of SwiftUI that are quite fun.

Here are 6 interesting SwiftUI features in View Builder many don't know are even possible 🤯
🤯 View protocol with enum

Struct is not the only way to describe #SwiftUI views. Learn how you can achieve the same thing with just enum
🤯 Conform primitive type to View protocol

You can also conform any value type or primitive type to View protocol

The only requirement View needs is to yield a reasonable body.
Read 7 tweets
Alright, this Saturday we’re going to use Swift Playgrounds on iPad to start a ridiculous todo app: ToDon’t: where we add things to NOT DO to your todo list so that you can cross them off & feel more productive.

#iOSDev #SwiftUI #iPad

1/n
Starting with the little todo bit I made from Core Data in Swift Playgrounds here: cephalopod.studio/blog/build-an-…

2/n
One thing I want to do is use the new SectionedFetchResults from Core Data so that my crossed off items go to a different area. Also made my task.name a non-optional string.

And I added a bit of animation and voila!

3/n
Read 20 tweets
Sensei Monitor is getting very close to a public release. I've reworked the design, fixed all the bugs, and optimised performance as much as I can. I'm finally feeling very happy about the state of this feature. [1/12] #SwiftUI #AppKit
It was well over a year ago that I started working on this feature. The first version was built completely in AppKit, and while the potential was there, working with AppKit grew harder and harder. Complex hierarchies and layout led to performance issues and lots of verbose code.
So I completely scrapped it and started over in SwiftUI. This was incredibly painful. I was new to SwiftUI, and I suffered through months of painful learning before I had anything that was even remotely similar to the functionality I had before.
Read 12 tweets
I've done some #SwiftUI lately for @pushheroapp @PastePalApp , and amazed by how easy and fun it is to make apps. If you want to get into SwiftUI but don't know where to start, here are my recommended resources #iosdev

Thread 👇
1) First thing first is @Apple official guides. Apple has done a stunning job to make SwiftUI tutorials fun and interactive

- Introducing SwiftUI developer.apple.com/tutorials/swif…
- Develop Apps with SwiftUI developer.apple.com/tutorials/app-…
- Creating a macOS App developer.apple.com/tutorials/swif…
2) Next is a mini-series focusing on fundamental blocks which are Stack and ScrollView

- Creating Performant Scrollable Stacks developer.apple.com/documentation/…
- Aligning Views Across Stacks developer.apple.com/documentation/…
- Building Layouts with Stack Views developer.apple.com/documentation/…
Read 18 tweets
Building a Netflix-like app for iOS and iPadOS in #SwiftUI - a thread: Image
Two weeks ago, I wrote about my experience with building a video streaming app for @cineasterna (). The app lets people watch movies for free with their public library card. This thread will discuss how porting that app to a universal #SwiftUI app went.
Just like on tvOS, the iOS and iPadOS app (referred to as iOS from now on) is oriented around four tabs - Discover, All Movies, Search and Profile. If a logged in user has favorites, an additional Favorites tab is added. If no user is logged in, the Profile tab says Login. Image
Read 18 tweets
Fun experiment: since a #swiftui view is just a struct, which is automatically serialisable if its members are, you can — safely! — pull an entire view hierarchy out of JSON. I’m considering using it to communicate with beta testers at some point in the future: Image
Could use HTML instead, but that’s slower to render, less domain-specific. This technique is fully native (fonts, glyphs, dark mode etc), can include custom interactive controls if you want. Can’t send code, only data, so each “item type” needs to be already in the app, but still
It’s simple to extend to support all sorts of layouts/features if you need to, and there’s… like… _nothing_ there — no parsing, almost nothing to write or maintain. Entire demo including test data fits in one screen. Not as general as HTML — but absurd power-to-weight ratio 🙂
Read 3 tweets
Am I right in saying #SwiftUI doesn't really have undo/redo support? It does make an UndoManager available in the Environment, but if you (say) hook up a Toggle, Slider, Picker etc to a binding, it won't support undo/redo and doesn't seem to have any built-in mechanism to do so?
This is my attempt to fill in the gap, but I wouldn't be suprised if there are better ways. If instead of binding a widget to $someItem.someProperty you bind it to UndoableBinding(target: someItem, undoManager: undoManager).someProperty (you can cache this struct & reuse it…) Image
…then undo & redo should work as expected. Surprisingly, sliders don't seem to spam the undo stack with continuous updates, even tho the binding itself updates continuously? This seems to suggest something, somewhere is context-aware, but not sure what...
Read 3 tweets
i'm so bored i started designing a fake stocks app this morning i might build with Swift to learn.

lot of stock apps optimize for density, assume you care about many stocks & require more tapping for basic info. kinda want the opposite: focus on fewer, bigger, one view Image
spent a bit more time today on this. need to figure out:
- stock card anatomy to fit pre/after hours info
- if i want to use Plaid to let people link their brokerage (+ UI to toggle price, positions etc)
- if i want to let people manually enter trades they've done Image
spending this Saturday morning learning how to use Swift Codable to deal with nested JSON using a dynamic key.. not as easy as I thought it would be 😬

Moved a chunk of the code Swift Playground to help debug.. really nice environment with live view and runtime values Image
Read 24 tweets
#swiftkotlin

(Не)-большой тредик о том, какой подход, вероятнее всего, в скором времени приживется в большинстве компаний: от маленьких галер, до больших корпоратов.

Суть подхода заключается в том, что...
#swiftkotlin

Он призван помирить два часто абсолютно зря враждующих друг меж другом лагеря — адептов ведра и овесеров и сплотить их перед единой задачей: написанием единого кода.

Один из его главных плюсов в том, что вкатиться в него проще простого и возможно на любом проекте,
#swiftkotlin

где уже используется swift или kotlin.

Инструментарий и сами подходы к созданию языков дают возможность писать практически полностью интерполируемый друг меж другом код.
Read 41 tweets

Related hashtags

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!