WWDC Quick Look 💓 By SwiftGGTeam
WWDC22 Day 5 recap

WWDC22 Day 5 recap

Watch original video

Highlight

WWDC22 Day 5 review video summarizes the key sessions of the day, covering iOS App battery optimization, Swift on Server, ShazamKit audio matching, iPad multi-window and Nearby Interaction interaction between devices.

Core Content

Reduce App’s power consumption

Display is one of the major sources of power consumption. The session that day introduced how to optimize display-related power consumption to make the app more power-saving.

00:07

Swift on Server

Apple shows how to build both an iOS app and a Swift Server backend in Xcode. Writing server-side components in Swift can bridge the technology stack gap and allow the front-end and back-end to share code and type definitions.

00:15

ShazamKit audio matching

Neil demonstrates how to use ShazamKit to match audio directories to videos. Apple also introduced important updates for managing custom audio catalogs at scale.

00:23

iPad multi-window

Today’s session shows how to create multiple windows for an iPad App. The presenter used an app that tracks reading books as an example to demonstrate the productivity improvements brought by multiple windows.

00:32

Nearby Interaction and Apple TV

The review video ends with a game of tic-tac-toe between devices, demonstrating how the Nearby Interaction framework allows devices to easily connect to Apple TV for a cross-device interactive experience.

00:38

Detailed Content

Today’s Session List

The fifth day of WWDC22 covered the following topics:

Battery and Performance

  • Optimize display power consumption and extend device life
  • Reduce battery consumption from background activities

Server-side Swift

  • Create a Swift Server project in Xcode
  • Share model code with iOS App
  • Use Swift Package Manager to manage dependencies

Audio & Media

  • ShazamKit custom audio directory
  • Large-scale audio matching management
  • Synchronization of audio directories with video content

iPad Productivity

  • Multi-window Scene configuration
  • Window management and state recovery
  • Interaction design optimized for large screens

Interaction between devices

  • Nearby Interaction framework
  • Device discovery and connection
  • Apple TV as a gaming center

Tic-Tac-Toe cross-device interaction example

import NearbyInteraction
import MultipeerConnectivity

// Discover nearby devices
let session = NISession()
session.delegate = self

// After establishing a connection through MultipeerConnectivity
// Exchange discovery tokens
func shareDiscoveryToken(_ token: NIDiscoveryToken, to peer: MCPeerID) {
    let data = try! NSKeyedArchiver.archivedData(
        withRootObject: token,
        requiringSecureCoding: true
    )
    // Send to the peer
}

// Start interaction after receiving the other party's token
func startInteraction(peerToken: NIDiscoveryToken) {
    let config = NINearbyPeerConfiguration(peerToken: peerToken)
    session.run(config)
}

// NISessionDelegate callback
func session(_ session: NISession, didUpdate nearbyObjects: [NINearbyObject]) {
    for object in nearbyObjects {
        if let distance = object.distance {
            print("Distance: \(distance) meters")
        }
        if let direction = object.direction {
            print("Direction: \(direction)")
        }
    }
}

Key points:

  • NISessionIs the core class of Nearby Interaction
  • Devices need to be exchanged firstNIDiscoveryTokento establish interaction
  • Usually cooperativeMultipeerConnectivityorCoreBluetoothComplete token exchange -NINearbyPeerConfigurationConfigure interaction parameters -didUpdateCallbacks provide distance and direction information that can be used in spatially aware UIs

Core Takeaways

  • Unify front-end and back-end technology stacks with Swift: Maintain iOS App and Swift Server projects simultaneously in Xcode, sharing data models and verification logic. Entry: Xcode -> File -> New -> Project -> Swift Server App.

  • Add multi-window support to iPad App: Use UIScene configuration to enable the App to support opening multiple windows at the same time, improving the user experience in productivity scenarios. Entrance: Info.plist -> UIApplicationSceneManifest -> Configure multiple scene delegates.

  • Build audio recognition with ShazamKit: Create custom audio directories to let apps recognize specific audio content. Suitable for museum tours, event check-ins, content copyright verification and other scenarios. Entrance:SHCustomCatalog + SHSession

  • Use Nearby Interaction to implement spatial perception function: obtain the distance and direction between devices, and build interactive experiences such as “find” and “close to unlock”. Requires U1 chip support (iPhone 11+). Entrance:NISession + NINearbyPeerConfiguration

  • Optimize display power consumption and extend battery life: Check the animation, refresh rate and background display behavior of the App to reduce unnecessary screen updates. Entry: Instruments -> Energy Log.

Comments

GitHub Issues · utterances