Hey, guys. In this lesson, we're gonna be taking a look at one of the other big announcement at WWDC 1
in 2019 which is Project Catalyst. 2
Now, Project Catalyst used to have the codename of Marzipan which is where you might have heard of it 3
on blog posts and on the internet. 4
But the idea is that there are so many iOS developers making wonderful iOS apps that work on the iPhone 5
and the iPad. But the Mac App Store is a little bit lonelier. 6
So why not bring UIKit which is the big framework that lets us build iOS apps and bring it over to 7
the Mac? 8
So this way you should be able to simply check a tick box in Xcode and be able to create a macOS 9
app from your iOS apps that you've already developed, and be able to run it as a Mac app. So that's what 10
I want to show you in this lesson. 11
So let's get started. 12
Now, I'm going to take the Hacker News app that we developed in the last lesson and I'm going to turn it 13
into a Mac app. 14
And the first step is we have to go to the settings of the app. So clicking on the Hacker News' 15
blue icon project in the file inspector, and then going to the targets in this left-hand side pane. 16
And now we're going to click this magical checkbox, and as it notes here, you have to be on the latest version 17
of macOS Catalina 18
for this to actually work. 19
So let's click on this and go ahead and click Enable. 20
And now we have to go to our signing and capabilities because whenever we want to deploy an app to a 21
physical device such as an iPhone and iPad, or in this case, our Mac, we have to provide a signing certificates. 22
So go ahead and sign in with your Apple ID 23
and you should now be able to select your team in the team dropdown list. 24
So, now that I've signed my app and I've checked off my Mac capabilities and the Mac has been selected 25
as the target up here, I can go ahead and click Run. 26
And here it is. 27
Here's what it would look like on the larger screen size of a Mac app. 28
I've got all of my news pieces loaded up on the left here. 29
And if I click on one of them, it brings it over to the DetailView on the right-hand side here. 30
And once it loads up, you can see that I've got my web view showing the actual article. 31
So pretty neat, huh? 32
Now, if you're wondering if this is only possible for apps built with SwiftUI, fear not, it's not. 33
Underlying mechanism actually relies on UIKit and it's through porting UIKit over to the Mac that 34
allows us to run and build our iOS apps onto the Mac. 35
So here, I've got the claim a project that we created a little while ago and I'm going to show you that 36
we can do exactly the same thing. 37
So, again, I'm gonna check off the Mac tick box. Click enable, click signing and capabilities to select 38
my development team, 39
and now I'm going to click on Run. 40
and once it runs, as long as you've still got all of your constraints set up properly, it should try and 41
fill the screen even though it is a different size and aspect ratio, so you can adjust your window as 42
much as you like, and you can see that we've got our Clima app and our Clima apps menu, such as File, 43
Edit, Format, although none of these things really do vary much in our app at the moment. But you can see 44
that if I search for the weather in Paris and hit enter, it will automatically change and update our 45
weather. Still using all of the underlying capabilities that we built with UIKit. And you can even see 46
that it's put at the app icon into the dark using that same icon that we've provided for iOS as the 47
macOS app icon. So this is a really cool piece of technology because it makes it so easy for us to build 48
apps for iPhone, iPad, and the Mac, or just using a couple of checkboxes. 49
So I hope you enjoyed working with SwiftUI and learning from these lessons. As new things come out, 50
I'll update the code and notify you guys about any breaking changes. But that's all for me in this lesson, 51
and thanks for coming along with me on this ride. 52
I'll see you on the next lesson.