An iOS Developer's Guide to SwiftUI: Design and build beautiful apps quickly and easily with minimum code

An iOS Developer's Guide to SwiftUI: Design and build beautiful apps quickly and easily with minimum code

An iOS Developer's Guide to SwiftUI: Design and build beautiful apps quickly and easily with minimum code
Автор: Fadda Michele
Дата выхода: 2024
Издательство: Packt Publishing Limited
Количество страниц: 447
Размер файла: 3.3 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы  Дополнительные материалы 

Cover....1

Title Page....2

Copyright and Credits....2

Contributors....4

Table of Contents....8

Preface....16

Part 1: Simple Views....24

Chapter 1: Exploring the Environment – Xcode, Playgrounds, and SwiftUI....26

Technical requirements....27

Exploring SwiftUI with Xcode....27

A brief tour of Xcode....27

Your first SwiftUI project....41

Creating a SwiftUI project....41

Creating a multi-platform project....45

Previews and the simulator....48

Playgrounds....52

The app submission process....55

Certificates....55

Mobile provisioning profiles....56

The application submission process....57

Summary....59

Chapter 2: Adding Basic UI Elements and Designing Layouts....60

Technical requirements....60

Reusing views code....60

More about Text....66

Managing space in SwiftUI....68

The padding modifier....68

The .frame modifier....69

The .alignment modifier....70

The Spacer....74

The Divider....77

Digging deeper into stacks....78

Overview of stacks....78

HStack....81

ZStack....81

Summary....87

Chapter 3: Adding Interactivity to a SwiftUI View....88

Technical requirements....89

Passing values at view creation....89

Responding to a button tap....90

Property wrappers....93

Limitations of @State....94

Changing a view appearance dynamically using modifiers....96

Bidirectional binding with Picker....99

Final notes on Subviews and @Binding, Classes, and @ObservableObject....101

Summary....106

Part 2: Scrollable Views....108

Chapter 4: Iterating Views, Scroll Views, FocusState, Lists, and Scroll View Reader....110

Technical requirements....110

Iterating views....110

Hiding or showing the keyboard in a form using @FocusState....117

Scroll views....119

Controlling scrolling programmatically using ScrollViewReader....123

Summary....127

Chapter 5: The Art of Displaying Grids....128

Technical requirements....128

Displaying grids in iOS....129

The Grid view....129

Creating a simple static grid....134

Lazy grids....139

Using GridItem to control the layout of LazyVGrid....142

Scrolling horizontally and sizing the grid automatically....143

Conditional formatting of a view....144

Reacting to device rotation....147

Summary....149

Part 3: SwiftUI Navigation....150

Chapter 6: Tab Bars and Modal View Presentation....152

Technical requirements....152

Creating a standard tab bar....152

Creating custom tab bars....159

Adapting your code to different versions of the operating system....167

The hitchhiker’s guide to modal navigation....168

Showing a modal sheet....168

Showing alerts....173

The popover....175

Presentation detents....179

Summary....181

Chapter 7: All About Navigation....182

Technical requirements....182

Navigation as a concept in iOS and other platforms....182

Showing a tab bar title with NavigationView....184

Presenting views with NavigationLink (pre-iOS 16)....186

Adding buttons to NavigationView and activating navigation programmatically....189

Using navigationDestination with NavigationStack....195

Using NavigationPath to control the navigation stack....197

NavigationSplitView – multicolumn navigation....200

Direct navigation stack manipulation with NavigationPath....204

Saving and loading the navigation stack....207

Summary....210

Part 4: Graphics and Animation....212

Chapter 8: Creating Custom Graphics....214

Technical requirements....214

Creating custom modifiers....214

Drawing with the Canvas....218

Using CALayers in SwiftUI....224

Custom layout....227

Summary....230

Chapter 9: An Introduction to Animations in SwiftUI....232

Technical requirements....233

Gestures....233

Basic gestures....233

Creating implicit animations....236

Explicit SwiftUI animations....239

Transitions....245

The .transition() modifier....246

The matchedGeometryEffect modifier....249

Summary....252

Part 5: App Architecture....254

Chapter 10: App Architecture and SwiftUI Part I: Practical Tools....256

Diagrams....257

Dependency inversion....258

Clean Architecture....264

Different ways to decouple....267

Initializer injection....268

Method injection....269

Property injection....270

A matter of state....271

iOS 17 changes in state management....274

Other ways to chop your code....275

Summary....277

Chapter 11: App Architecture and SwiftUI Part II – the Theory....278

Keeping it light enough....279

Conflict and the role of the architect....283

What good software architecture is and what it is not....287

Don’t be shy; ask an expert!....290

The origin of software patterns....294

Agency theory and bad architecture....296

Clean Architecture....297

TCA, The Composable Architecture....301

Summary....304

Part 6: Beyond Basics....306

Chapter 12: Persistence with Core Data....308

What is persistency?....308

What is Core Data?....312

Understanding Core Data framework classes....314

Using Core Data with SwiftUI....316

Creating a Core Data project....317

Working with the data model file....325

Core Data migrations....329

The SQLite data file....331

CloudKit....334

Summary....335

Chapter 13: Modern Structured Concurrency....336

A brief introduction to concurrency....337

Understanding traditional concurrency mechanisms....338

Threads....338

Callbacks and event loops....339

GCD....339

What is structured concurrency?....340

Using the async/await syntax....341

Understanding tasks....348

Task groups....350

Asynchronous streams....358

Actors....363

MainActor....365

Bridging old GCD and structured concurrency....368

Summary....369

Chapter 14: An Introduction to SwiftData....370

Technical requirements....371

Understanding the differences between SwiftData and Core Data....371

SwiftData and SwiftUI....372

Exploring changes in the binding mechanisms....373

Creating a data model....377

Understanding relationships in SwiftData....383

One-to-one relationships....383

One-to-many relationships....384

Many-to-one relationships....384

Many-to-many relationships....385

Cascading deletion rules....386

Fetching data....386

Filtering data with predicates....386

Summary....387

Chapter 15: Consuming REST Services in SwiftUI....388

Technical requirements....389

An overview of REST....389

Ports....396

Understanding REST requests in Swift....396

Codable, Encodable, and Decodable protocols....398

Using URLSession....403

Implementing HTTP methods....404

Setting headers....404

Handling errors....405

URLProtocol....411

Summary....415

Chapter 16: Exploring the Apple Vision Pro....416

Technical requirements....416

Tools for visionOS development....417

An overview of Unity and RealityKit....418

First steps with visionOS development....421

Summary....433

Index....434

Other Books You May Enjoy....443

SwiftUI transforms Apple Platform app development with intuitive Swift code for seamless UI design.

Explore SwiftUI's declarative programming: define what the app should look like and do, while the OS handles the heavy lifting.

Hands-on approach covers SwiftUI fundamentals and often-omitted parts in introductory guides.

Progress from creating views and modifiers to intricate, responsive UIs and advanced techniques for complex apps.

Focus on new features in asynchronous programming and architecture patterns for efficient, modern app design.

Learn UIKit and SwiftUI integration, plus how to run tests for SwiftUI applications.

Gain confidence to harness SwiftUI's full potential for building professional-grade apps across Apple devices.

What you will learn

  • Get to grips with UI coding across Apple platforms using SwiftUI
  • Build modern apps, delving into complex architecture and asynchronous programming
  • Explore animations, graphics, and user gestures to build responsive UIs
  • Respond to asynchronous events and store and share data the modern way
  • Add advanced features by integrating SwiftUI and UIKit to enhance your apps
  • Gain proficiency in testing and debugging SwiftUI applications

Who this book is for

This book is for iOS developers interested in mastering SwiftUI, software developers with extensive iOS development experience using UIkit transitioning to SwiftUI, as well as mobile consultants and engineers who want to gain an in-depth understanding of the framework.

Newcomers equipped with knowledge of Swift, UIkit, XCode, and asynchronous programming will find this book invaluable for launching a career in mobile software development with iOS.


Похожее:

Список отзывов:

Нет отзывов к книге.