Article

watchOS 6 Release Notes

Update your apps to use new features, and test your apps against API changes.

Overview

The watchOS 6 SDK provides support for developing watchOS apps for Apple Watch devices running watchOS 6. The SDK comes bundled with Xcode 11 beta available from Beta Software Downloads. For information on the compatibility requirements for Xcode 11, see Xcode 11 Release Notes.

Networking

New Features

Known Issues

Deprecations

Notifications

New Features

  • To send a UserNotifications push to a watchOS device, a new apns-push-type key is now required as part of the APNs request header. Depending on the type of notification, this key can be set to alert or background and is supported across all Apple platforms. (47099534)

Podcasts

Known Issues

  • Asking Siri to play a podcast on Apple Watch might result in an error message. (50392036)

SwiftUI

New Features

Known Issues

  • SwiftUI has an API that lets you change the value type of Binding to AnyHashable:

    let someBinding: Binding<String> = ...
    let typeErasedBinding = Binding<AnyHashable>(someBinding)
    

    Attempting to use this API at compile time results in a linker error on watchOS 6. (53769896)

  • A WKInterfaceObjectRepresentable instance with no explicit width might expand to the bounds of its container.

    Workaround: Wrap the WKInterfaceObjectRepresentable instance in a GeometryReader to get an explicit width for the view. (53512858)

  • Image instances don’t use resizing information configured in asset catalogs. Configure the size of an image using the resizable(capInsets:resizingMode:) modifier instead. (49114577)

Deprecations

  • SwiftUI APIs deprecated in previous betas are now removed. (52587863, 53310683)

  • The Length type is replaced by CGFloat. (50654095)

  • TabbedView is now named TabView. (51012120)

  • HAlignment and VAlignment are now deprecated, use the more flexible HorizontalAlignment or VerticalAlignment types instead and use TextAlignment for text. (51190531)

  • The SelectionManager protocol is removed, use Optional and Set instances directly for selection. (51557694)

  • The isPresented environment value is deprecated and replaced with the more general presentationMode value. (51641238)

  • The StaticMember protocol is deprecated. Use protocol-conforming types directly instead. For example, use an instance of WheelPickerStyle directly rather than the wheel static member.(52911961)

  • Complex overloads for the background(_:alignment:) and border(_:width:) modifiers are deprecated. Use shapes in a background(_:alignment:) or overlay(_:alignment:) to draw these instead. (53067530)

  • The identified(by:) method on the Collection protocol is deprecated in favor of dedicated init(_:id:selection:rowContent:) and init(_:id:content:) initializers. (52976883, 52029393)

    The retroactive conformance of Int to the Identifiable protocol is removed. Change any code that relies on this conformance to pass \.self to the id parameter of the relevant initializer. Constant ranges of Int continue to be accepted:

    List(0..<5) {
        Text("Rooms")
    }
    

    However, you shouldn’t pass a range that changes at runtime. If you use a variable that changes at runtime to define the range, the list displays views according to the initial range and ignores any subsequent updates to the range.

  • Several extensions to the Binding structure are removed. (51624798)

    If you have code such as the following:

    struct LandmarkList: View {
        var landmark: [Landmark]
        @Binding var favorites: Set<Landmark>
    
        var body: some View {
            List(landmarks) { landmark in
                Toggle(landmark.name, isOn: self.$favorites.contains(landmarkID))
            }
        }
    }
    

    Define the following subscript on the Set structure:

    extension Set {
        subscript(member: Element) -> Bool {
            get { contains(member) }
            set {
                if newValue {
                    insert(member)
                } else {
                    remove(member)
                }
            }
        }
    }
    

    Then, change self.$favorites.contains(landmarkID) to self.$favorites[landmarkID].

  • The Binding structure’s conditional conformance to the Collection protocol is removed. (51624798)

    If you have code such as the following:

    struct LandmarkList: View {
        @Binding var landmark: [Landmark]
    
        var body: some View {
            List(landmarks) { landmark in
                Toggle(landmark.value.name, isOn: landmark[\.isFavorite])
            }
        }
    }
    

    Define the following collection type:

    struct IndexedCollection<Base: RandomAccessCollection>: RandomAccessCollection {
        typealias Index = Base.Index
        typealias Element = (index: Index, element: Base.Element)
    
        let base: Base
    
        var startIndex: Index { base.startIndex }
    
        var endIndex: Index { base.startIndex }
    
        func index(after i: Index) -> Index {
            base.index(after: i)
        }
    
        func index(before i: Index) -> Index {
            base.index(before: i)
        }
    
        func index(_ i: Index, offsetBy distance: Int) -> Index {
            base.index(i, offsetBy: distance)
        }
    
        subscript(position: Index) -> Element {
            (index: position, element: base[position])
        }
    }
    
    extension RandomAccessCollection {
        func indexed() -> IndexedCollection<Self> {
            IndexedCollection(base: self)
        }
    }
    

    Then, update your code to:

    struct LandmarkList: View {
        @Binding var landmarks: [Landmark]
    
        var body: some View {
            List(landmarks.indexed(), id: \.1.id) { (index, landmark) in
                Toggle(landmark.name, isOn: self.$landmarks[index].isFavorite)
            }
        }
    }
    
  • The relativeWidth(_:), relativeHeight(_:), and relativeSize(width:height:) modifiers are deprecated. Use other modifiers like frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:) instead. (51494692)

Xcode

Known Issues

  • If your watch debugging session continuously times out, you might need to quit and relaunch Xcode after connecting to the internet in order to download the appropriate DeviceSupport files. (50554987)

  • The watchOS Mail app and related processes might quit unexpectedly when used within the Simulator. (53799899)

See Also

watchOS 6

watchOS 6.1.1 Beta 4 Release Notes

Update your apps to use new features, and test your apps against API changes.

watchOS 6.1 Release Notes

Update your apps to use new features, and test your apps against API changes.