Archive for July 6, 2023

Thursday, July 6, 2023

SwiftUI Data Flow 2023

Discover Observation in SwiftUI:

Simplify your SwiftUI data models with Observation. We’ll share how the Observable macro can help you simplify models and improve your app’s performance. Get to know Observation, learn the fundamentals of the macro, and find out how to migrate from ObservableObject to Observable.

Sarah Reichelt:

With the introduction of Swift macros, the SwiftUI team was able to reduce the number of property wrappers need to send data around, and remove a lot of boilerplate code.

For this article, I have re-written my sample app as a Mac app and updated it to use the new data macros.

[…]

Apart from adding some details to the decisions points, there are really only two additions to my chart:

  • If a property doesn’t need to change, it can be a let.
  • @Bindable only works for classes. The equivalent for structs or primitive data types is still @Binding.

[…]

And lastly, in @Observable classes, everything that is NOT private is published. This is the opposite to what we had before where you had to explicItly state which properties were published.

Keith Harrison:

[Observable] has a number of benefits:

  • Simplified data flow, using State and Environment. You no longer need StateObject or EnvironmentObject.
  • Less boiler-plate. No need to annotate properties with @Published or models with @ObservedObject.
  • A view is now only updated when a property it depends on changes not when any change happens to the observable object.
  • You can have arrays of observable models or even observable types that contain other observable types.

Apple has a useful guide on the steps to migrate an ObservableObject to an Observable. To summarise:

Ish Abazz:

In case anyone else runs across this… Using @Observable on a class that has a property that is a closure causes the Xcode beta 3 compiler to flip out. Using @ObservationIgnored on the said property will get the compiler to calm down.

Previously:

Update (2023-07-26): Keith Harrison:

In iOS 17, Apple deprecated the onChange(of:perform) view modifier replacing it with two new variations.

Update (2023-08-10): Natascha Fadeeva:

When it comes to state management in SwiftUI combined with reference types, SwiftUI provides two property wrappers: @StateObject and @ObservedObject. Understanding the difference between them is crucial for building robust SwiftUI applications, as it determines how data is managed and flows through the view hierarchy.

Note: Apple introduced the Observation framework at WWDC23 which will make these two property wrappers obsolete in the future. The knowledge around them is still useful since they are used in many existing applications. The knowledge might also help migrate to new Observation framework.

Update (2023-08-22): Thomas Clement:

Things are getting a bit weird in the swift forums, there’s been a huge amount of feedback in several discussions over several months about missing didSet support in Observability and Apple’s response has been just complete silence.

Update (2024-02-14): Donny Wals:

In this post, we’ll explore the new @Observable macro, we’ll explore how this macro can be used, and how it compares to the old way of doing things with ObservableObject.

Firefox 115’s Two-Tier Extensions System

Vishal Gupta (Hacker News):

If you installed or upgraded to the new Mozilla Firefox 115 or later version and you are getting “Some extensions are not allowed” error message on Extensions panel or flyout (puzzle piece toolbar icon), this article will help you in fixing the issue and enabling the blocked extensions again in Firefox web browser.

[…]

The [error message] is shown by a new feature called “Quarantined Domains”[…]. According to Mozilla team, this new back-end feature has been implemented to only allow some extensions monitored by Mozilla to run on specific websites for various reasons, including security concerns.

[…]

Now double-click on extensions.quarantinedDomains.enabled preference and set its value to false.

Jeff Johnson (Mastodon, Hacker News):

I’m all in favor of giving users control over which extensions are allowed to load on which sites. Safari already has this feature on both macOS and iOS. My concern is not about user control—little of which even exists in Firefox 115, as I’ll show later—but rather about the remote control that Mozilla has now given itself, as mentioned in a Bugzilla report.

[…]

You have to wonder why an open source project required confidentiality about this. Incidentally, neither Safari nor Chrome, or any other browser as far as I know, has such a remote domain-specific kill switch for extensions, so you have to wonder why it was necessary in Firefox.

[…]

I believe that Mozilla already had the capability to remotely disable an individual extension, if it turned out to be malware. […] Given this preexisting capability, it’s unclear why there should be a list of domains where all except a lucky few chosen extensions are disabled, regardless of whether the disabled extensions have shown signs of misbehavior.

Update (2023-07-10): Jeff Johnson:

Mozilla has posted additional information about the quarantined domains feature added in Firefox 115.

Update (2023-07-11): Jeff Johnson:

Note that extensions.webextensions.restrictedDomains and extensions.quarantinedDomains.list are two separate settings in Firefox.

[…]

Thus, it appears that Mozilla introduced a built-in add-on to disable the Brazilian web sites in Firefox version 113, then they moved the same functionality from the add-on into the main app in Firefox version 115.

We still have no information from Mozilla about why most Firefox add-ons, except for a select few add-ons “monitored by Mozilla”, have been disabled on those six Brazilian web sites.

How Ventura Checks the Security of Apps and Tools

Howard Oakley:

When you first run an app that you’ve just downloaded to your Mac from a source that results in it being put into quarantine, the following has occurred[…]

[…]

Some or all of those can also be triggered when a known app, which has already passed its first run tests, is run from a previously unknown path, when it’s put back into quarantine, or when it remains stuck in app translocation.

[…]

One situation where repeated security checks could have significant impact is when repeatedly executing a third-party command tool in a script. […] Provenance tracking thus appears to overcome overhead without compromising security.

Previously:

Affinity Publisher for iPad

Beardy Guy:

In general the app has been very stable and usable in my four months of use. And to be clear, it’s not just usable, it’s smooth and responsive on the M1 iPad, 8GB of memory. Being able to work with touch, Pencil and trackpad is a real pleasure.

[…]

For many iPad users Apple’s Pages app is all that’s needed. That app has also had many features added over the years and is quite capable for laying out documents. I used it for years designing a wide variety of reports, newsletters and brochures. Affinity Publisher is a competitor to Adobe’s InDesign. It will open InDesign IDML files as well as pdfs for conversion to Publisher files.

Unlike Adobe’s various iPad apps, Publisher on iPad is the full app with the full feature set. Should you want to edit a Publisher file shared by someone or share to someone using Publisher on a Mac or Windows, it’s no problem as long as the file will be opened with version 2 of the app on those platforms[…]

[…]

StudioLink, allows me to open up an a vector graphic in Designer or an image in Photo without actually leaving the Publisher app. It’s an amazing feature though it does require that you have all three apps installed to work.

Previously: