Post not yet marked as solved
In What's New In Swift, a new DispatchSerialQueue-backed actor was introduced. We're able to call MainActor-annotated functions using DispatchQueue.main.async without errors or warnings. For example:
@MainActor
func randomFunc() {
print("Hello World")
}
DispatchQueue.main.async {
randomFunc()
}
However calling a globalActor-annotated function or a regular actor-isolated function backed by a DispatchSerialQueue, we get the warning Actor-isolated instance method 'randomFunc()' can not be referenced from a non-isolated context; this is an error in Swift 6. Code here:
actor MyActor {
private let queue: DispatchSerialQueue
nonisolated var unownedExecutor: UnownedSerialExecutor { queue.asUnownedSerialExecutor() }
init(queue: DispatchSerialQueue) {
self.queue = queue
}
func randomFunc() {
print("Hello World!")
}
}
let queue = DispatchSerialQueue(label: "actorQueue")
let actor = MyActor(queue: queue)
queue.async {
actor.randomFunc() // Warning here
}
Although it has a warning, the code still runs successfully and prints Hello World, but it would also do so from another DispatchQueue not used by the actor (this was tested in Version 15.0 beta (15A5160n) Playground).
My question: Can we remove the warning resulting from calling an actor isolated function backed by DispatchSerialQueue A using A.async { }, if that's safe behavior? If it's not safe, why not?
Post not yet marked as solved
The new ARKit 3D hand tracking looks amazing, but most of the demos seem to be done with the Vision Pro which has far more sensors than other iOS devices.
Will the ARKit 3D hand tracking also be available on iOS Devices with LiDAR? If not, is there any alternatives developers can do to achieve similar 3D hand tracking on mobile devices to make the interaction experience consistent across devices? (I know Vision only detects 2D hand pose)
Thanks!
Post not yet marked as solved
Subject: Bug Report: Issue with SKStoreReviewController.requestReview on iOS 17 beta 1 - Review Prompt Not Displaying
Dear Apple Developer Support,
I hope this email finds you well. I am writing to inform you about a bug that I have encountered while testing my app on the latest iOS 17 beta 1.
Specifically, I have noticed that the SKStoreReviewController.requestReview() method does not display the review prompt on this beta release. Despite invoking the method, the expected review window does not appear for users to provide feedback or rate the app. This issue seems to be isolated to iOS 17 beta 1, as previous iOS versions did not exhibit this behavior.
I understand that beta versions are prone to bugs and issues, and I am reporting this matter to assist in the improvement of the platform before the official release. If there are any additional steps or information required to help investigate and resolve this issue, please let me know, and I will be more than happy to provide them. Resolving this bug would greatly benefit developers who rely on the SKStoreReviewController functionality within their apps.
Thank you for your attention to this matter, and I appreciate your ongoing dedication to enhancing the iOS platform for app development.
Kind regards, Alexey
Post not yet marked as solved
Is there a limit to the size of the object that you are wanting to capture with Object Capture. e.g could it capture a horse or other such sized animal?
Post not yet marked as solved
In the video 'The SwiftUI cookbook for focus" a key detail is left out.
https://developer.apple.com/videos/play/wwdc2023/10162/?time=1130
selectRecipe has no code provided meaning it leaves out a vital detail, how to handle up and down keyboard presses.
If a LazyVGrid has 4 items per row with the current shape of the window and the user presses the down key, how is the application supposed to know which item is directly underneath the currently focused one? Or if they press up and they need to know which is directly above? What happens when the user resizes the window and the number of items per row changes?
This would seem to require knowing the exact current layout of the window to return the correct recipe ID. The code provided isn't wrapped in a complex GeometryReader so I assume there's some magic I am missing here.
I am trying to create a similar LazyVGrid that can be navigated with the keyboard as with the recipes grid here but have no means of implementing .onMoveCommand in such a way that makes sense.
At the moment, SwiftUI seems to be intentionally built in such a way to defy all attempts to implement keyboard navigation.
Post marked as Apple Recommended
I am having trouble getting the new mirroring session API to send data to the companion device.
when starting a workout on my watch I call startMirroringToCompanionDevice and then go onto my iOS workout manager to handle it via the workoutSessionMirroringStartHandler, I set the delegate here and can confirm that it is indeed not nil within that function but when I go to send some data across I get an error saying the remote session delegate was never set up.
I noticed this same behaviour in the WWDC demo and have been unable to find a solution that will allow me to send data across the mirrored session even though I am able to control the workout session state(pause, resume, end) on both Phone and Watch.
Has anyone else encountered this issue? Anyone have a solution?
Post not yet marked as solved
I'm trying to create swift macros for initializer. I can't get the members of the inherited class.
Post not yet marked as solved
Rapidly tapping on a Button in an interactive widget bypasses the button's AppIntent action, and launches the host app instead.
I've filed a radar for this, but is there any known workaround for this behaviour?
Doesn't seem to happen when using Apple's first party app widgets.
Post not yet marked as solved
Adding an inspector and toolbar to Xcode's app template, I have:
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
.toolbar {
Text("test")
}
.inspector(isPresented: .constant(true)) {
Text("this is a test")
}
}
}
In the preview canvas, this renders as I would expect:
However when running the app:
Am I missing something?
(Relevant wwdc video is wwdc2023-10161. I couldn't add that as a tag)
Post not yet marked as solved
Its regarding to https://developer.apple.com/videos/play/wwdc2023/10233/
Post not yet marked as solved
I attempted to utilize the Background Assets feature for an iOS app. While debugging, I employed the following command to trigger the installation event:
xcrun backgroundassets-debug -b <bundleID> -s --app-install -d <Device ID>
This command worked flawlessly on an iPhone.
However, when I attempted to trigger the installation event on a Mac, I encountered the following error message:
The requested device to send simulation events to is not available.
Verify that the device is connected to this Mac.
Please note that the xcrun backgroundassets-debug -l command only displays a list of connected devices.Mac is not listed in that list.
Post not yet marked as solved
Related to this StackOverflow post (not mine).
In my chat view:
ScrollView(showsIndicators: false) {
messagesView
}
.safeAreaInset(edge: .bottom) { composerView }
.scrollDismissesKeyboard(.interactively)
Using interactively keyboard dismissing won't change the safe area size interactively causing a weird UI glitch like you can see in the post up above.
The keyboard and composer play nice when I use it as tool bar, But I want my composer to always be visible (obviously), I've tried to play with FocusState to change the composer parent:
.toolbar {
ToolbarItem(placement: $isFocused ? .keyboard : .bottomBar) {
bottomView
}
}
But not only it redraws the view each time, it will also make the view lose its focus state, affectively releasing the keyboard. Plus it feels kind of a hack.
What is the right way to make the composer move with the keyboard interactively and stay on screen while the keyboard is gone, like in iMessages?
Post not yet marked as solved
I'm experiencing an issue trying to install the 'mirroringworkoutssample' app from the official Apple documentation on my Apple Watch. When attempting a direct installation from the Apple Watch, I receive an error stating, "Cannot install this app due to an inability to verify its integrity."
Has anyone else encountered this problem or can provide any solutions or insights?
** I have a 'Development' type certificate that allows for watchOS(it includes iOS, tvOS ..) development.
** also added WKCompanionAppBundleIdentifier com.example.apple-samplecode.MirroringWorkoutsSample7C76V3X7AB.watchkitapp
Post not yet marked as solved
Related to this post.
In my chat view, each time I load new page (items are added from top), the ScrollView jumps to top instead of maintaining scrollPosition.
Here is my scroll view:
GeometryReader { geometryProxy in
ScrollView(showsIndicators: false) {
VStack(spacing: 0) {
if viewModel.isLoading {
LoadingFooter()
}
messagesView
.frame(minHeight: geometryProxy.size.height - loadingFooterHeight - bottomContentMargins, alignment: .bottom)
}
}
.scrollDismissesKeyboard(.interactively)
.defaultScrollAnchor(.bottom)
.scrollPosition(id: $scrolledId, anchor: .top)
.contentMargins(.bottom, bottomContentMargins, for: .scrollContent)
.onChange(of: scrolledId, scrollViewDidScroll)
}
And this is the messages view
@ViewBuilder var messagesView: some View {
LazyVStack(spacing: 0) {
ForEach(sectionedMessages) { section in
Section(header: sectionHeaderView(title: section.id)) {
ForEach(section, id: \.id) { message in
MessageView(message: message)
.padding(.horizontal, .padding16)
.padding(.bottom, .padding8)
.id(message.id)
}
}
}
.scrollTargetLayout()
}
}
Printing the scrolledId after a page load, I can see it hasn't changed, but the ScrollView position does.
Post not yet marked as solved
WWDC23 Platform State of the Union mentioned that Volume shutter buttons to trigger the camera shutter is coming later this year. This was mentioned at 0:30:15.
Would anyone know when this will be available?
Post not yet marked as solved
I'd like to implement a fully immersive space that's experienced by multiple Vision Pro users simultaneously via SharePlay. To do this, the multiple Vision Pro users will join a SharePlay-enabled visionOS window that has a button to enter a fully immersive space, which is also SharePlay-enabled. I tried following the WWDC sessions and docs, but they don't provide enough detail about integrating SharePlay into an existing window and immersive space. How can I adjust my SharePlay code so it makes my visionOS window + fully immersive space SharePlay-able? Please see existing code below for a SharePlay visionOS widow, thank you.
P.S. WWDC ref. https://developer.apple.com/videos/play/wwdc2023/10087
import SwiftUI
import RealityKit
import RealityKitContent
import GroupActivities
import LinkPresentation
struct SharePlayWorld: View, GroupActivity {
@Environment(ViewModel.self) private var model
@Environment(\.openWindow) private var openWindow
@Environment(\.dismissWindow) private var dismissWindow
@Environment(\.openImmersiveSpace) private var openImmersiveSpace
@Environment(\.dismissImmersiveSpace) private var dismissImmersiveSpace
var body: some View {
@Bindable var model = model
Toggle(
model.isShowingPracticeSpace ? "Leave Space" : "Enter Space",
isOn: $model.isShowingPracticeSpace
)
.onChange(of: model.isShowingPracticeSpace) { _, isShowing in
Task {
if isShowing
{
await openImmersiveSpace(id: "SharePlayWorld")
}
else
{
await dismissImmersiveSpace()
}
}
}
.toggleStyle(.button)
}
// SHAREPLAY CODE
private func startSharePlaySession() async {
for await session in SharePlayWorld.sessions() {
guard let systemCoordinator = await session.systemCoordinator else { continue }
let isLocalParticipantSpatial = systemCoordinator.localParticipantState.isSpatial
Task.detached {
for await localParticipantState in systemCoordinator.localParticipantStates {
if localParticipantState.isSpatial {
// Start syncing scroll position
} else {
// Stop syncing scroll position
}
}
}
var configuration = SystemCoordinator.Configuration()
configuration.spatialTemplatePreference = .sideBySide
systemCoordinator.configuration = configuration
session.join()
}
// Create the activity
let activity = SharePlayWorld()
// Register the activity on the item provider
let itemProvider = NSItemProvider()
itemProvider.registerGroupActivity(activity)
// Create the activity items configuration
let configuration = await UIActivityItemsConfiguration(itemProviders: [itemProvider])
// Provide the metadata for the group activity
configuration.metadataProvider = { key in
guard key == .linkPresentationMetadata else { return nil }
let metadata = LPLinkMetadata()
metadata.title = "Explore Together"
metadata.imageProvider = NSItemProvider(object: UIImage(named: "explore-activity")!)
return metadata
}
self.activityItemsConfiguration = configuration
}
}
#Preview {
SharePlayWorld()
.environment(ViewModel())
}
Post not yet marked as solved
I have to turn off closed captions for every video in the WWDC catalogue. How can i set all videos CC to be off by default?
Post not yet marked as solved
I've been trying to reproduce the example used in the WWDC 23 Presentation "Explore Pit Charts and Interactivity in SwiftCharts" where a popover annotation is set on top of the chart and vertical; RuleMark. However when doing so the annotation doesn't appear at all.
I worked around that issue by setting: y: .fit(to: .chart) in the init of the overflowResolution, like:
.annotation(position: .top, spacing: 0, overflowResolution: .init(x: .fit(to: .chart), y: .fit(to: .chart)))
Probably a SwiftUI bug given this API is only a few months old. If anyone has been able to reproduce that example let me know!
Post not yet marked as solved
I have an iOS app target with a framework dependency and want to merge that framework by setting MERGED_BINARY_TYPE to automatic in the app target's build settings.
It all works fine until I add a (non-private) UIHostingController to the framework target. When I do this it crashes on startup with this message: dyld[15894]: Symbol not found: _OBJC_CLASS_$__TtC5Frame4MyVC.
Xcode 15.1b3
Reported as bug via Feedback Assistant: FB13379276
Post not yet marked as solved
I have developed an interactive widget which looks as the following
It is using CoreData.
The view is implemented as the following
struct widget_extensionEntryView : View {
var body: some View {
if let nsTodoList = nsTodoList {
VStack(alignment: .leading, spacing: 1) {
...
ForEach(0..<prefixGoodNSTodoArray.count, id: \.self) { index in
...
let todoIntent = TodoIntent(objectIDAsString: objectIDAsString, parentOrder: parentOrder)
Button(intent: todoIntent) {
}
}
}
}
}
}
The AppIntent is implemented as the following
import Foundation
import AppIntents
import WidgetKit
import CoreData
struct TodoIntent: AppIntent {
static var title: LocalizedStringResource = "Complete Task"
static var description: IntentDescription = IntentDescription("Complete selected task")
@Parameter(title: "objectIDAsString")
var objectIDAsString: String
@Parameter(title: "parentOrder")
var parentOrder: Int
init() { }
init(objectIDAsString: String, parentOrder: Int) {
self.objectIDAsString = objectIDAsString
self.parentOrder = parentOrder
}
func perform() async throws -> some IntentResult {
guard let objectID = NSManagedObjectID.from(objectIDAsString) else { return .result() }
guard let nsTodoList = NSTodoListRepository.INSTANCE.getNSTodoList(objectID) else { return .result() }
nsTodoList.toggleChecked(context: CoreDataStack.INSTANCE.viewContext, parentOrder: Int64(parentOrder))
RepositoryUtils.saveContextIfPossible(CoreDataStack.INSTANCE.viewContext)
TodoWidgetOptions.isWrittenByWidgetExtension = true
// Refresh all home widgets.
// TODO: https://developer.apple.com/forums/thread/721937
WidgetCenter.shared.reloadAllTimelines()
return .result()
}
}
The interactive widget works pretty well.
However, tapping on the widget has no response in the following situations:
After an overnight, we turn on the iPhone's screen and tap on the widget.
After a few hours of idle time, we turn on the iPhone's screen and tap on the widget.
One of the steps below will make the widget workable again:
Launch and close the main app again. The main app will call WidgetCenter.shared.reloadAllTimelines() during sceneDidEnterBackground.
Press and hold on the widget, choose 'Edit widget', and select the desired Todo list.
One thing to take note of is that I am using IntentTimelineProvider instead of AppIntentTimelineProvider. The reason I am using 'older tech' is due to the limitation mentioned in https://developer.apple.com/forums/thread/741053
However, I am not sure whether this is the root cause of the problem.
Does anyone have any idea why such a problem occurs?
Thanks.