{"id":25484,"date":"2019-06-03T16:39:34","date_gmt":"2019-06-03T20:39:34","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=25484"},"modified":"2019-10-13T13:39:59","modified_gmt":"2019-10-13T17:39:59","slug":"swiftui-and-combine","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/06\/03\/swiftui-and-combine\/","title":{"rendered":"SwiftUI and Combine"},"content":{"rendered":"<p><a href=\"https:\/\/developer.apple.com\/xcode\/swiftui\/\">SwiftUI<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/xcode\/swiftui\/\">\n<p>SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. Build user interfaces for any Apple device using just one set of tools and APIs. With a declarative Swift syntax that&rsquo;s easy to read and natural to write, SwiftUI works seamlessly with new Xcode design tools to keep your code and design perfectly in sync. Automatic support for Dynamic Type, Dark Mode, localization, and accessibility means your first line of SwiftUI code is already the most powerful UI code you&rsquo;ve ever written.<\/p>\n<\/blockquote>\n<p>I guess this is project Amber. I don&rsquo;t know the details well enough to say much yet. But I think building UIs in code with a functional\/declarative style is fundamentally the right approach. The code snippets look similar to (but better than) the newer UI code I&rsquo;ve been writing using my own layer on top of AppKit.<\/p>\n\n<blockquote cite=\"https:\/\/developer.apple.com\/xcode\/swiftui\/\"><p>As you work in the design canvas, everything you edit is completely in sync with the code in the adjoining editor. Code is instantly visible as a preview as you type, and any change you make to that preview immediately appears in your code. Xcode recompiles your changes instantly and inserts them into a running version of your app, visible and editable at all times.<\/p>\n<p>The Swift compiler and runtime are fully embedded throughout Xcode, so your app is constantly being built and run. The design canvas you see isn&rsquo;t just an approximation of your user interface &mdash; it&rsquo;s your live app. And Xcode can swap edited code directly in your live app with &ldquo;dynamic replacement&rdquo;, a new feature in Swift.<\/p><\/blockquote>\n\n<p>At first I thought SwiftUI was a wrapper layer on top of AppKit and UIKit.<\/p>\n\n<p><a href=\"https:\/\/twitter.com\/RJ_Clegg\/status\/1135631835009028096\">Robert Clegg<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/RJ_Clegg\/status\/1135631835009028096\">\n<p>It really isn&rsquo;t. It&rsquo;s built from the ground up and is all Swift code.<\/p>\n<\/blockquote>\n\n<p>If so, this is really interesting as it introduces a separate UI stack and really makes Objective-C a second-class citizen. But it is also a chance to have a unified framework that can apparently coexist with legacy views in the same window.<\/p>\n\n<p><a href=\"https:\/\/twitter.com\/nnnnnnnn\/status\/1135632048478085121\">Nate Cook<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/nnnnnnnn\/status\/1135632048478085121\">\n<p>SwiftUI works great with UIKit, AppKit, and more! This tutorial shows how you can host SwiftUI views inside view controllers, and then embed those view controllers in SwiftUI<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/_jackhl\/status\/1135633040347000832\">Jack Lawrence<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/_jackhl\/status\/1135633040347000832\">\n<p>Remember all those awesome UX #WWDC talks about interruptible animations, and how they make your app feel far more responsive? Getting it right used to be incredibly hard. #SwiftUI does it all for you with One. Line. Of. Code.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/documentation\/combine\">Combine<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/documentation\/combine\">\n<p>The Combine framework provides a declarative Swift API for processing values over time. These values can represent user interface events, network responses, scheduled events, and many other kinds of asynchronous data. Combine declares <em>publishers<\/em> to expose values that can change over time, and <em>subscribers<\/em> to receive those values from the publishers. <\/p>\n<\/blockquote>\n\n<p>This is Apple&rsquo;s reactive framework (finally) and the successor to Cocoa Bindings and KVO.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/06\/03\/final-marzipan-thoughts-before-wwdc-2019\/\">Final Marzipan Thoughts Before WWDC 2019<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/11\/02\/developing-an-ios-app-in-2018\/\">Developing an iOS App in 2018<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2017\/03\/14\/rxnot\/\">RxNot<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2016\/12\/22\/cwlsignal-and-reactive-programming\/\">CwlSignal and Reactive Programming<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2016\/10\/18\/working-without-a-nib\/\">Working Without a Nib<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2014\/03\/16\/the-siren-call-of-kvo-and-cocoa-bindings\/\">The Siren Call of KVO and (Cocoa) Bindings<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2013\/08\/28\/principles-of-reactive-programming\/\">Principles of Reactive Programming<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2013\/02\/16\/reactivecocoa-explanation\/\">ReactiveCocoa Explanation<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2012\/05\/06\/reactivecocoa\/\">ReactiveCocoa<\/a><\/li>\n<\/ul>\n\n<p id=\"swiftui-and-combine-update-2019-06-04\">Update (2019-06-04): <a href=\"https:\/\/twitter.com\/jckarter\/status\/1135677921014628352\">Joe Groff<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jckarter\/status\/1135677921014628352\">\n<p>Some things wrap UI\/NS views, but whether they do, and what view type they wrap, is subject to change. Best to think about it as a distinct thing<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jckarter\/status\/1135643412336500737\">Joe Groff<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jckarter\/status\/1135643412336500737\">\n<p>SwiftUI controls have layers that are managed directly by the framework; there are APIs for embedding an NS\/UIView in SwiftUI and vice versa. Performance was a top priority, it&rsquo;s good<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jckarter\/status\/1135685866062397445\">Joe Groff<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jckarter\/status\/1135685866062397445\"><p>Any transform that can change visibility or structure gets represented by a generic wrapper in Swift, so it&rsquo;s known that opacity\/scale\/rotation\/etc. can change, when content can have variable numbers of nodes, etc. Only the variable cases need &ldquo;ids&rdquo; for diffing<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/Freerunnering\/status\/1135665375641833476\">Kyle Howells<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/Freerunnering\/status\/1135665375641833476\">\n<p>You don&rsquo;t build an entirely brand new UI framework from scratch if you intend the other to be around long term.<\/p>\n<p>Best case you reimplement everything twice in both frameworks forever, or they diverge and you get diff behaviours in each over time (like adding swipe to delete).<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/aligatr\/status\/1135643903053447168\">Olivier Halligon<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/aligatr\/status\/1135643903053447168\">\n<p>Sooo... <a href=\"https:\/\/github.com\/apple\/swift-evolution\/pull\/1046\/files\">This<\/a> is what&rsquo;s likely behind that strange SwiftUI! &#x1F575;&#xFE0F;&#x200D;&#x2642;&#xFE0F;\n(you know, with no commas and still an if statement inside that StackV)<\/p>\n<\/blockquote>\n\n<p>There&rsquo;s now a <a href=\"https:\/\/forums.swift.org\/t\/important-evolution-discussion-of-the-new-dsl-feature-behind-swiftui\/25168\">forum thread<\/a>.<\/p>\n\n<p><a href=\"https:\/\/twitter.com\/Catfish_Man\/status\/1135636630155350016\">David Smith<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/Catfish_Man\/status\/1135636630155350016\">\n<p>Let&rsquo;s see, names this project has had&#8230;<\/p>\n<p>Pipelines<br \/>\nDataflows<br \/>\nKVO2<br \/>\nPubSub<br \/>\nCombine<\/p>\n<p>am I forgetting any? &#x1F602;<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/simjp\/status\/1135651358256664576\">JP Simard<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/simjp\/status\/1135651358256664576\">\n<p>I&rsquo;m assuming the SwiftUI <code>@State<\/code> keywords are @dgregor79&rsquo;s <a href=\"https:\/\/forums.swift.org\/t\/pitch-3-property-wrappers-formerly-known-as-property-delegates\/24961\">Property Wrappers<\/a> currently being pitched in the Swift Forums.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/danielpunkass\/status\/1135695221558169600\">Daniel Jalkut<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/danielpunkass\/status\/1135695221558169600\">\n<p>If you were lost when Apple used $ in $variableNames during coding demos, it comes from <a href=\"https:\/\/github.com\/DougGregor\/swift-evolution\/blob\/property-wrappers\/proposals\/0258-property-wrappers.md\">this addition to Swift<\/a>.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/UINT_MIN\/status\/1135643392912658432\">Jordan Rose<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/UINT_MIN\/status\/1135643392912658432\">\n<p>Yeah, it has too many system components to backwards-deploy, sorry. But it supports all the usual weak-linking \/ availability stuff, so if you want to mix-and-match for new views in existing apps you do have that option.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jnadeau\/status\/1135662536836165633\">Jeff Nadeau<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jnadeau\/status\/1135662536836165633\">\n<p>Localized by default. In fact, if you want to display un-localized text from model data or internet sources, you use the <code>Text(verbatim:)<\/code> initializer instead.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/Freerunnering\/status\/1135662766960906241\">Kyle Howells<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/Freerunnering\/status\/1135662766960906241\">\n<p>I&rsquo;m actually incredibly disappointed that SwiftUI seems to be a new UI framework, not written on top of UIKit.<\/p>\n<p>Declarative UI frameworks are great for simple straight forward UIs that fully their preconceptions. But if you want to violate those they are a massive pain!<\/p>\n<p>If it was built on top of a normal imperative UI framework you could drop down to the real power of a normal framework instead of dancing through hundreds of hoops to make it work.<\/p>\n<p>I&rsquo;m fearful this will regress iOS UI into more bland plain simple UIs even further than iOS7.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/nibroc\/status\/1135730998035881984\">Corbin Dunn<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/nibroc\/status\/1135730998035881984\">\n<p>I also worry about customizability.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jnadeau\/status\/1135732764861317120\">Jeff Nadeau<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jnadeau\/status\/1135732764861317120\">\n<p>Most things are customizable (or will be when API lands). The controls do some indirection through a Style type that lets you implement whatever appearance and behaviors you want.<\/p>\n<p>It&rsquo;s just a matter of getting to everything since there are so many widgets on the Mac<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/BalestraPatrick\/status\/1135646425604415488\">Patrick Balestra<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/BalestraPatrick\/status\/1135646425604415488\">\n<p>Creating a brand new project in Xcode 11 doesn&rsquo;t create a Main.storyboard anymore, everything is defined in code.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jckarter\/status\/1135647858667868160\">Joe Groff<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jckarter\/status\/1135647858667868160\">\n<p>One place Swift really helps with performance compared to other Reactish frameworks is the type system. The static subset of the view graph is encoded in the type system, so the runtime knows it can&rsquo;t change and only has to diff the dynamic parts. 120hz update was a P0 goal<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/danielpunkass\/status\/1135957310793109505\">Daniel Jalkut<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/danielpunkass\/status\/1135957310793109505\">\n<p>It&rsquo;s still sinking in for me that Apple effectively deprecated ALL of their UI frameworks yesterday. Mac, iOS, tvOS, and watchOS developers are equally displaced.<\/p>\n<\/blockquote>\n\n<p>See also: <a href=\"https:\/\/news.ycombinator.com\/item?id=20087168\">Hacker News<\/a>.<\/p>\n\n<p><a href=\"https:\/\/twitter.com\/Freerunnering\/status\/1135997592876257285\">Kyle Howells<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/Freerunnering\/status\/1135997592876257285\">\n<p>Two things Swift (and looks like SwiftUI now too) fall down on is lack of understandability\/predictability and reasoning about perfo; and being seemingly simple but having a very steep difficulty curve when you get into the details.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/zhuowei\/status\/1136000624158433280\">Zhuowei Zhang<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/zhuowei\/status\/1136000624158433280\">\n<p>Apple: Swift is a system programming language that can replace C++<br \/>\nAlso Apple: writes new #SwiftUI library in C++<\/p>\n<p>In fairness, most of SwiftUI is written in Swift! It&rsquo;s just the scenegraph that is in C++. I wonder why they did that. Is there an older library that they reused?<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jnadeau\/status\/1135661006561013760\">Jeff Nadeau<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jnadeau\/status\/1135661006561013760\">\n<p>SwiftUI does not require Catalyst (it interfaces with AppKit directly on macOS), but it does work in Catalyst apps if that&rsquo;s what you&rsquo;re building.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/rustyshelf\/status\/1136014386961633280\">Russell Ivanovic<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/rustyshelf\/status\/1136014386961633280\"><p>iOS Devs: &ldquo;ha ha only 10% of Android devices are on the latest OS&rdquo;<\/p><p>Also iOS Devs: &ldquo;I can&rsquo;t touch SwiftUI for another 2 years because I have to support older iOS versions&rdquo;<\/p><p>Android Devs: &ldquo;Oh Google shipped a new framework? I&rsquo;ll update my AndroidX package and start using it today&rdquo;<\/p><\/blockquote>\n\n<p id=\"swiftui-and-combine-update-2019-06-20\">Update (2019-06-20): <a href=\"https:\/\/twitter.com\/jnadeau\/status\/1136143196289765378\">Jeff Nadeau<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jnadeau\/status\/1136143196289765378\">\n<p>A feature of this screen I took from today&rsquo;s Introducing SwiftUI talk, and something I think will be very typical.<\/p>\n<p>Look at the shape of the code: state, var body, and functions. The body is <em>all<\/em> nouns, and then <em>all<\/em> of the verbs follow in separate functions.<\/p>\n<p>Personally I think this separation is wonderful. It keeps the event-reactive code out of the DSL and very cleanly demarcates &ldquo;deciding what to show&rdquo; vs &ldquo;deciding what to do&rdquo;.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/56450804\/order-of-modifiers-in-swiftui-view-impacts-view-appearance\/56455155#56455155\">Rob Mayoff<\/a>:<\/p>\n<blockquote cite=\"https:\/\/stackoverflow.com\/questions\/56450804\/order-of-modifiers-in-swiftui-view-impacts-view-appearance\/56455155#56455155\">\n<p>Order of modifiers in SwiftUI view impacts view appearance<\/p>\n<p>[&#8230;]<\/p>\n<p>It is better not to think of the modifiers as modifying the <code>MapView<\/code>. Instead, think of <code>MapView().edgesIgnoringSafeArea(.top)<\/code> as returning a <code>SafeAreaIgnoringView<\/code> whose <code>body<\/code> is the <code>MapView<\/code>, and which lays out its body differently depending on whether its own top edge is at the top edge of the safe area. You should think of it that way because that is what it actually does.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/schwa\/status\/1136498361110896641\">Jonathan Wight<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/schwa\/status\/1136498361110896641\">\n<p>Quick example.<\/p>\n<p>This is <code>NSOutlineView<\/code> uses a SwiftUI <code>HStack<\/code> (or rather many&#8230;) for each row.<\/p>\n<p>The (unoptimised, in need of a refactor) method for outlineView(viewFor:item:) is shown.<\/p>\n<p>I think this code plays to both Cocoa&rsquo;s <em>and<\/em> SwiftUI&rsquo;s strengths<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/mecid.github.io\/2019\/06\/05\/swiftui-making-real-world-app\/\">Majid<\/a>:<\/p>\n<blockquote cite=\"https:\/\/mecid.github.io\/2019\/06\/05\/swiftui-making-real-world-app\/\">\n<p>I will try to show you real-world app example written entirely in SwiftUI. Let&rsquo;s build an app searching for Github repos. We need a screen with a text field for typing a query and a list of repos which comes from the search query.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/wwdcbysundell.com\/2019\/swiftui-first-look\/\">John Sundell<\/a>:<\/p>\n<blockquote cite=\"https:\/\/wwdcbysundell.com\/2019\/swiftui-first-look\/\">\n<p>Declarative UI programming patterns have become incredibly popular over the last few years. On the web with frameworks like React and Vue.js, in cross-platform development environments like React Native and Flutter, and through native tools like RxSwift and RxCocoa &mdash; declarative UIs and the reactive principles behind them have truly taken many development communities by storm.<\/p>\n<p>It&rsquo;s therefore especially exciting to see Apple step into this scene, with their own, completely native declarative UI framework &mdash; called SwiftUI. While there&rsquo;s a ton of functionality to be discovered and experimented with in this new UI framework for all of Apple&rsquo;s platforms &mdash; let&rsquo;s start by taking a first look at some of the fundamentals of SwiftUI, and how it lets us drastically reduce the amount of code needed to produce common forms of UIs and interactions.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/ruiper.es\/2019\/06\/07\/swiftui_and_combine\/\">Rui Peres<\/a>:<\/p>\n<blockquote cite=\"https:\/\/ruiper.es\/2019\/06\/07\/swiftui_and_combine\/\">\n<p>First, how I feel as a developer and as a person that has dedicated a tremendous amount of time to FRP* (both as a dev, contributor and evangelist). The release of <code>Combine<\/code> is the realization that the investment I have been making all these years made sense and it's also the confirmation that the industry is moving on this particular direction.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/sharplet\/status\/1138912087319691264\">Adam Sharp<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/sharplet\/status\/1138912087319691264\">\n<p>Combine has very different thread safety guarantees than I&rsquo;m used to coming from ReactiveSwift, which goes to heroic effort to ensure that events are always delivered serially, and never recursively.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/wwdcbysundell.com\/2019\/swiftui-relationship-to-uikit-appkit\/\">John Sundell<\/a>:<\/p>\n<blockquote cite=\"https:\/\/wwdcbysundell.com\/2019\/swiftui-relationship-to-uikit-appkit\/\">\n<p>While it&rsquo;s quite easy to initially look at SwiftUI as just a declarative API written right on top of UIKit (and in some ways <em>it is<\/em>), it&rsquo;s so much bigger than that. While it&rsquo;s true that, at the end of the day, any SwiftUI view hierarchy will get resolved into <em>some form<\/em> of UIKit\/AppKit\/CoreAnimation representation &mdash; there&rsquo;s not a simple 1-to-1 mapping going on here.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/DaveAbrahams\/status\/1136303023242612736\">Dave Abrahams<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/DaveAbrahams\/status\/1136303023242612736\">\n<p>SwiftUI layout isn&rsquo;t a constraint system&mdash;or you could say we just have one-way constraints between parents and children.  Most of the time, that&rsquo;s enough, but if you need generalized constraints you can bridge views to UIKit and use autolayout.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jckarter\/status\/1136032973961039872\">Joe Groff<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jckarter\/status\/1136032973961039872\">\n<p>The eventual goal is to allow all your UI code to be done in SwiftUI. Whether and how things map to UIViews is subject to change<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/danielpunkass\/status\/1137516709978550272\">Daniel Jalkut<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/danielpunkass\/status\/1137516709978550272\">\n<p>I&rsquo;m going to throw some more worms into this compost bin. Another huge &ldquo;mind blown&rdquo; realization I had (with help) today: SwiftUI means &ldquo;views&rdquo; are essentially free. Zero overhead. Declarative UI is as cheap as any other struct. Huge shift from UIView, even more from NSView.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/medium.com\/gett-engineering\/rxswift-to-apples-combine-cheat-sheet-e9ce32b14c5b\">Shai Mishali<\/a>:<\/p>\n<blockquote cite=\"https:\/\/medium.com\/gett-engineering\/rxswift-to-apples-combine-cheat-sheet-e9ce32b14c5b\">\n<p>Myself, and Gett, are heavy users of RxSwift&#x200A;&mdash;&#x200A;so as part of my learning process, I&rsquo;m trying to make a map of things that correlate directly between RxSwift and Combine.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/www.caseyliss.com\/2019\/6\/17\/combine-wheres-the-beef\">Casey Liss<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.caseyliss.com\/2019\/6\/17\/combine-wheres-the-beef\">\n<p>In order to discuss a Combine, one has to discuss the main differences between it and RxSwift. To my eyes: there are three.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/cocoawithlove\/status\/1140368436146495488\">Matt Gallagher<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/cocoawithlove\/status\/1140368436146495488\">\n<p>Apple&rsquo;s Combine talk at WWDC didn&rsquo;t mention &ldquo;reactive programming&rdquo; or any background to the field. When presenting functions with the same interface as standard reactive transforms they said &ldquo;we&rsquo;ve designed&rdquo;. It was the most blinkered, isolationist talk I&rsquo;ve seen.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/swiftrocks.com\/inside-swiftui-compiler-magic.html\">Bruno Rocha<\/a>:<\/p>\n<blockquote cite=\"https:\/\/swiftrocks.com\/inside-swiftui-compiler-magic.html\">\n<p>The new Swift features that are spawning out it are also game changing, and I for one am ready for the addition of new compiler black magics into Swift.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/chriseidhof\/status\/1136951603062300673\">Chris Eidhof<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/chriseidhof\/status\/1136951603062300673\">\n<p>SwiftUI still seems to be full of bugs, making it hard to learn. You don&rsquo;t know if it&rsquo;s you making a mistake, or the implementation. Here&rsquo;s another one[&#8230;]<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/ericlewis\/status\/1137746497309745152\">Eric Lewis<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/ericlewis\/status\/1137746497309745152\">\n<p>There is so many gotchas in SwiftUI. Especially around lists.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/wilshipley\/status\/1136762655841013760\">Wil Shipley<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/wilshipley\/status\/1136762655841013760\">\n<p>The other (real) complaint is there&rsquo;s no good reason this was secret. It&rsquo;s not like Apple just invented reactive programming. This could have been done with community input.<\/p>\n<p>Apple&rsquo;s making this common mistake where they&rsquo;re like, &ldquo;Oh boy, we created something amazing with help from a huge community working together &mdash; now we should add our own private surprise stuff because surely we know better than everyone else in the whole world combined.&rdquo;<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/inessential.com\/2019\/06\/07\/wwdc_2019_first_words_which_i_may_end_up\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"https:\/\/inessential.com\/2019\/06\/07\/wwdc_2019_first_words_which_i_may_end_up\">\n<p>The future of app-making looks more and more like web development. Declarative. Semantic. Dynamic &mdash; adapting to context (interaction styles, accessibility settings, screen size, etc.). Runtime-editable.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/apontious\/status\/1137504696120225792\">Andrew Pontious<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/apontious\/status\/1137504696120225792\">\n<p>I&rsquo;ve never seen an abstraction layer high enough up to make cross-platform apps work well enough to be something I&rsquo;d like to use for native apps.<\/p>\n<p>Everyone keeps trying to reinvent the web, but for native, this time.<\/p>\n<p>But the web exists for a reason. It was supposed to give us cross platform functionality <em>without<\/em> being native. And it works!<\/p><p>[&#8230;]<\/p>\n<p>Apple fought cross-platform layers for so many years! And we cheered along with them!<\/p>\n<p>And now, suddenly, due to their own strategic moves, they have too many platforms to develop for individually.<\/p>\n<p>Same problem they brushed aside when it was only <em>our<\/em> problem!<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/pfandrade_\/status\/1137118634080423936\">Paulo Andrade<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/pfandrade_\/status\/1137118634080423936\">\n<p>While I&rsquo;m very excited about SwiftUI, this type of stuff is what scares me most about letting the framework &ldquo;do the right thing&rdquo;. Sometimes you might want a slightly different behavior than what the framework does and you&rsquo;re down the rabbit hole trying to make that happen.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/chockenberry\/status\/1137471981245194240\">Craig Hockenberry<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/chockenberry\/status\/1137471981245194240\">\n<p>This is exactly why I think Apple has a HUGE advantage over other systems. Their solution must adapt for interaction sizes as small as a watch face and as large as a TV screen. That requirement means it must be control independent, thereby allowing a native platform feel.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/inessential.com\/2019\/06\/08\/putting_my_world_back_together\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"https:\/\/inessential.com\/2019\/06\/08\/putting_my_world_back_together\">\n<p>I have not watched WWDC videos so avidly, and with so much glee, in a decade.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/inessential.com\/2019\/06\/07\/the_next_era_ends_the_swift_era_begins\">Brent Simmons<\/a>:<\/p>\n<blockquote cite=\"https:\/\/inessential.com\/2019\/06\/07\/the_next_era_ends_the_swift_era_begins\">\n<p>I&rsquo;m surely not the only person to think, all week long, that this WWDC marks the end of Apple&rsquo;s NeXT era and the beginning of the Swift era.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/www.cocoawithlove.com\/blog\/swiftui.html\">Matt Gallagher<\/a> (<a href=\"https:\/\/twitter.com\/cocoawithlove\/status\/1137573437935738880\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/www.cocoawithlove.com\/blog\/swiftui.html\"><p>This article will look at how SwiftUI&rsquo;s approach to declarative views compares to CwlViews, why the two approaches differ and what Apple changed to make this possible.<\/p>\n<p>[&#8230;]<\/p>\n<p>Long term, SwiftUI will be good but it&rsquo;s going to be years of transition before most projects have a minimum deployment target of iOS 13 or macOS 10.15. As with the first year or two of Swift development, I expect a lot of hastily started, poorly implemented and quickly forgotten projects. The SwiftUI implementation, its API and associated tooling are likely to change rapidly as serious bugs and gaping holes are patched.<\/p><\/blockquote>\n\n<p><a href=\"http:\/\/www.colincornaby.me\/2019\/06\/transitions\/\">Colin Cornaby<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.colincornaby.me\/2019\/06\/transitions\/\">\n<p>SwiftUI is amazing because it doesn&rsquo;t feel like there are any losers. It makes the Mac better. It makes the iPad better. It makes the iPhone better. Heck, it even makes the Apple Watch and Apple TV better. I&rsquo;m thinking about ways to ship apps for the TV and Watch, and I never would have considered that before. I even have Mac apps I might bring to iPad. I didn&rsquo;t want to give up the power of AppKit on the Mac, and I didn&rsquo;t want to maintain two separate code bases. Now I don&rsquo;t have to choose.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/chockenberry\/status\/1138112835697819648\">Craig Hockenberry<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/chockenberry\/status\/1138112835697819648\">\n<p>Something I haven&rsquo;t seen discussed: how size classes will be handled in SwiftUI.<\/p>\n<p>I realize it&rsquo;s still early days, but this is a pretty important aspect of devices like the iPad, where screen real estate varies widely.<\/p>\n<p>&ldquo;Just add some conditional logic&rdquo; hurts the abstraction.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/stroughtonsmith\/status\/1138150974349021189\">Steve Troughton-Smith<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/stroughtonsmith\/status\/1138150974349021189\">\n<p>SwiftUI is really great for AppKit developers because it does give them a path forward that is cross-platform and isn&rsquo;t &lsquo;port to UIKit&rsquo;. But I don&rsquo;t see SwiftUI currently capable of replacing complex AppKit-specific Mac UI any more than UIKit; that could be some years out<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/ericasadun.com\/2019\/06\/07\/swiftui-embracing-the-nonobvious\/\">Erica Sadun<\/a>:<\/p>\n<blockquote cite=\"https:\/\/ericasadun.com\/2019\/06\/07\/swiftui-embracing-the-nonobvious\/\">\n<p>In fact, as a developer, I&rsquo;m not happy about not having direct control over the tightness of either layout or an obvious way to relate <code>ZStack<\/code>&nbsp;siblings. If there&rsquo;s a way to describe how much content hugging I want in a <code>ZStack<\/code>&nbsp;layout and how to prioritize which item in that layout should guide the others, I haven&rsquo;t discovered it. If you have, please let me know!<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/furbo.org\/2019\/06\/07\/the-future-of-interaction-part-ii\/\">Craig Hockenberry<\/a>:<\/p>\n<blockquote cite=\"https:\/\/furbo.org\/2019\/06\/07\/the-future-of-interaction-part-ii\/\">\n<p>But I think there&rsquo;s something important to add to his note: the SwiftUI DSL describes the most capable environment. It&rsquo;s the maximum interaction surface: platforms will render and react to a subset of what&rsquo;s declared.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/colincornaby\/status\/1138231159794442240\">Colin Cornaby<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/colincornaby\/status\/1138231159794442240\">\n<p>Are master\/detail editable views a problem in SwiftUI right now? If you have an array of structs, and a detail view that edits one of the structs, there&rsquo;s no way to commit the edit to the master array it seems like.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/rhonabwy.com\/2019\/06\/11\/commodity-and-fashion-with-swiftui\/\">Joe Heck<\/a>:<\/p>\n<blockquote cite=\"https:\/\/rhonabwy.com\/2019\/06\/11\/commodity-and-fashion-with-swiftui\/\">\n<p>Color, Layout, and graphics design are all clearly customizable with SwiftUI. I also expect that some of the crazier innovations (such as the now common &ldquo;pull to refresh&rdquo; gesture) will become significantly harder to enable from declarative structures. By its very nature, the declarative structure will make the common, well established UI elements easy and accessible, so much so that I wouldn&rsquo;t be surprised to see a lot of early SwiftUI apps to &ldquo;all look alike&rdquo;. I expect the impact of &ldquo;all looking alike&rdquo; to drive a number of IOS dev teams a bit nuts.<\/p>\n<p>The &ldquo;escape hatches&rdquo; to do crazy things clearly do exist &#x2013; and while I haven&rsquo;t reached that level of learning with SwiftUI, it does seem to follow the &ldquo;make easy things simple, and hard things possible&rdquo; concept of progressive disclosure.<\/p>\n<p>It will be interesting to see what happens this fall when the first SwiftUI apps become available as experiments and where that takes consistency and usability on the Apple platforms.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/NSExceptional\/status\/1138569321435807745\">Tanner Bennett<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/NSExceptional\/status\/1138569321435807745\">\n<p>It seems every single WWDC session on SwiftUI and Combine I&rsquo;ve watched have managed to avoid talk of graceful error handling.<\/p>\n<p>If someone could please point me to some resources on this, I would be very greatful. For example, displaying an alert when refreshing a feed failed.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/drewmccormack\/status\/1138723502960316416\">Drew McCormack<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/drewmccormack\/status\/1138723502960316416\">\n<p>One thing I won&rsquo;t miss is autolayout. Feels like the layout system in SwiftUI is an admission that autolayout was a dead end. It can live out its days with Garbage Collection and Java Cocoa. (Or perhaps it will remain, but only as an implementation detail.)<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/mackuba.eu\/2019\/06\/14\/thoughts-on-swiftui\/\">Kuba Suder<\/a>:<\/p>\n<blockquote cite=\"https:\/\/mackuba.eu\/2019\/06\/14\/thoughts-on-swiftui\/\">\n<p>Prepare to feel like you&rsquo;ve just started learning Mac\/iOS programming&#8230; This is a completely new thing which works in a completely new way, and it&rsquo;s hard to switch your brain to a new mode. You will be thinking &ldquo;How the hell do I do X&rdquo; every step of the way.<\/p>\n<p>[&#8230;]<\/p>\n<p>Long term, I imagine the way it&rsquo;s going to work is that SwiftUI (and possibly some related new frameworks) will gradually take over more and more parts of the underlying platform UI frameworks, to the point where they eventually just disappear. We&rsquo;ll be writing a single codebase with SwiftUI and it will render differently on each platform, with some customizations required for each platform, but it&rsquo;s possible that we&rsquo;ll need less and less of those going forward, as the framework will get smarter.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/jaanus.com\/first-thoughts-on-swiftui\/\">Jaanus Kase<\/a>:<\/p>\n<blockquote cite=\"https:\/\/jaanus.com\/first-thoughts-on-swiftui\/\">\n<p>In the old UIKit\/AppKit world, view controllers were a central building block, and did a lot of manual shuffling between view and model. In the SwiftUI world, the view binds directly to the model, the glue is gone, and I have yet to figure out if there is any &ldquo;logic&rdquo; left which previously lived in ViewControllers and would still need to exist, or can I just forget about the whole ViewController concept.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/_inside\/status\/1141758374285103111\">Guilherme Rambo<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/_inside\/status\/1141758374285103111\">\n<p>So apparently the way Apple found to hide SwiftUI (Amber) from the eyes of curious engineers was to implement it in a framework called &ldquo;TimerSupport&rdquo; lol<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/drewmccormack\/status\/1140581525098045442\">Drew McCormack<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/drewmccormack\/status\/1140581525098045442\">\n<p>Rather than hacking a DSL into the Swift language for SwiftUI, I think I would have preferred they add a data format based on Swift syntax. Like JSON is to JS.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jckarter\/status\/1141763976822476801\">Joe Groff<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jckarter\/status\/1141763976822476801\">\n<p>We&rsquo;d considered this. The problem with that for UI, and historically with nibs, is that if you outgrow what the data language can do, then you&rsquo;re stuck rewriting a programmatic UI. By using code, the DSL, mix regular and DSL code, and also DSL and Kit components<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/github.com\/Juanpe\/About-SwiftUI\">About-SwiftUI<\/a>:<\/p>\n<blockquote cite=\"https:\/\/github.com\/Juanpe\/About-SwiftUI\">\n<p>The goal of this repository is to gather all this information having an unique place where looking for info about SwiftUI.<\/p>\n<\/blockquote>\n\n<p id=\"swiftui-and-combine-update-2019-06-24\">Update (2019-06-24): <a href=\"https:\/\/twitter.com\/mike_p3\/status\/1141718763152146432\">Mike<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/mike_p3\/status\/1141718763152146432\">\n<p>Hmmm, looks like CareKit uses Combine and CoreData as a local database&#8230;\nAnd this project is open-source so you can get a glimpse how to use Combine in the wild!<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/jnadeau\/status\/1143012882281459712\">Jeff Nadeau<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/jnadeau\/status\/1143012882281459712\">\n<p>The SwiftUI <code>Environment<\/code> is extensible, if you want to propagate your own custom values hierarchically. Once you define a property on <code>EnvironmentValues<\/code>, you can push new values using the <code>.environment<\/code> modifier and a <code>KeyPath<\/code> to your property.<\/p>\n<\/blockquote>\n\n<p id=\"swiftui-and-combine-update-2019-10-13\">Update (2019-10-13): <a href=\"https:\/\/twitter.com\/Catfish_Man\/status\/1182653460468006912\">David Smith<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/Catfish_Man\/status\/1182653460468006912\">\n<p>Well, the final version [of Combine] that actually shipped isn&rsquo;t my work, but the original concept is simple enough: make KVO composable, then strip it down to just the most core concept (data streaming) by replacing all the options and parameters with composition.<\/p>\n<p>My first prototype was an alternative to NSFileHandle of all things, but some friends on another team were like &ldquo;you know if you replace all those NSData*s with ids it looks a surprising amount like something we were prototyping, let&rsquo;s join forces&rdquo;.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>SwiftUI: SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. Build user interfaces for any Apple device using just one set of tools and APIs. With a declarative Swift syntax that&rsquo;s easy to read and natural to write, SwiftUI works seamlessly with new Xcode [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2019-06-03T20:39:37Z","apple_news_api_id":"6a8e3690-aa9f-43f6-92da-540e5ae12448","apple_news_api_modified_at":"2019-10-13T17:40:08Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAEA==","apple_news_api_share_url":"https:\/\/apple.news\/Aao42kKqfQ_aS2lQOWuEkSA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[200,1621,69,199,1813,31,1667,275,309,30,1666,71,341,901,1812,1558,1212,226],"class_list":["post-25484","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-autolayout","tag-marzipan","tag-cocoa","tag-bindings","tag-combine-framework","tag-ios","tag-ios-13","tag-keyvalueobserving","tag-localization","tag-mac","tag-macos-10-15","tag-programming","tag-reactivecocoa","tag-swift-programming-language","tag-swiftui","tag-tvos","tag-watchos","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=25484"}],"version-history":[{"count":17,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25484\/revisions"}],"predecessor-version":[{"id":26853,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/25484\/revisions\/26853"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=25484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=25484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=25484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}