2022 EssentialsSwiftDeveloper Tools
WWDC22 · 16 min · Essentials / Swift / Developer Tools
Use Xcode to develop a multiplatform app
Learn how you can build apps for multiple Apple platforms using Xcode 14. We’ll show you how to streamline app targets, maintain a common codebase, and share settings by default. We’ll also explore how you can customize your app for each platform through conditionalizing your settings and code.
Watch at developer.apple.com ↗Code shown on screen · 6 snippets
canImport
#if canImport(ARKit)
import ARKit
#endif Condition Property
#if os(iOS)
(\.editMode) private var editMode
#endif Condition View Modifier
#if os(iOS)
.onChange(of: editMode?.wrappedValue) { newValue in
if newValue?.isEditing == false {
selection.removeAll()
}
}
#endif Condition View
#if os(iOS)
EditButton()
#endif Computed Property
var thumnailSize: Double {
#if os(iOS)
return 120
#else
return 80
#endif
} Menu Bar Extra
#if os(macOS)
MenuBarExtra {
MiniTruckView(model: model)
} label: {
Label("Food Truck", systemImage: "box.truck")
}
.menuBarExtraStyle(.window)
#endif Related sessions
-
34 min -
21 min