Replies: 1 comment 1 reply
-
Hi @jaredh159, making SwiftUI an opt-in dependency is definitely a goal of TCA, but it is going to take awhile to get there. However, I'm not entirely sure I understand your problem fully, because SwiftUI and Combine are both supported in macOS 10.15. There may be something much simpler happening in your project. Can you try creating a macOS 10.15 project from scratch that reproduces the problem so that we can see what the issue is? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
i'm (re)building a macOS app that is a menu-bar background utility that is also a host for a system network extension.
i'm a huge fan of TCA, and am using it for both the menu bar app, and the system extension (which runs as root) which it hosts. i'm also using
swift-dependencies
to model the communication between the app and the extension, over XPC. furthermore, i'm targeting 4 versions of macOS, going back to10.15
.i fully realize all of this puts me way out of the mainstream, normal, happy path for TCA.
my question has to do with TCA's implicit dependency on SwiftUI. i have zero SwiftUI usage in my entire app. that's mostly because, as I mentioned, i'm targeting 4 versions of macOS, and anyone who has done SwiftUI in production on macOS can testify to the fact that it has severely lagged behind iOS, and been inconsistent and buggy across major macOS versions. trying to write SwiftUI that works well from Catalina thru Venture is incredibly difficult, and almost impossible to test without having a VM or dual-boot for every version of the OS. what's more, my app is a background utility (
LSUIElement
) app, so it has very little UI anyway, mostly it stays out of the user's way, and is only intermittently interacted with, while it does it's job in the background.but beyond the app, the root-user system extension which the app installs is also running TCA. that may seem odd, but TCA is actually an incredibly great fit to tame this use case. the system extension lives forever, has to manage multiple background concerns over time, recover from error states, communicate with user processes, make logic decisions based on a set of rules, etc. having this all testable inside a reducer with actions, publishers, long-lived effects, timers, and being able to control time and dependencies and use all of TCA's test store features has been amazing.
however, i do get os-level errors in my
Console.app
when the root system extension launches, having to do with SwiftUI. the os (rightly) seems to think it's odd that my extension with zero UI is (transitively) depending on SwiftUI.so far, it seems like these errors aren't causing any actual problems, but it got me thinking about TCA and whether you guys had ever thought about making the SwiftUI dependency opt-in. it feels weird that SwiftUI is coming along for the ride in my app, when I don't use it at all, and especially so in a context where it can't be used, and there is no possibility of having any UI (in the system extension).
i recognize that you guys have put a ton of work into all of the SwiftUI helpers and integration, and that probably the vast majority of your users are using SwiftUI, and I imagine it's super convenient to just make it a transitive dependency. i don't fault you for it at all. but i'm wondering if the architecture of TCA would ever allow SwiftUI to be not included transitively, and then library consumers could explicitly pull in modules like your SwiftUI Navigation module, if they wanted to use SwiftUI. is that something you've discussed, or are open to? or would it just be too deep of a change for too few users in my situation?
also, i may be misunderstanding the errors, and exactly in what sense SwiftUI is a transitive dependency.
fwiw, i'm working with the 1.0 pre-release branch for now (though i'm a couple months from shipping the re-write to production, so i'm pretty confident i'll be depending on a non-beta version of TCA before this goes into production).
thanks for all the great libraries, every swift project i make has a laundry list of pointfree dependencies. :)
Beta Was this translation helpful? Give feedback.
All reactions