Post

Replies

Boosts

Views

Activity

How to correctly load video selected with PHPickerViewController?
Hello! I am playing around with the PHPickerViewController and so far I was able to get the selected images by loading them into UIImage instances but I don't know how to get the selected video. Below is the relevant implementation of the method: func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]): let provider = result.itemProvider guard provider.hasItemConformingToTypeIdentifier(AVFileType.mov.rawValue) else { return } 						provider.loadItem(forTypeIdentifier: AVFileType.mov.rawValue, options: nil) { (fileURL, error) in 								if let error = error { 										print(error) 										return 								} 								guard let videoURL = fileURL as? URL else { return } 								DispatchQueue.main.async { 										let fm = FileManager.default 										let destination = fm.temporaryDirectory.appendingPathComponent("video123.mov") 										try! fm.copyItem(at: videoURL, to: destination) 										let playerVC = AVPlayerViewController() 										playerVC.player = AVPlayer(url: destination) 										self.present(playerVC, animated: true, completion: nil) 								} 						} I get crash trying to copy the item. It says the source file does not exists but the path looks real to me. "The file “3C2BCCBC-4474-491B-90C2-93DF848AADF5.mov” couldn’t be opened because there is no such file." I tried it without copying first and just passing the URL to AVPlayer but nothing would play. I am testing this on a simulator. Thanks for help!
13
0
10k
Sep ’23
Issues with NEHotspotConfigurationManager (unknown & internal errors)
Hello, I am using apply(_:completionHandler:) on the NEHotspotConfigurationManager.shared to prompt the user to join particular WiFi network. In my testing it works all the time, but via Sentry I am getting a lot of errors with this code from the NEHotspotConfigurationErrorDomain domain. In particular I am getting: NEHotspotConfigurationErrorInternal and NEHotspotConfigurationErrorUnknown. It doens't appear to be connected to particular iOS version nor device. The WiFi network should be pretty same too - this is an app that connects to the Nintendo Switch game console. From some anectodal reports it looks like when the user tries to connect via Camera.app (by scanning QR code) that works for the WiFi connection. It is possible to debug this further?
4
0
1.5k
Jan ’22
Cannot get DeviceActivityReport to work
I am unable to make any progress regarding DeviceActivityReport. The session from WWDC 2022 covers it very briefly. What I (hopefully correctly) understood is that we need to create an extension of type Activity report and inside it implement the body which is DeviceActivityReportScene that will display the charts and what not. And then in the app, we need to use DeviceActivityReport with SwiftUI to show the report which will be run in sandbox from the extension. But I cannot get anything to show up on the screen. Even when my extension view is just a static text to verify something gets displayed. I am trying to create the device activity report without any filter which should give me all activity data per the docs. This is shown in the Xcode console for the view that uses DeviceActivityReport. 2022-06-17 18:08:47.219785+0200 DeviceActivityTest[9613:954204] [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler} 2022-06-17 18:08:47.219862+0200 DeviceActivityTest[9613:954204] [default] Attempt to map database failed: permission was denied. This attempt will not be retried. 2022-06-17 18:08:47.219911+0200 DeviceActivityTest[9613:954204] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler} 2022-06-17 18:08:47.290070+0200 DeviceActivityTest[9613:954204] [default] Remote viewcontroller request failed: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 9615 named com.apple.DeviceActivityUI.DeviceActivityReportService.viewservice was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid." UserInfo={NSDebugDescription=The connection to service with pid 9615 named com.apple.DeviceActivityUI.DeviceActivityReportService.viewservice was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.}
17
2
5.6k
Mar ’23
Using FamilyActivityTitleView/FamilyActivityIconView Label sometimes freezes entire app
Hello, we have been using the SwiftUI Label with the Family Controls tokens (ApplicationToken, ActivityCategoryToken - https://developer.apple.com/documentation/swiftui/label/init(_:)-39rkz) And noticed that sometimes (quite rarely) the loading of the labels would take so long that it would freeze the entire app. Unfortunately as this only happened to our users (few times during user interviews) we aren't able to reproduce it on our devices and profile it. My guess is that this "mapping" of tokens to images happens entirely on the UI thread because it is supposed to be fast but sometimes there is huge delay and everything freezes. It would be great if the labels were somehow "prepared" on the background and the Label view would perhaps show some sort of loading and then get updated with the image of the app or category. This freezing was happening even when our app showed at most six labels on the screen. We tried some workarounds, namely to render the Label components in a backround and then use it as an image but instead of app icons we got yellow squares with red cross - probably due to privacy reasons. Anyone run into this issue? Any solutions?
5
2
1.6k
Jun ’23
Opening app's iCloud Drive folder in the Files.app?
Hello, I am unable to use UIApplication.shared.open to open URL to my app's iCloud Drive folder that I am using to export files to. I am using this method to get the URL: url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents") But when testing this URL with UIApplication.shared.canOpenURL I am getting back false. -canOpenURL: failed for URL: "file:///private/var/mobile/Library/Mobile%20Documents/iCloud~MyApp/Documents/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" Since my app's local document folder can be opened by prefixing the URL with shareddocuments:// I tried that for iCloud Drive URL, but didn't work either. Is this even possible?
0
0
6.3k
Jan ’22
Starting `NEPacketTunnelProvider` very rarely gets stuck. How to debug?
Hello, I have successfully implemented NEPacketTunnelProvider network extension in iOS app which works fine most of the time. By working fine I mean it starts, stops (it is configured to disconnect on sleep) and handles network traffic as expected. However I have a few reports that sometimes it doesn't start correctly. It hangs on "Connecting..." when checking the Settings -> VPN. As far as I can tell even with waiting for minutes, it seems still stuck. Re-installing either the VPN provider extension or entire app fixes this problem. What could be causing such random and very rare issues? This doesn't seem to be connected to single iOS version for example.
5
0
1.2k
May ’22
Slow performance when using Screen Time API?
Hello, our app uses the frameworks FamilyControls, ManagedSettings and DeviceActivity. It runs smoothly in like 99% cases but we have some support requests that mention the app being incredibly slow - like seconds to register button presses. These reported incidents deal with calls to these APIs mentioned above. One of the frequent complaint is that code that manipulates with ManagedSettingsStore is slow and the whole app becomes unresponsive. Unfortunately I am not able to reproduce this on my devices so cannot run it through the Instruments. Anyone has experience with this? PS: These reports are frequently from new and fast devices - like iPhone 13 & iPhone 14 so that should not be the case.
0
1
1.2k
Nov ’22
Scanning QR code with AVCaptureDevice issues on iPhone 14 Pro
Hello, I am using simple AVCaptureDevice setup to scan QR code from LCD screen, usually the distance is 5 to 15 centimeters. This has been working fine for a long time, with correct focus and everything. Today I noticed that my iPhone 14 Pro cannot focus on these smaller distances while my developer iPhone SE 2020 can easily detect the QR code in basically all cases. I have been using this code to create the capture device: AVCaptureDevice.default(for: .video) And then some settings: if videoCaptureDevice.isAutoFocusRangeRestrictionSupported { videoCaptureDevice.autoFocusRangeRestriction = .near } if videoCaptureDevice.isFocusModeSupported(.continuousAutoFocus) { videoCaptureDevice.focusMode = .continuousAutoFocus } As I said, this worked great prior to noticing the issue on iPhone 14 Pro. After some searching I found recommendations to use another device type like: builtInDualWideCamera and other available types. I tried all of them and they either behave like the default (meaning I cannot scan the code unless I move the phone way out) or they always seem to use the 0.5 Ultra-Wide camera which looks weird and the scanning experience is not ideal. What is the best approach to have QR scanning with these new phones?
3
1
3.6k
Dec ’22
Full calendar access needed to display event details that my app created?
Hello, I watched the EventKit session from WWDC 23 (https://developer.apple.com/videos/play/wwdc2023/10052/) that details the new permission changes. The ability to have just write access to the calendar is great, however my app also offers the user to view the already created event and to possibly edit it further via EKEventEditViewController. The event in question is release date of a videogame, so there might be needs for edit and based on saved event identifier, I am able to show different icon to let the user know that event exists. When the user taps on the icon, I use the eventStore.event(withIdentifier:. So I guess I will need the new "full access" with new prompt API to keep my functionality? Is there any possibility that this will change and apps would be able to query event they created? Thanks
1
0
1.9k
Jun ’23
DeviceActivityReport no longer works on iOS 16 with Xcode 15
Hello, we had working DeviceActivityReport in our app for months now. However when building with Xcode 15 (previously betas, now the GM), the activity reports no longer displays anything on iOS 16 devices. If we run it with Xcode 14, it works. But with Xcode 15 builds, the device activity report only works on iOS 17 devices :( I am able to see some somewhat generic errors in the Console.app when opening screen that contains the report. -[_EXServiceClient launchWithConfiguration:error:]_block_invoke failed with error: Error Domain=com.apple.extensionKit.errorDomain Code=2 UserInfo={NSUnderlyingError=0x280b9b600 {Error Domain=RBSRequestErrorDomain Code=5 UserInfo={NSLocalizedFailureReason=<private>}}} Failed to create extensionProcess for extension '<private>' error: Error Domain=com.apple.extensionKit.errorDomain Code=2 UserInfo={NSUnderlyingError=0x280b9b600 {Error Domain=RBSRequestErrorDomain Code=5 UserInfo={NSLocalizedFailureReason=<private>}}}. Failed to make extensionProcess with error: Error Domain=com.apple.extensionKit.errorDomain Code=2 UserInfo={NSUnderlyingError=0x280b9b600 {Error Domain=RBSRequestErrorDomain Code=5 UserInfo={NSLocalizedFailureReason=<private>}}} Failed to get extension process and XPC endpoints with error: Error Domain=com.apple.extensionKit.errorDomain Code=2 UserInfo={NSUnderlyingError=0x280b9b600 {Error Domain=RBSRequestErrorDomain Code=5 UserInfo={NSLocalizedFailureReason=<private>}}} And I managed to find one error that is specific to our activity extension which says just: Cannot track instance that is already dead!
3
3
1.8k
Sep ’23
SwiftUI StateObject crash: “failed to demangle witness for associated type 'Property’”
Hello, we have weird crash in our app that mostly seems to happen right after launch. It is quite rare and so far I haven’t been able to reproduce it (the info below comes from Crashlytics). The main error message I have is this: failed to demangle witness for associated type 'Property' in conformance 'SwiftUI.StateObject<AppBlock.QuickBlockActivityViewModel>.(unknown context at $18f34e5b8).Box: DynamicPropertyBox' from mangled name ' � ��yxG' - subject type x does not conform to protocol ObservableObject And here is the stack trace: Crashed: com.apple.main-thread 0 libsystem_kernel.dylib 0x7200 __pthread_kill + 8 1 libsystem_pthread.dylib 0x71ac pthread_kill + 268 2 libsystem_c.dylib 0x20ca0 abort + 180 3 libswiftCore.dylib 0x3d7304 swift::fatalError(unsigned int, char const*, ...) + 134 4 libswiftCore.dylib 0x3d7324 swift::warningv(unsigned int, char const*, char*) + 30 5 libswiftCore.dylib 0x3ee678 swift_getAssociatedConformanceWitnessSlowImpl(swift::TargetWitnessTable<swift::InProcess>*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*) + 2078 6 libswiftCore.dylib 0x3ecb9c swift_getAssociatedTypeWitness + 236 7 SwiftUI 0x5b838 OUTLINED_FUNCTION_49 + 640 8 SwiftUI 0xa8d68 OUTLINED_FUNCTION_513 + 16260 9 SwiftUI 0x58244 OUTLINED_FUNCTION_177 + 10892 10 SwiftUI 0x95524 OUTLINED_FUNCTION_1160 + 6632 We are using the view model (QuickBlockActivityViewModel) in a SwiftUI view that is part of collection view using the new UIHostingConfiguration from iOS 16. Our view model is a subclass of view model for older iOS versions that conforms to ObservableObject and is marked as @MainActor. And the view model is used like this: @StateObject private var viewModel = QuickBlockActivityViewModel() Internally the view model uses Combine to monitor a couple of states from other parts of the app to modify its properties.
5
2
2.5k
Sep ’24
ForEach in Widget: How to fit only the number of items that can be fully visible?
Hello, I have this widget: And as you can see down at the bottom, next item is very barely visible. This is because on different devices (combined with varied text sizes + number of lines) the vertical space differs quite a lot. In the past I had the limit set to 4 items in the bottom part but that often left empty space at the bottom or even overflowed still on iPhone SE. What is the proper way to tell ForEach (or any other component) to "layout as many items as can fully fit, but no more". The only solution I could think of is to use ViewThatFits and try first rendering 6 items, then 5 and so on to find the count that fully fits. But that seems maybe too complicated? Thanks.
4
2
1.5k
Oct ’23
UIHostingController adds extra backgrounds on iOS 26.1, breaks Liquid Glass effect
I was trying to figure out why my bottom sheet looks weird and doesn't have the "proper glass" look. I found that this issue seems to be new to iOS 26.1. See the images below, they show the same view hierarchy (in this case UIHostingController configured as bottom sheet that has NavigationStack and content. On iOS 26.1 there seems to be extra two layers of background - even though I am no adding any. iOS 26: iOS 26.1 Has anyone experienced something similar? Any workarounds? I am happy to completely disable the glass effect for this bottom sheet if it helps. The screenshots show one sheet, but the same thing happens for another ones.
1
2
139
2w
Uploading app with Family Controls to TestFlight?
Hello, does anyone have any info/insight when we will be able to test app version that contains the Family Controls entitlement to TestFlight? iOS 16 is getting really close.. When we try to upload the build, Xcode shows the entitlements error and the Apple Developer portal shows that Family Controls is still available only for Development profile. Thanks!
10
1
7.0k
Feb ’23
FamilyControls: FamilyActivityPicker needs bug fixes and parity with the system picker
Hello, we have been using the new Screen Time APIs for a long time. While the API is simple to work with, we have persistent issues with the FamilyActivityPicker component. I have filled many feedbacks but have yet to notice any changes/fixes in the point releases. One issue we see frequently is that expanding categories does not work. Instead, the picker shows just a single row, and you need to scroll up or down to “refresh” it and make it expand correctly. Another problem is that some apps are “hidden” in the “Other” category, and our users have trouble discovering them. I have been part of a few user interviews we did recently, and basically, every user had some issue with the FamilyActivityPicker. For one user, it just disappeared, and they needed to re-open the app screen, which contains the picker, to fix it. Sometimes the picker shows apps that have already been uninstalled from the device. The system picker from Screen Time works much better. For one, websites have dedicated category, which makes it much easier to navigate. I have seen instances where you would open the “Productivity” category and see like 50 websites - making it super hard to find apps. The system picker also allows users to manually enter a website that FamilyActivityPicker does not provide. Also, the system picker offers a search bar which is not possible with FamilyActivityPicker. Some users get frustrated with finding the specific apps in the picker if they have many apps installed. Since FamilyActivityPicker is critical to user experience in our app, we would appreciate it if the FamilyActivityPicker would be on par with the Screen Time built-in picker. Thanks 🙏
3
1
1.9k
Apr ’23