Watch os 11

How to workaround URLSession issue in watchOS 6.1.1

Issue #577

https://stackoverflow.com/questions/59724731/class-avassetdownloadtask-is-implemented-in-both-cfnetwork-and-avfoundation

objc[45250]: Class AVAssetDownloadTask is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/ …

How to show list with section in SwiftUI

Issue #511

struct CountriesView: View {
    let groups: [Group]

    init(countries: [Country]) {
        self.groups = CountryManager.shared.groups(countries: countries)
    }

    var body: some View {
        List {
            ForEach(groups) { …

How to make Swift Package Manager package for multiple platforms

Issue #504

https://twitter.com/NeoNacho/status/1181245484867801088?s=20

There’s no way to have platform specific sources or targets today, so you’ll have to take a different approach. I would recommend wrapping all OS specific files in #if os and …

How to make multiline Text in SwiftUI in watchOS

Issue #482

lineLimit does not seem to work, use fixedSize instead

Fixes this view at its ideal size.

A view that fixes this view at its ideal size in the dimensions given in fixedDimensions.

extension Text {
    func styleText() -> some View { …

How to use Swift package manager in watchOS

Issue #474

SPM

Go to Project -> Swift Packages, add package. For example https://github.com/onmyway133/EasyStash

Select your WatchKit Extension target, under Frameworks, Libraries and Embedded Content add the library

CocoaPods

If we use CocoaPods, …

How to reload data without using onAppear in SwiftUI in watchOS

Issue #468

From onAppeear

Adds an action to perform when the view appears.

In theory, this should be triggered every time this view appears. But in practice, it is only called when it is pushed on navigation stack, not when we return to it.

So if …

How to use EnvironmentObject in SwiftUI for watchOS

Issue #467

Declare top dependencies in ExtensionDelegate

class ExtensionDelegate: NSObject, WKExtensionDelegate {
    let storeContainer = StoreContainer()

    func applicationDidEnterBackground() {
        storeContainer.save()
    }
}

Reference …

How to create watch only watchOS app

Issue #457

From Creating Independent watchOS Apps

The root target is a stub, and acts as a wrapper for your project, so that you can submit it to the App Store. The other two are identical to the targets found in a traditional watchOS project. They …

How to show web content as QR code in SwiftUI in watchOS

Issue #449

WatchKit does not have Web component, despite the fact that we can view web content

A workaround is to show url as QR code

import SwiftUI

struct QRCodeView: View {
    let …

How to load remote image in SwiftUI

Issue #448

Use ObservableObject and onReceive to receive event. URLSession.dataTask reports in background queue, so need to .receive(on: RunLoop.main) to receive events on main queue.

For better dependency injection, need to use ImageLoader from …

How to do navigation in SwiftUI in watchOS

Issue #447

NavigationView is not available on WatchKit, but we can just use NavigationLink

List(services.map({ AnyService($0) })) { anyService in
    NavigationLink(destination:
        ItemsView(service: anyService.service)
            . …