Post

Replies

Boosts

Views

Activity

iOS 16 - how to get more than 1 AppIntents / AppShortcut
I've implemented 2 different AppIntents, each includes their own AppShortcutsProvider with phrases unique to each AppIntent. Individually, they work great. But, when I try to include both in my app, only the last one defined works. In my ContentView.onAppear(), I've tried calling: ShortcutsOne.updateAppShortcutParameters() ShortcutsTwo.updateAppShortcutParameters() and only those defined in ShortcutsTwo are recognized by Siri. I've also tried including ShortcutsTwo's AppShortcut(intent:, phrases) into ShortcutOne's AppShortcutsProvider (since it's static var appShortcuts: is defined as an array, ie, [Shortcuts] - but that doesn't work either. Overall, I've found the system to be rather temperamental. ie, I have had to power off my iPhone & reboot my Mac to get changes recognized. Any thoughts on how to get 2 or more AppIntents to work in one app?
1
0
1k
Feb ’23
Instruments "can't find source code for selected symbol"
I'm attempting to use Xcode & Instruments to Time Profile my app - but there's something in my environment which is preventing Instruments from linking back to source code. It's this way with all of my apps, and even with a recent tutorial from Kodeco (RayWenderlich.com) - so I'm suspecting my environment. In Xcode, I select Product -> Profile, which launches Instruments. I select Time Profiler. I click the record button, use the app such that the area of interest is executed, hit stop. In the Profile section of Instruments, I can see the stack traces, and many of them have function names which are clearly from my app. When I double-click on them, I expect them to show the source code from Xcode (as detailed in apple docs and the Kodeco tutorial). However, instead I get this screen which says "Error: Can't find source code for selected symbol" Most of the question / answers I've seen come from many years ago, which suggests that my problem isn't common - which has me wondering what I've got lurking in my environment that's preventing this from working. I'm using an M1 Mac w/ Ventura 13.1 Beta (22C5044e) and Xcode Version 14.1 (14B47b). Any thoughts will be greatly appreciated...
1
0
816
Nov ’22
WatchOS 9.1 / HealthKit error “Unable to transition to desired state”
I’ve got a WatchOS app in the App Store, but since WatchOS 9.1 it’s no longer updating workoutManager.heartRate nor is it saving workout data to Apple’s Health store. Curiously, workoutManager.builder?.elapsedTime, is still correct. No errors are thrown while executing these lines of code: session = try HKWorkoutSession(healthStore: healthStore, configuration: configuration) builder = session?.associatedWorkoutBuilder() … and shortly after this completion block executes, session?.startActivity(with: startDate) builder?.beginCollection(withStart: startDate) { (success, error) in print("WorkoutMgr.startWorkout() - The workout has started.") } … I get the following error messages in my log: 2022-09-28 18:15:01.380071-0500 AppName WatchKit Extension[1240:609337] [workouts] HKLiveWorkoutBuilder_6311 [B194]: (#w0) Failed to update target construction state: Error Domain=com.apple.healthkit Code=3 "Unable to transition to the desired state from the Error(6) state (event 1). Allowed transitions from the current state are: { }" UserInfo={HKErrorParameter=@"", NSLocalizedDescription=Unable to transition to the desired state from the Error(6) state (event 1). Allowed transitions from the current state are: { }, HKErrorClass=HKStateMachine, HKErrorSelector=_handleEvent:date:error:completion:} No developer.apple.com nor StackOverflow.com searches have resulted in any relevant discussions. Any help will be GREATLY appreciated!
1
3
1.4k
Sep ’22
How to register my app for openURL()
In the following app, all Buttons open the expected app except the 1st one for “MyApp”. MyApp is installed on the iPhone, but I don’t know what I need to do in order for it to behave similarly to Apple’s Maps & Music, and Uber… struct ContentView: View { @Environment(\.openURL) var openURL var body: some View { Button("Launch MyApp") { openURL(URL(string:"MyApp://")!) } Button("Launch Maps") { openURL(URL(string:"Maps://")!) } Button("Launch Music") { openURL(URL(string:"Music://")!) } Button("Launch Uber") { openURL(URL(string:"Uber://")!) } } }
1
0
698
Sep ’22
Please send this bug to NSUbiquitousKeyValueStore (whaaa???)
I’m getting this very weird error (send this bug to NSUKVS) when trying to get data from my app into both a lock-screen widget and an Apple Watch app. Most documentation and online tutorials suggest using App Groups and UserDefaults(suiteName:). I have implemented this and can write to and read from my iOS app to UserDefaults(suiteName:) - no problem. However, despite the fact that the UserDefaults(suiteName:) is found on both the lock-screen widget and the Apple Watch app - there is never any data found within. One month ago, Eskimo posted (https://developer.apple.com/forums/thread/710966) that the UserDefaults won’t work in modern devices because the WatchOS app won’t run in an extension on the phone, so we need to use another device-to-device mechanism. OK, so hoping that one solution will work for both targets, I built a tiny app that intends to implement NSUbiquitousKeyValueStore. (Please note that I have added the iCloud Key-value storage entitlement to the app target.) Import SwiftUI struct ContentView: View { var uks = NSUbiquitousKeyValueStore() var body: some View { Text(readData()).onAppear { writeData() } } func writeData() { uks.set("Hello", forKey:"name") uks.synchronize() } func readData() -> String { return uks.string(forKey:"name") ?? "n/a" } } Unfortunately, I’m getting this: 2022-09-18 17:40:32.538800-0500 Widget[5717:1877533] [Connection] Error synchronizing with cloud for store <(DevID.BundleID.AppName)>: Error Domain=SyncedDefaults Code=101010 "Tried to access unknown store DevID.BundleID.AppName" UserInfo={NSLocalizedDescription=Tried to access unknown store DevID.BundleID.AppName} 2022-09-18 17:57:58.655802-0500 Widget[5727:1883819] [Connection] BUG IN KVS: Tried to access store that is unknown to the system (DevID.BundleID.AppName). Please send this bug to NSUbiquitousKeyValueStore. Which begs the question: just how, exactly, does one “send a bug to NSUbiquitousKeyValueStore”??? 🤣 Is this possibly a problem with my AppleID? I ask because I’m getting really weird different results from my app which is currently in the App Store - depending upon if I’ve downloaded my app from Xcode or if I’ve downloaded it from the AppStore. Just wondering if my AppleID has somehow gotten into a corrupted state because of my Promo code (StoreKit) testing… Any and all ideas / suggestions welcomed…
4
2
1.9k
Sep ’22
How to read/write to App1’s database from App2?
I have 2 apps in the App Store, and each uses the private database in its own CloudKit container. (ie, App1 uses “iCloud.com.company.App1” and App2 uses “iCloud.com.company.App2”) I want to add a feature to App2 which will require App2 to read/write to the App1 database. To be clear, we’re talking about 2 apps, 2 private databases, but all access occurs under the same user’s AppleID. In App2, I’ve tried to create 2 NSPersistentCloudKitContainers - one for each App’s database as follows: @main struct App2: App { @StateObject var app1DB = PersistenceApp1.shared @StateObject var app2DB = PersistenceApp2.shared @SceneBuilder var body: some Scene { WindowGroup { NavigationView { ContentView() .environmentObject(app1DB) .environmentObject(app2DB) } } } } …where each Persistence object is defined like this… class PersistenceApp1: ObservableObject { static let shared = PersistenceApp1() let container: NSPersistentCloudKitContainer init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: “App1”) // expecting to use CloudKit container id: “iCloud.com.company.App1” … } … } All read & write operations called from App2 using app1DB (unexpectedly) reads & writes the Entity (which was defined in the App1.xcdatamodeld) to show up in “iCloud.com.company.App2”. So I end up with the Entity duplicated inside “iCloud.com.company.App1” as well as “iCloud.com.company.App2”. None of App2’s reads nor writes actually use “iCloud.com.company.App1” - they all just use the duplicate App1 entity that shows up inside of “iCloud.com.company.App2”. Looking in CoreData.NSPersistentCloudKitContainer, I see the following comment: NSPersistentCloudKitContainer managed one or more persistent stores that are backed by a CloudKit private database. By default, NSPersistentContainer contains a single store description which, if not customized otherwise, is assigned to the first CloudKit container identifier in an application's entitlements. Instances of NSPersistentCloudKitContainerOptions can be used to customize this behavior or create additional instances of NSPersistentStoreDescription backed by different containers. Which suggests why I’m seeing this. However, when I look for samples using NSPersistentCloudKitContainerOptions, all I find is references to using the .shared database as promoted via WWDC21-10015 - which focuses on sharing CloudKit data between different users - which is not my use case. Question 1: does anyone have any ideas on how to configure the NSPersistentCloudKitContainerOptions to accommodate my use case? Question 2: does anyone want a micro-consulting gig to help me get this working?
2
0
1k
Sep ’22
iOS 16 beta 4 broke UITextView.appearance().backgroundColor
in iOS 16 beta 4, the following code ignores the UITextView.appearance().backgroundColor = .clear struct ContentView: View { @State var text = "Type something here." var body: some View { ZStack { Color.blue.ignoresSafeArea() TextEditor(text: $text) .frame(height: 100) .padding([.leading, .trailing], 40) } .onAppear { UITextView.appearance().backgroundColor = .clear } } } Earlier, I had assumed it was Xcode 14 beta 4 - but further investigation shows that it's the new iOS beta. I would obviously prefer that TextEditor correctly handle it's own .background() method, but in the meantime, any ideas for a workaround?
4
0
1.8k
Jul ’22
CloudKit Console unresponsive
Over the past few days, my experience with CloudKit Console has been terribly frustrating... recurring http timeouts, 502 Bad Gateways, and - worst of all - I've got an app which is posting to CloudKit via CoreData and although it DOES sync the data between my devices - CKConsole fails to show ANY records in the specified database... (I've even gone so far as to check BOTH public and private databases, in EACH of the CK Containers associated with my AppleID - desperately hoping to find these records via CKConsole - but alas, no such luck.) Has anyone built an app (or MacOS application) which mirrors (and more importantly, improves upon) the functionality that is supposed to be available via CKConsole? Prior to making the switch to using CloudKit, I've previously used MySQL on a long list of non-iPhone applicaitons - and having access to a command-line interface to the SQL database has always been a very valuable part of my development process. Can anyone suggest ways to re-introduce that CLI type of rapid prototyping into a CloudKit project? Is there a CLI that speaks directly to CloudKit databases (both public and private)? Many thanks...
2
0
957
Aug ’21
@available(iOS 15.0, *) causes runtime crash on iOS 14.7 device
The following app builds, but causes a runtime crash when trying to execute on an iOS 14.7 device. Using Xcode 13b5, macOS Monterey b5, iOS 15.b6 & iOS 14.7 import SwiftUI struct ContentView: View { @State private var text = "This app causes a runtime error on ios 14.7" @available(iOS 15.0, *) @FocusState var isInputActive: Bool var body: some View { if #available(iOS 15.0, *) { TextEditor(text: $text) .focused($isInputActive) } else { // ios14 or < TextEditor(text: $text) } } }
8
0
7.5k
Aug ’21
iPadOS 15 beta 2 - not updating
I'm trying to update to 15 beta 2 a brand new iPad Pro 12.9 running 14.5.1, from a brand new M1 MBAir running Monterrey beta 2 (for M1 Macs), and it was "updating" for a couple of hours. I gave up and then downloaded & installed "Device Support for iOS 15" - and tried again. Same results. I see that there's a known issue regarding the 11" iPad Pro - but does anyone have any suggestions for me? I do have a 2020 iMac that's running Big Sur 11.4 - should I attempt the update from there?
5
0
1.9k
Jun ’21