Post

Replies

Boosts

Views

Activity

VisionOS app with UIKit : error with window visibility
I am running into an exception whenever I try to open the app's window in visionOS simulator. The exception error message says: "Thread 1: "Error in UIKit client: window visibility must match its layer visibility!"" This is the same code that runs just fine on iOS where I setup the app's window and tab bar controller in code: - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Setup the UI - Override point for customization after app launch UIWindowScene *firstScene = (UIWindowScene *) [[[[UIApplication sharedApplication] connectedScenes] allObjects] firstObject]; self.mainWindow = [[UIWindow alloc] initWithWindowScene:firstScene]; self.mainWindow.backgroundColor = [UIColor systemBackgroundColor]; self.tabController = [[UITabBarController alloc] init]; [self.tabController definesPresentationContext]; self.mainWindow.rootViewController = self.tabController; [self.mainWindow makeKeyAndVisible]; // setup the tab bar later The exception comes from the makeKeyAndVisible line. I'm not sure what I need to do differently for a visionOS app to make it work. I'm using Xcode 15.1 Beta 2.
5
0
1.2k
Oct ’23
Increased number of CKErrorServerRejectedRequest
Hi, I have a CloudKit based app in production on the App Store for the past 5 years. One feature in the app downloads a lot of records, over a few different recordTypes, from a user's private database using an array of CKQueryOperations (using an NSOperationQueue). This has been working fine for the past few years, and even now works fine for most users, but an increasing number of users are seeing one of the operations in the array fail for CKErrorServerRejectedRequest. This has been happening over a few weeks now, and the customer support is getting burdensome. Asking the user to repeat the feature sometimes fails, and sometimes succeeds, with no obvious reason. This is also happening for operations for recordTypes where there aren't any records in the private database, as well as for recordTypes where there are hundreds of records. I haven't made any changes over the past year that directly impacts this process. Why would this sudden increase be happening and how do I go about analyzing and fixing it? Also, my current code handles this by cancelling all the operations in the operation queue, because the comment I saw in CKError.h for this error says "This is a non-recoverable error". I'm not sure I completely understand what that means ... is the operation non-recoverable (and hence I should retry by creating a new operation), or is the user's private database corrupted, or what? Would be great if I could get some insight / suggestions.
2
0
591
Oct ’23
CLLocationManager: getting kCLErrorDenied in widget
I am having some problem with accessing the CLLLocationManager location from my widget. It works fine with Xcode 15 running on a iOS17 simulator. But running it on a iOS17 device gives me an error in the delegate: To access the location manager, I have this class: class WidgetLocationManager: NSObject, CLLocationManagerDelegate { var locationManager: CLLocationManager? private var handler: ((CLLocation?) -> Void)? override init() { super.init() DispatchQueue.main.async { print("WidgetLocationManager: init") self.locationManager = CLLocationManager() if self.locationManager!.authorizationStatus == .notDetermined { print("WidgetLocationManager: init - auth status is Undetermined") } else { print("WidgetLocationManager: init - auth status = \(self.locationManager!.authorizationStatus)") } } } func fetchLocation(handler: @escaping (CLLocation?) -> Void) { self.handler = handler self.locationManager = CLLocationManager() self.locationManager!.delegate = self self.locationManager!.requestLocation() } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { if let lastLocation = locations.last { if (CLLocationCoordinate2DIsValid(lastLocation.coordinate) == true && abs(lastLocation.timestamp.timeIntervalSinceNow) < 60 && lastLocation.horizontalAccuracy < 200.0 && lastLocation.horizontalAccuracy > 0.0) { self.handler!(locations.last!) } } } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print("WidgetLocationManager: locationManager didFailWithError = \(error)") self.handler!(nil) } } When run on device, I get an error: WidgetLocationManager: locationManager didFailWithError = Error Domain=kCLErrorDomain Code=1 "(null)" Code = 1 in CLError is kCLErrorDenied ("Access to location or ranging has been denied by the user") This is despite getting the following output in the init method: WidgetLocationManager: init - auth status = CLAuthorizationStatus(rawValue: 4) The weird thing is that it works fine in the simulator. On device, I've tried deleting and reinstalling the app a couple of times, restarting the device, making sure the privacy setting is correct etc. Also, on the iOS17 device, when I am in the "Add Widget" page, the location manager runs fine in the preview screen, and shows the 'current location' to the user. But as soon as I add the widget to the home screen, it starts giving me this problem where the location can't be found, and I have to display an error message in the widget. I have the following keys in the Info.plist for the widget: NSLocationAlwaysAndWhenInUseUsageDescription NSLocationWhenInUseUsageDescription NSWidgetWantsLocation The app target also has the following keys in the Info.plist: NSLocationWhenInUseUsageDescription NSLocationAlwaysAndWhenInUseUsageDescription Any idea for what I can try to fix this problem? Thanks.
2
0
1.2k
Sep ’23
Replacing [[UIScreen mainScreen] scale] for visionOS
The [[UIScreen mainScreen] scale] API is unavailable for visionOS, but I use it in various places to pass into Apple's drawing APIs ... for e.g.: UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); and for generating thumbnails: QLThumbnailGenerationRequest *request = [[QLThumbnailGenerationRequest alloc] initWithFileAtURL:fileURL size:size scale:screenScale representationTypes:QLThumbnailGenerationRequestRepresentationTypeThumbnail]; What would be the best way to get the 'scale' factor in this case, when building for visionOS?
1
0
1.4k
Jul ’23
Problem with accessing keychain after update
Hi, I have an existing Mac app that stores some important values in the keychain. I am working on an update for the app, which was working fine while I was testing with debug builds. But when I build the app for Release and test the update using TestFlight, on trying to access the keychain item, I get prompted by the system: "MyApp wants to use your confidential information stored in "SyncSettingsValue" in your keychain" And the user now has to enter their password and click on "Allow", "Always Allow" or Deny. Obviously this is a really bad experience, and clicking on Deny will stop many features for the user. Why is this happening? I've updated the app 100s of times before and I've never had this problem. I don't believe I'm messing around with any certificate or provisioning profile since the last update, which was only a few weeks ago. How do I find out what is causing the problem here? Or is this a TestFlight issue that won't happen to users when they update through the App Store?
9
0
2.8k
Jun ’23
New warning when updating app in macOS Sonoma
Hi, I am testing out an update for my app in macOS Sonoma. I first installed the App Store version of my app on the device running macOS Sonoma, and it ran fine. I then installed an updated version of my app through TestFlight (built with macOS Ventura SDK), but when I run this updated version, I get prompted ”MyApp differs from previously opened versions. Are you sure you want to open it?". Why is this happening? Is this warning only because the app is updated through TestFlight, or do I need to do something to prevent this warning from happening when I update my app through the App Store? I see this mentioned in an Apple security update:: App Sandbox now associates your macOS app with its sandbox container using its code signature. The operating system asks the person using your app to grant permission if it tries to access a sandbox container associated with a different app. For more information, see Accessing files from the macOS App Sandbox. My app is already sandboxed, and I'm not trying to access a different app's sandbox container, just my own. For the TestFlight build, it probably also uses the same Release configuration that the App Store build uses. I might have changed my provisioning profiles recently because they expired. Would that affect this and cause a prompt to be showed? Would love to know more about this prompt and how to avoid it. Thanks.
3
0
2.4k
Jun ’23
Bridging header issue when building for visionOS SDK
When I build my iOS app for the visionOS simulator, it works fine, and it runs in the compatibility mode. When I try to build against the new visionOS SDK, I get build errors related to the bridging header: SimpleList-Bridging-Header.h:5:9: error: 'MyFramework/MyFramework.h' file not found #import <MyFramework/MyFramework.h> ^ 1 error generated. :0: error: failed to emit precompiled header '...DerivedData/CJ-bkylkdabwgxlstdympoknglfewum/Build/Intermediates.noindex/PrecompiledHeaders/SimpleList-Bridging-Header-swift_3HAL1I7NW16O7-clang_3RN0BYG6SZHIS.pch' for bridging header '.../SimpleList/Classes/SimpleList-Bridging-Header.h' 2 errors generated. I don't know why it's not finding my framework for the visionOS SDK, while it works fine for the iOS SDK. The framework is included in the project itself (i.e. it's not an external dependency). Any tips?
2
0
1.5k
Jun ’23
Removing dependencies for visionOS
Hi, My iOS app includes 4 dependencies added through SPM, and a xcframework file from an external source. When I build the iOS app for the visionOS simulator, it works fine, and it runs in the compatibility mode. When I try to build for the new visionOS SDK, I get build errors related to these external dependencies, like "When building for visionOS Simulator, no library for this platform was found ..." How do I remove these dependencies for just the visionOS SDK? Any help would be appreciated. Thanks.
1
1
1.7k
Jun ’23
Using containerBackground with iOS16 deployment
Hi, I need to keep supporting iOS16 for my widgets. I'm having a problem using the iOS17 'containerBackground' API. Ideally I would use a view extension: extension View { func adoptableWidgetBackground(_ color: Color) -> some View { if #available(iOS 17.0, *) { containerBackground(for: .widget) { color } } else { background(color) } } } But this gives an error: Branches have mismatching types 'some View' (result of 'Self.containerBackground(for:alignment:content:)') and 'some View' (result of 'Self.background(_:alignment:)') If I try to use this directly on the 'body' view modifier like this: if #available(iOS 17.0, *) { .containerBackground(for: .widget) { ContainerRelativeShape().fill(Color.init(UIColor.quaternarySystemFill)) } } else { .background(ContainerRelativeShape().fill(Color.init(UIColor.quaternarySystemFill))) } This doesn't work either. Instance member 'containerBackground' cannot be used on type 'View' How do I use this correctly?
3
1
5.8k
Jun ’23
Xcode 15 linking error
Hi, I am getting a linking error when building my app to run against an iOS17 device, using Xcode15. Same project builds and runs fine with Xcode 14 and iOS16. The linking error just says: clang: error: unable to execute command: Segmentation fault: 11 clang: error: linker command failed due to signal (use -v to see invocation) Not sure what I should try to overcome this. I can't run my app on an iOS17 device. It builds, links and runs just fine on a simulator.
29
16
25k
Jun ’23
Create Swift Package with 3rd party dependencies
I am trying to create a Swift Package for a custom framework I'm building for a client. The framework has a dependency on a couple of 3rd party frameworks. I've read about how even though binary frameworks don't support dependencies directly, there is way to do this with a 'wrapper' target, so this is what I came up with for Package.swift: let package = Package( name: "SBCardScannerFramework", platforms: [ .iOS(.v16) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "SBCardScannerFramework", targets: ["SBCardScannerFramework-Target"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"), .package(url: "https://github.com/marmelroy/PhoneNumberKit.git", from: "3.3.3") ], targets: [ .target(name: "SBCardScannerFramework-Target", dependencies: [ .target(name: "SBCardScannerFramework", condition: .when(platforms: [.iOS])), .product(name: "Algorithms", package: "swift-algorithms"), .product(name: "PhoneNumberKit", package: "PhoneNumberKit") ] ), .binaryTarget(name: "SBCardScannerFramework", path: "SBCardScannerFramework.xcframework") ] ) This works, and I can add the package to my test project and import the framework and it links against the dependancies as well, and works correctly. The problem is that every time I run the app, it also shows these messages in the Xcode console: objc[845]: Class _TtC14PhoneNumberKitP33_0FE53357E470A64027C8F0CAF7B114C812BundleFinder is implemented in both /private/var/containers/Bundle/Application/EEE0C0A6-4FF5-44BC-B81A-F95401219D32/TestSBCardScannerFrameworkImport.app/Frameworks/SBCardScannerFramework.framework/SBCardScannerFramework (0x100f4aaf0) and /private/var/containers/Bundle/Application/EEE0C0A6-4FF5-44BC-B81A-F95401219D32/TestSBCardScannerFrameworkImport.app/TestSBCardScannerFrameworkImport (0x10069b778). One of the two will be used. Which one is undefined. There's multiple lines for different classes that show the "Class X is implemented in both [.../MyApp.app/Frameworks/MyFramework.frameworkMyFramework/] and [.../MyApp.app/MyApp]". I'm not sure how to avoid this problem, and whether this could cause a problem down the line. The framework that is the basis for this Swift Package is linked against the two dependencies, because I wouldn't be able to build the framework without them. But they also need to be added to the app target (at least, and if I don't, I get a run-time crash when using the PhoneNumberKit initializer. PhoneNumberKit/resource_bundle_accessor.swift:40: Fatal error: unable to find bundle named PhoneNumberKit_PhoneNumberKit Is there a good way to resolve this issue? I'm worried this will could be a problem for the client when they integrate it into their app, and the app is deployed to 1000s of devices.
0
0
1.1k
May ’23
Distributing Swift Package, without remote repo
Hi, I am working on distributing a 'framework' I made to a client. The framework itself has a couple of dependencies on a couple of 3rd-party frameworks. Also, I don't want to disclose my source code to the client. So after doing some research, it seems like the best way to do this would be to use Swift Packages, and make it a binary distribution, which would basically wrap a .xcframework (which I would generate with my source code). But I'm confused about the next steps ... how would I go about sharing the 'package' with the client? Would I just zip up the 'package' folder and email it to them, and they can unzip it on their end, and add it to their project by using "Add local package"? Or is there a more elegant way to do this, which doesn't require publishing a package publicly?
0
0
513
May ’23
Differences between .framework and .xcframework
Hi, I am developing a 'framework' for a client so they can embed some of my code into their own custom app. I'm confused a bit about the best option to distribute this. I have created an iOS 'framework' within my Xcode project and added all the necessary files there. Can I just build the framework and send them the build folder for the framework? Or is it better to generate an .xcframework that I read about somewhere? I'm just not completely sure about the benefits for distributing an .xcframework file (which there doesn't seem to be an option to generate from Xcode) over just the .framework folder from the built products? Thanks.
1
1
4.3k
May ’23
StoreKit2: using AppTransaction.shared triggers user login
Hi, I plan to use the new AppTransaction.shared API in StoreKit2 to find the user's original purchase date and version for my macOS app. However, when testing this running in the debugger, the app shows up with an App Store login prompt, asking for my login and password, which is undesirable. I wanted to know if this is just a sandbox quirk, or is the "AppTransaction.shared" API supposed to trigger this prompt for all users, even in production? In that case, is it like the old "Refresh receipt" API where we shouldn't trigger this automatically when a user opens the app, and instead have a button somewhere that triggers the call? Thanks.
1
0
690
Mar ’23