Apr 06, 2020 Create a new Mac project. First you need to launch your XCode. Create a new project. From the menu there, select Create a new Xcode project. This action will pop up a new window. From the new window you need to select the option MacOS and then navigate to the Application panel. From there you can choose the App option.
- Create the Project. The first step is to open Xcode and create a project. Choose File New Project to create a new Xcode project. The New Project Assistant opens. The project is a Mac app so click the macOS button at the top of the window. Select Cocoa App.
- Dec 08, 2016 Jump Right In. Start Developing iOS Apps (Swift) is the perfect starting point for learning to create apps that run on iPhone and iPad. View this set of incremental lessons as a guided introduction to building your first app—including the tools, major concepts, and best practices that will ease your path.
- Swift is a programming language used to write apps and games for iPhone, iPad, Mac, Apple Watch and more; Apple designed Swift explicitly to get the fastest and most efficient performance from.
The Hacking with macOS tutorial series is designed to make it easy for beginners to get started coding for macOS
- Place your own amazing desktop apps into the hands of thousands of people through the Mac App Store
- Become completely proficient with Swift 3 and macOS app development
- You will need a Mac, and Xcode 8 which is a free download from the Mac App Store, and simply a desire to transform your ideas into amazing apps
Description
This course is produced from the “Hacking with macOS” series of tutorials, which are written and authored by the award winning Swift programmer, Paul Hudson, and these videos were made with his permission and support. You can always be guaranteed you’re learning the latest and greatest Apple technologies in the Hacking with Swift tutorials. Here you learn smart, powerful, and expressive Swift 3, the way it was meant to be written. You learn while you make real-world desktop apps, which means you get to apply your new skills immediately and see them work in context. Hacking with Swift is one of the most popular Swift tutorial series online, which uses an approach that teaches you Swift programming incredibly quickly, and you end up with a huge library of finished projects that are yours to develop further, or ship to the Mac App Store.Paul has received high praise from the creator of the Swift language, Chris Lattner, for his outstanding method of teaching, and series of Swift tutorials. And working together with iOS developer Steve DeStefano, the Hacking with Swift series of programming training videos are simply the fastest way to learn how to code in the Apple eco-system.
Check out all of Paul Hudson’s Swift tutorials and books at HackingWithSwift – from beginner to pro, Paul will teach you to write Swift code in very little time.
- Want to learn how to build amazing desktop apps?
- Want to code your own custom buttons for the new MacBook Pro “Touch Bar”?
- This course has all the step by step instruction you need to create awesome apps to submit to the Mac App Store. And the Mac App Store is also a great source of revenue as it only has a fraction of the number of apps that the iOS App Store has, and typically you charge more for a Mac app.
- Building a Mac desktop app uses the exact same Swift 3 language as iOS apps…there are differences of course from iOS, such as the macOS user interface uses windows instead of screens for an iPhone, but if your coming from iOS, the transition is seamless…an example is on iOS we use a UIImageView, and on macOS we use an NSImageView…simple right?.
- If your completely new to coding, don’t worry, we have you covered, as there is also a language section in the course that starts at the very beginning, and covers the complete Swift 3 language.
- The term “Hacking with macOS” means we are “playing” with the Swift language, and using it in unique and interesting ways.
- Desktop apps are fun to build, simply add your own unique creativity, and follow along in the lectures, and before you know it, you’ve created a masterpiece…..how cool is it to have your very own creation right on your prized MacBook Pro, and on thousands of other MacBook Pros?
- This course makes use of annotations, callouts, diagrams, highlighting, and deep explanations that help make complex subject matter, much easier to grasp, and guides you along the path of the code, each step of the way.
- This course also makes the perfect reference tool kit, to be used in conjunction with the Apple docs, so that you can go back and scrub through any of the lectures very quickly to pull out relevant code or instruction that you need, as there’s no wasted chatter here, it’s strictly on point with Swift 3 and macOS.
Some of the topics that will be covered:
- Featuring apps built by the award winning Swift programmer – Paul Hudson – HackingWithSwift dot com
- Build 18 projects – each one teaching a new aspect of macOS
- We use Xcode 8 – The latest version
- The Swift 3 language – we go from variables to creating our own functions and more
- Learn Swift by use of annotations – diagrams – highlighting – callouts
- Touch Bar – code your own custom touch bar buttons and controls
- How to use controls – Outlets and Actions
- Windows – Controllers – Table views
- Split view controllers – Toolbars
- Web views
- Using delegates and protocols
- Work with the social framework – FB – Twitter etc.
- Learn how to refactor code
- The ins and outs of GCD
- SpriteKit and Games
- The new UserDefaults to persist data
- Adding audio – Animations
- Master strings in Swift 3
- Using stackView
- Grid views
- Learn the best debugging techniques
- Auto layout easy and advanced – create constraints using VFL
- Learn how to work with JSON data in swift
- NSUndoManager – Add undo and redo to your apps
- NSDocument
- Bindings – Which let you build apps with very little code
- And a ton more!
- All videos are recorded in HD for maximum resolution and clarity
Swift is the new language of the future, and with this course you will get plenty of instruction on how to implement it in unique ways to create beautiful desktop apps.
This course assumes you have no programming experience, so its perfect for the beginner. Its also a nice fit for the intermediate and experienced coder as well.
If you think this might be too difficult for you, think again, and come code along with me in a step by step format….just add a big portion of your own unique creativity, and before you know it, you will have built many amazing apps that you can submit to the Mac App Store, and place in the hands of thousands of people. See you inside the course.
Happy Coding ?
Who this course is for:
- This course is for anyone who has a burning desire to get their own creative ideas translated into desktop apps on the mac. We cover the complete Swift 3 language and then how to build apps in macOS – From beginner to advanced
- This is the perfect course if your coming from another language like Objective C or any other language, and you’ll see how easy it is to transition to swift 3.
Created by Stephen DeStefano
Last updated 5/2017
English
English [Auto-generated]
Last updated 5/2017
English
English [Auto-generated]
Size: 3.71 GB
https://www.udemy.com/macbookapps/.
So far, nearly all the articles I have seen about SwiftUI show it being used for iOS, more particularly for iPhone.But SwiftUI works on all Apple’s platforms, and as I am primarily a Mac developer, I decided to try out a Mac app and see what happened.
Setup
I opened up Xcode and created a new project selecting the macOS App template. The project opened at the usual ContentView.swift but there were a few differences in the project structure as well as one in the ContentView struct.
The first thing to notice is that the default “Hello, World!” Text view has a frame set:
If I removed this frame modifier, the preview display in the Canvas changed so that the view was only the size of the text instead of being a standard window size. I guess an iOS device always knows what size it is, but a Mac window can be any size, so you have to be more explicit to stop SwiftUI shrinking the container view to the minimum size possible.
The next thing is to look at the files that are included in the project. There is no SceneDelegate.swift as you would see in an iOS project. And to my surprise, there was still a Main.storyboard file! And going to the General settings for the app target, I could see that this storyboard was selected as the Main Interface.
Opening it up reveals that this is where the application menu is configured. I had wondered where the menus were configured in Mac SwiftUI apps.
The AppDelegate was the next thing I looked at and here I found some of the code that I would have expected to find in a SceneDelegate. The
applicationDidFinishLaunching(_:)
method creates an instance of ContentView, creates an NSWindow and uses an NSHostingView to display the ContentView inside the window. At this stage, running the app gives me what I would expect: a fully-fledged Mac app with a window and a menu, both with all the functions you would expect in any standard Mac app.The Canvas
I was not expecting the Canvas to be much use when it came to previewing a Mac app. It works so well with an iPhone app because the iPhone is tall and thin and fits neatly into one side of the code window. But a Mac view is likely to be much bigger, so it would have to be scaled down a lot to avoid talking up too much precious space in my Xcode window.
But it works as expected, and even scaled down, you get a good idea of the layout while still getting the live reloading that is part of what makes developing in SwiftUI so much fun.
But here is where I got my first real surprise, with a feature that I had not seen yet in any SwiftUI tutorial or article. Click the Live Preview button and see what happens…
Of course I clicked “Bring Forward” and there was my app running in a window called “Xcode Preview”. There was an app in my Dock and when I chose “Show in Finder”, I found that the app is buried deep in DerivedData. Positioning my windows so I could type in Xcode while watching this preview window, I saw that it instantly updated my view as I typed, just like an iPhone in the Canvas.
If I changed the structure of the view, the app closed and re-opened immediately with the new content. This is amazing and shows that the Xcode & SwiftUI teams really thought about how to use these new features in Mac apps as well as iOS.
In Xcode 11.3, I found that I was having trouble with the previews. They would not display and above the Canvas, I got the super helpful message “Cannot preview in this file — SwiftUI-Mac.app may have crashed.”. It turned out that this was a signing issue. If you go to the app target and look in the Signing and Capabilities section, check that Signing Certificate is not set to “Sign to Run Locally”. If it is, switch to “Development” and the previews will start working again.
Laying out the View
Now that I have the project and I know how to preview it, it’s time to work out what to display in the app. The next real app I want to work on will use a master-detail layout, so that is what I decided to try here.
Before worrying about the data, I decided to try populating the master view with a static list and using that to navigate to a detail view that was simply a Text view.
This worked, except that the left column was only about 20 pixels wide. But I was able to use the mouse to drag it wider and there were my List entries. Clicking on one did indeed show the detail I wanted, but it shrunk the window to one line high!
The first thing I did was to apply a
listStyle
modifier to make it show the semi-transparent Mac sidebar. This fixed the width of the sidebar. But the whole window still shrunk when I selected an item.I tried applying the frame modifier to the NavigationView and that made the window stay the same size, but the content still shrunk into a tiny section in the middle. It looks like I need to apply that frame modifier to the detail view as well.
![Mac Mac](https://appsbuilders.org/wp-content/uploads/2019/07/1562542407_maxresdefault-1140x641.jpg)
![Swift mac app tutorial android studio Swift mac app tutorial android studio](/uploads/1/3/3/8/133862376/501950571.jpg)
And as you can see from this gif, I then had a full functional master-detail view with a collapsible and expandable semi-transparent sidebar.
Adding Data
After some scouting around for a free API that I could hook into, I came across HTTP Cats which is a site that serves up a cat image to match almost every HTTP status code.
This sounded ideal: I can list the codes in the master view on the left and display the image in the detail view on the right.
First I created a JSON file to list all the HTTP status codes so that I could put them into a List view. This was a very simple array with each entry having a code and a title:
I created an HttpStatus struct with these 2 properties and I borrowed Paul Hudson’s excellent Helper Bundle extension to decode the JSON file. For a first attempt, I used the numeric codes to build the list and showed the title of the selected one in the detail view. But one of the best things about SwiftUI is that it makes it so easy to configure table rows, so it is time to create a new View to do this.
After some experimentation, I had a TableRowView that I liked the look of, but the default sidebar width was too narrow and truncated the status code titles, so I added a frame modifier to the List to set a minimum and maximum width for the sidebar.
Best Mac App
Outline List
At this point I decided that it would be more useful to have a outline list with the status codes grouped by their category.
So I re-did the JSON file to show this, added an HttpSection struct and a SectionHeaderView and modified the data loading method and @State variable.
This worked really well and I was thrilled to find that the sections automatically had Show/Hide toggles!
Detail View
Swift Mac App Tutorial Windows 10
Up until now, I had been using a standard Text view as the destination for my navigation. This is a really useful technique as you can build the interface gradually but have it work from the beginning. But now it was time to create a new view for the details.
I set up the view and added a method that would download the correct cat image when the view appeared but there was no image. After some digging, I realised that sand-boxed Mac apps do not allow network access by default. I went to the Signing & Capabilities section of the target settings and turned on “Outgoing Connections (Client)”. And then I had my cat pictures.
It really should have a loading image to display while the cat image is being downloaded, but to my disappointment, I found that the SF Symbols are not available to a Mac app! But I added a Text view to say “Loading…”.
Now that I have a functioning Mac app with a Master-Detail view, the next thing is to explore some more of the challenges that will need to be solved before I can write a Mac app completely using SwiftUI.
If you want to check out the project at this stage, here is a link to the relevant GitHub commit. Or if you would prefer, here is a link to the final version of the project.
In part 2 of this series, I will look into:
- how to interact with the menus
- how to open a secondary window
- more user interface controls
- how to pass data around between windows