ebook img

Catalyst by Tutorials. Bringing iOS Apps to the Mac PDF

238 Pages·2022·23.295 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Catalyst by Tutorials. Bringing iOS Apps to the Mac

Catalyst by Tutorials Catalyst by Tutorials Catalyst by Tutorials By Marin Benčević, Nick Bonatsakis & Andy Pereira Copyright ©2022 Razeware LLC. Notice of Rights All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner. Notice of Liability This book and all corresponding materials (such as source code) are provided on an “as is” basis, without warranty of any kind, express of implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software. Trademarks All trademarks and registered trademarks appearing in this book are the property of their own respective owners. raywenderlich.com 2 Catalyst by Tutorials Table of Contents: Overview Book License............................................................................................. 10 Before You Begin................................................................ 11 What You Need........................................................................................ 12 Book Source Code & Forums............................................................. 13 Acknowledgments.................................................................................. 16 Introduction.............................................................................................. 17 Section I: Making a Great iPad App.............................. 24 Chapter 1: The Checkbox........................................................ 25 Chapter 2: Migrating to Split View Controller................ 37 Chapter 3: Drag & Drop........................................................... 49 Chapter 4: Setting the Scene(s)............................................. 62 Chapter 5: Adding Some Context........................................ 87 Chapter 6: The Keyboard...................................................... 107 Chapter 7: Preferences & Settings Bundle.................... 118 Section II: Making a Great Mac App.......................... 136 Chapter 8: Making Your App Feel at Home on macOS.......................................................................................... 137 Chapter 9: The Mouse............................................................ 152 Chapter 10: Barista Training: Menu Bar......................... 162 Chapter 11: Barista Training: Toolbar.............................. 174 Chapter 12: Barista Training: The Touch Bar................ 193 raywenderlich.com 3 Catalyst by Tutorials Section III: Distributing Your App .............................. 205 Chapter 13: Releasing on the App Store........................ 206 Chapter 14: Third-Party Distribution.............................. 223 Conclusion.............................................................................................. 238 raywenderlich.com 4 Catalyst by Tutorials Table of Contents: Extended Book License. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Before You Begin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 What You Need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Book Source Code & Forums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 About the Authors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 About the Editors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Content Development. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 What is This Book?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Catalyst. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Section I: Making a Great iPad App . . . . . . . . . . . . . . . . 24 Chapter 1: The Checkbox. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 The Sample App: Journalyst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 The iPad Checkbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 The Mac Catalyst Checkbox. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Chapter 2: Migrating to Split View Controller. . . . . . . . . . . . . . . 37 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Integrating Split View Controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Updating the UI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 macOS Split Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 raywenderlich.com 5 Catalyst by Tutorials Chapter 3: Drag & Drop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 How do Drag and Drop Work?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Dropping New Photos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Dropping Inside UICollectionView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Reordering Collection View Items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Chapter 4: Setting the Scene(s). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Introducing Multiple Windows for iPad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Enabling Multi-Window in Xcode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Improving the Standard Multi-Window Experience. . . . . . . . . . . . . . . . . . 73 Adding Custom Drag Behavior to Create a New Window. . . . . . . . . . . . 80 Trying it on the Mac. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Chapter 5: Adding Some Context. . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Introducing Context Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Adding a Context Interaction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Opening a New Window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Creating a New Entry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Adding an Image to an Entry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Add an Entry to Favorites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Sharing an Entry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Deleting an Entry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Trying it on macOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Chapter 6: The Keyboard. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Getting Started. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 First Responders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 raywenderlich.com 6 Catalyst by Tutorials Adding the Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Alternate Keyboard Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Chapter 7: Preferences & Settings Bundle . . . . . . . . . . . . . . . . . 118 Getting Started. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Adding the Settings Bundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Responding to Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Child Panes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Section II: Making a Great Mac App . . . . . . . . . . . . . . 136 Chapter 8: Making Your App Feel at Home on macOS . . . . . 137 It Starts With an App Icon. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Adding a Touch of Color. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 A Word on Typography. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Sizing Down Window Resizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Preferential Treatment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 A Few More Odds and Ends. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Chapter 9: The Mouse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Getting Started. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Pointer Style Providers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Adding Effects With Hover Gesture Recognizer. . . . . . . . . . . . . . . . . . . . 155 A Few Notes on Elements and Haptics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Accessorize. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 raywenderlich.com 7 Catalyst by Tutorials Chapter 10: Barista Training: Menu Bar. . . . . . . . . . . . . . . . . . . . 162 A Free Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 The Responder Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Beyond the Default Menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Deleting Entries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Sharing Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Chapter 11: Barista Training: Toolbar . . . . . . . . . . . . . . . . . . . . . . 174 Getting Started. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Adding the Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Adding Buttons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Customizing the Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Responding to Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Chapter 12: Barista Training: The Touch Bar. . . . . . . . . . . . . . . 193 Understanding the Touch Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Adding Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Grouping Items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Customizing the Touch Bar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 Section III: Distributing Your App. . . . . . . . . . . . . . . . . 205 Chapter 13: Releasing on the App Store . . . . . . . . . . . . . . . . . . . 206 Updating Existing Catalyst Apps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 The App Store vs. Third-Party Distribution . . . . . . . . . . . . . . . . . . . . . . . . . 207 Adding Your App to the App Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Testing Your App With TestFlight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 raywenderlich.com 8 Catalyst by Tutorials Releasing Your App. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Selling Your macOS App Separately. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 Chapter 14: Third-Party Distribution . . . . . . . . . . . . . . . . . . . . . . 223 Signed, Notarized and Delivered. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 Creating a DMG File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Notarizing Disk Images. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Key Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 Where to Go From Here?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 raywenderlich.com 9 L Book License By purchasing Catalyst by Tutorials, you have the following license: • You are allowed to use and/or modify the source code in Catalyst by Tutorials in as many apps as you want, with no attribution required. • You are allowed to use and/or modify all art, images and designs that are included in Catalyst by Tutorials in as many apps as you want, but must include this attribution line somewhere inside your app: “Artwork/images/designs: from Catalyst by Tutorials, available at www.raywenderlich.com”. • The source code included in Catalyst by Tutorials is for your personal use only. You are NOT allowed to distribute or sell the source code in Catalyst by Tutorials without prior authorization. • This book is for your personal use only. You are NOT allowed to sell this book without prior authorization, or distribute it to friends, coworkers or students; they would need to purchase their own copies. All materials provided with this book are provided on an “as is” basis, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action or contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. All trademarks and registered trademarks appearing in this guide are the properties of their respective owners. raywenderlich.com 10

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.