Discuss the latest Apple technologies announced at WWDC22.

Posts under WWDC22 tag

27 Posts
Sort by:
Post marked as solved
4 Replies
4.5k Views
How can I add a native UX for pull-to-refresh for a ScrollView? Is support for this being added in iOS 16? Right now, the native UX only appears for List. For example, I want to support to be able to support .refreshable on a ScrollView like this: var body: some View {     ScrollView {       LazyVStack {         Text("1")         Text("2")         Text("3")       }     }     .refreshable {       ///     }   }
Posted
by
Post not yet marked as solved
9 Replies
3.2k Views
The new Virtualization framework (and sample code!) are great. It's a lot of fun to run the sample code and quickly fire up multiple VMs of macOS running as a guest. However, the inability to authenticate with any iCloud services is a significant roadblock. Xcode, for example, is not allowing me to authenticate my developer account. Are there any plans to resolve this issue so that iCloud accounts can be authenticated from within a VM?
Posted
by
Post not yet marked as solved
4 Replies
1.8k Views
All of my builds get stuck on Archive action - it keeps running forever (10+ hours where it took 30 minutes before for a clean build), and never finishes despite having all subtasks finished (green check). This started to happen on a workflow that has worked reliably for months, right after WWDC22 start - is there a problem with a new version of Xcode Cloud?
Posted
by
Post not yet marked as solved
2 Replies
2.2k Views
Exciting to see the new Medication tracking features coming to Health. As a medical app we're wondering if read/write access to these is coming to HealthKit? We're currently building prescription management into our app so it would be great to be able to let users also add these to Health to handle their adherence tracking.
Posted
by
Post not yet marked as solved
5 Replies
1.9k Views
Hi, according this WWDC session https://developer.apple.com/wwdc22/10170 App Shortcuts are defined in Swift code, by implementing the AppShortcutsProvider protocol. To implement the protocol, I'll simply create a single getter that returns all the app shortcuts I want to set up for the user. Note that in total, your app can have a maximum of 10 app shortcuts. However, most apps only need a few. there is a limit for up to 10 AppShortcuts. Could you please clarify how that limit handled? 🤔 (e.g. project failed to build / app will crash or malfunction / only 10 shortcuts will be handled on random/ordered choice by iOS) I suppose there is some way to manage shortcuts amount but see no details at documentation yet.
Posted
by
Post not yet marked as solved
2 Replies
1.7k Views
Is it possible to see a preview of the Live Activity UI we design? For a regular widget, we pass in a WidgetPreviewContext modifier where we specify the size of the widget to preview. Is it possible to do something similar to see how the live activity would appear without having to run the app and then see how the live activity appears on the Lock Screen?
Posted
by
Post not yet marked as solved
19 Replies
5.8k Views
I had a timer app, it played white noise after starting the timer. so my app is running in the background with background audio, and the timer is perfect for display with live activity. However, when I test my code with a real device, I find calling await activity.update(using: contentState) when app is running in the background does not work at all. the code executes, but the live activity won't get updated. After some experiments, I find: if the app is running in the background with background location or Picture-in-picture mode, the app can update live activity when running in the background. If the app is running in the background with audio playing, it will work on simulator, but not on a real device. I submit a feedback: FB11683922 (Can't update Live Activity from app with ActivityKit when app is running in the background with background audio playing.) My code is like: func startLiveActivity() { // Prepare content state and attributes.     do {       self.activity = try Activity.request(attributes: activityAttributes, contentState: initialContentState) // Play audio so app can keep running in the background.       try playAudio()     } catch (let error) {       print("Error requesting Live Activity \(error.localizedDescription).")     }   } private func playAudio() throws {     try AVAudioSession.sharedInstance().setCategory(.playback, options: .mixWithOthers)     try AVAudioSession.sharedInstance().setActive(true)     if self.player == nil {       if let url = Bundle.main.url(forResource: "Forest", withExtension: "m4a") {         player = try AVAudioPlayer(contentsOf: url)         player?.numberOfLoops = -1       }     }     player?.stop()     player?.currentTime = 0     player?.play()   } after the timer stops, the code will execute, but the live activity won't get updated.   func updateActivity(){     Task {       if let activity = self.activity { // Prepare content state         await activity.update(using: contentState)       }     }   }
Posted
by
Post not yet marked as solved
1 Replies
999 Views
Hello! Since the Stage Manager now occupies a set of interactions left of the screen to display a new dock, we'd like to conditionally turn off features or provide a feature workaround to not conflict with this set of interactions. Is there any way to check in AppKit, whether Stage Manager is currently turned on in the system to accomplish this? Any help would be greatly appreciated!
Posted
by
Post not yet marked as solved
1 Replies
1.4k Views
I'm looking to see if someone could point me in the right direction in terms of understanding what's needed for to host a backend server for the new Push To Talk API. Additionally, I'm curious to know what type of latency times people are getting. We've ran a mumble server which unfortunately had a considerable amount of latency.
Posted
by
Post not yet marked as solved
2 Replies
1.3k Views
Before iOS16, Map can be displayed as a globe by setting MapType as either SatelliteFlyover or HybridFlyover constant  https://developer.apple.com/documentation/mapkit/mkmaptype With iOS16 the MKMapType is deprecated but I couldn't find any equivalent of a 3d globe view in the new preferredConfiguration of MKMapConfiguration. Is it no longer possible?
Posted
by
Post not yet marked as solved
1 Replies
1.1k Views
Hi,i have been trying out SwiftUI Table and wanted to present a details view when click on Table Row occurs, but I couldn't figure out how to "deselect" row once its been selected, while it may not be what Table was intended for, but I still think this code should be valid. (iPadOS) struct Person: Identifiable { let givenName: String let familyName: String let emailAddress: String let id = UUID() } private var people = [ Person(givenName: "Juan", familyName: "Chavez", emailAddress: "juanchavez@icloud.com"), Person(givenName: "Mei", familyName: "Chen", emailAddress: "meichen@icloud.com"), Person(givenName: "Tom", familyName: "Clark", emailAddress: "tomclark@icloud.com"), Person(givenName: "Gita", familyName: "Kumar", emailAddress: "gitakumar@icloud.com") ] @State private var selectedPeople: Person.ID? @State private var detailsViewPresented: Bool = false var body: some View {         Table(people, selection: $selectedPeople) {             TableColumn("Given Name", value: \.givenName)             TableColumn("Family Name", value: \.familyName)             TableColumn("E-Mail Address", value: \.emailAddress)         }         .onChange(of: selectedPeople) { selection in             guard selection != nil else {                 return             }             detailsViewPresented = true         }         .sheet(isPresented: $detailsViewPresented, onDismiss: {             // Trying to reset the selection             self.selectedPeople = nil         }) {             Text("Person's details")         } } Here when I press row, it gets selected and Text is presented, but row still remains selected, and yes, I could just use onTapGesture within row content if I declared TableColumn with explicit content, but it would just be added to that column and would not provide build in selection style. https://developer.apple.com/documentation/swiftui/table
Posted
by
Post not yet marked as solved
1 Replies
1k Views
I'm looking for a way to check user Screen Time and trigger a notification after a specified amount of time on certain apps. I have the code from WWDC21 but I was wondering if I could get the code sample for the Worklog app created for WWDC22. Would really help as a reference point for building my project. Thank you!
Posted
by
Post marked as solved
2 Replies
1.2k Views
Since NavigationView is now deprecated, I’m trying to update my code to use NavigationStack instead. However, I found that when using NavigationStack, section headers within an overall List view no longer have the collapsing triangle functionality. This used to work for NavigationView, List view, Section headers. Am I missing something? Is there a way to get back the section header collapse triangle within an overall List view when encapsulating within a NavigationStack?
Posted
by
Post not yet marked as solved
1 Replies
614 Views
Today I was searching for some watchOS code, and came across this WWDC22 demo. But I found out there are some quote sign bugs in the demo code (go to the code section and scroll down) like this: ... y: .value( “Completed", dataPoint.itemsComplete) ) ... It is so obvious that the code block even displays the code after those signs with a different color. There are 4 such code bugs in that page. Looks like the guy who wrote the code pasted that for 3 times and never noticed that lol.
Posted
by
Post not yet marked as solved
0 Replies
517 Views
The child views of my container need to get (not set) the size of container from within their view body, in order to perform some calculation. I've made a custom container that conforms to the Layout protocol (the actual implementation isn't important). The required placeSubviews method has a bounds parameter which is the size of container. Does anyone know whether it is possible to store the bounds somewhere so that the subviews of the container can access it, such as in environment key of the view hierarchy? Or is my only option to use a GeometryReader? struct CustomContainer: Layout { func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout Void) -> CGSize { // Calculate and return the size of the layout container. } func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout Void) { // Tell each subview where to appear. // Can I store bounds parameter somewhere?? } }
Posted
by
Post marked as solved
1 Replies
599 Views
I am using the same ChannelManager, however when switching to another channel, I leave the channel and then requestToJoin a new channel with the new inputted ChannelName and PTDescriptor however the name and image are not changing when I go to background to see the Native UI. Am I missing something to call for an update for the PTDescriptor?
Posted
by
Post not yet marked as solved
3 Replies
710 Views
I'm building a UIKit app that reads user's Apple Music library and displays it. In MusicKit there is the Artwork structure which I need to use to display artwork images in the app. Since I'm not using SwiftUI I cannot use the ArtworkImage view that is recommended way of displaying those images but the Artwork structure has a method that returns url for the image which can be used to read the image. The way I have it setup is really simple: extension MusicKit.Song { func imageURL(for cgSize: CGSize) -> URL? { return artwork?.url( width: Int(cgSize.width), height: Int(cgSize.height) ) } func localImage(for cgSize: CGSize) -> UIImage? { guard let url = imageURL(for: cgSize), url.scheme == "musicKit", let data = try? Data(contentsOf: url) else { return nil } return .init(data: data) } } Now, everytime I access .artwork property (so a lot of times) the main thread gets blocked and the console output gets bombared with messages like these: 2023-07-26 11:49:47.317195+0200 Plum[998:297199] [Artwork] Failed to create color analysis for artwork: <MPMediaLibraryArtwork: 0x289591590> with error; Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.mediaartworkd.xpc was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.mediaartworkd.xpc was invalidated: failed at lookup with error 159 - Sandbox restriction.} 2023-07-26 11:49:47.317262+0200 Plum[998:297199] [Artwork] Failed to create color analysis for artwork: file:///var/mobile/Media/iTunes_Control/iTunes/Artwork/Originals/4b/48d7b8d349d2de858413ae4561b6ba1b294dc7 2023-07-26 11:49:47.323099+0200 Plum[998:297013] [Plum] IIOImageWriteSession:121: cannot create: '/var/mobile/Media/iTunes_Control/iTunes/Artwork/Caches/320x320/4b/48d7b8d349d2de858413ae4561b6ba1b294dc7.sb-f9c7943d-6ciLNp'error = 1 (Operation not permitted) My guess is that the most performance-heavy task here is performing the color analysis for each artwork but IMO the property backgroundColor should not be a stored property if that's the case. I am not planning to use it anywhere and if so it should be a computed async property so it doesn't block the caller. I know I can move the call to a background thread and that fixes the issue of blocking main thread but still the loading times for each artwork are terribly slow and that impacts the UX. SwiftUI's ArtworkImage loads the artworks much quicker and without the errors so there must be a better way to do it.
Posted
by
Post not yet marked as solved
1 Replies
673 Views
Hello there, I am trying to follow along with the video and copy the example shown here in SwiftUI. I am given the error Cannot assign value of type 'UIView' to type 'PKCanvasView?' on this line: resultView = overlayView It is totally possible that I am botching the whole thing up but I would appreciate it if someone looked over my code. Thanks. code: // ContentView.swift import SwiftUI import PDFKit import PencilKit import Foundation import UIKit struct PDFUIView: View { let pdfDoc: PDFDocument let pdfView: PDFView init() { let url = Bundle.main.url(forResource: "example", withExtension: "pdf")! pdfDoc = PDFDocument(url: url)! pdfView = PDFView() } var body: some View { VStack { PDFKitView(showing: pdfDoc, pdfView: pdfView) } .padding() } } #Preview { PDFUIView() } struct PDFKitView: UIViewRepresentable { let pdfDocument: PDFDocument let pdfView: PDFView init(showing pdfDoc: PDFDocument, pdfView:PDFView) { self.pdfDocument = pdfDoc self.pdfView = pdfView } func makeUIView(context: Context) -> PDFView { pdfView.usePageViewController(true) pdfView.autoScales = true pdfView.pageOverlayViewProvider = context.coordinator pdfView.displayMode = .singlePageContinuous pdfView.isUserInteractionEnabled = true pdfView.document = pdfDocument pdfView.delegate = context.coordinator return pdfView } func updateUIView(_ pdfView: PDFView, context: Context) { pdfView.document = pdfDocument } func makeCoordinator() -> Coordinator { Coordinator() } } class Coordinator: NSObject, PDFPageOverlayViewProvider, PDFViewDelegate { var pageToViewMapping = [PDFPage: UIView]() func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? { var resultView: PKCanvasView? = nil if let overlayView = pageToViewMapping[page] { resultView = overlayView } else { var canvasView = PKCanvasView(frame: .zero) canvasView.drawingPolicy = .anyInput canvasView.tool = PKInkingTool(.pen, color: .systemCyan, width: 20) canvasView.backgroundColor = UIColor.clear pageToViewMapping[page] = canvasView resultView = canvasView } let page = page as! MyPDFPage if let drawing = page.drawing { resultView?.drawing = drawing } return resultView } func pdfView(_ pdfView: PDFView, willDisplayOverlayView overlayView: UIView, for page: PDFPage) { guard let overlayView = overlayView as? PKCanvasView else { return } guard let canvasView = pageToViewMapping[page] else { return } let page = page as! MyPDFPage page.drawing = overlayView.drawing pageToViewMapping.removeValue(forKey: page) } class MyPDFAnnotation: PDFAnnotation { override func draw(with box: PDFDisplayBox, in context: CGContext) { UIGraphicsPushContext(context) context.saveGState() let page = self.page as! MyPDFPage if let drawing = page.drawing { let image = drawing.image(from: drawing.bounds, scale: 1) image.draw(in: drawing.bounds) } context.restoreGState() UIGraphicsPopContext() } } class MyPDFPage: PDFPage { var drawing: PKDrawing? } }
Posted
by