Post

Replies

Boosts

Views

Activity

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
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
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
NEPacketTunnelProvider does not seem to be capturing all the traffic
Hello, I initially started the discussion over at Swift Forums - https://forums.swift.org/t/issue-with-connect-proxy-some-connections-dont-work-probably-sockets/45575 because I am using SwiftNIO but it appears that it makes more sense here. I have an app with NetworkExtension of the packet tunnel provider type. So I am using the NEPacketTunnelProvider. As part of the extension, I have SwiftNIO server with connect proxy which is used to route the traffic. This works great in almost all cases, but apps like Signal or WhatsApp don't work. They don't display any kind of "no connection" indicator but the messages aren't send or received. Over at Swift Forums I got an answer from Quinn “The Eskimo!” that I think points to the actual problem: My experience is that a lot of these ‘chat’ apps explicitly bind their connections to the WWAN interface, which means they don’t use the default route and thus aren’t seen by the packet tunnel provider. My packet tunnel provider is configured to use the default routes for IP4 and IP6. So my concern is how to configure it, that it works also for the chat apps? There are couple of apps from the App Store that I tried which use this same approach and while they are active, Signal works fine. Yes, I know this solution is not ideal and not the main intended usecase for packet tunnel, but it is the only option available on iOS.. Thanks for help! Happy to clarify further.
9
0
2.4k
Jul ’23
How to setup `matchDomains` for NEPacketTunnelProvider?
Hello, in my usecase, I want to use the matchDomains property, so my VPN (NEPacketTunnelProvider) handles traffic for just some apps and not everything that happens on the device. But settings matchDomains to anything other than [""] doesn't seem to work properly. It works for websites in Safari but in my testing not for other apps. Let's use Instagram as an example: let proxySettings: NEProxySettings = NEProxySettings() proxySettings.matchDomains = ["instagram.com"] With this settings, using the Instagram app doesn't send traffic to my VPN. However if I set something like "theverge.com" as the domain, it gets set to my app. According to the docs, the matchDomains uses suffixes: If the destination host name of a HTTP connection shares a suffix with one of these strings then the proxy settings will be used for the HTTP connection. Otherwise the proxy settings will not be used. I also tried wildcards like *.instagram.com without much luck. How would I go about this? Is there any internal limits on how many domains I can match like this? Thanks
9
0
1.8k
Jul ’21
How to re-enable disabled VPN configuration?
Hello, I noticed an issue with my VPN configuration created with NETunnelProviderManager. When the user has multiple apps that use VPN configuration and are active, I cannot activate my network extension. I am getting this error: NEVPNError.Code.configurationDisabled For ObjC it's NEVPNErrorConfigurationDisabled An error code indicating the VPN configuration associated with the VPN manager isn’t enabled. So if this happens, I need to open Settings - VPN and select my app's profile. How to do this programatically? Other apps are able to re-enable their VPN profile, if another one was selected.
7
0
3.1k
Aug ’22
Specify WiFi password for ASDiscoveryDescriptor?
Hello, I am looking into the newly announced Accessory Setup Kit and I'd like to replace my manual WiFi connection setup with it, but I cannot find a way how to specify WiFi password when configuring ASDiscoveryDescriptor, only ssid or ssidPrefix can be specified? Is it really not possible to connect to WiFi with password with this new framework? That kind of makes it unusable for my use case :( Since the accessory has password.
7
0
1k
Jul ’24
Cannot confirm my trader info - apps removed soon in the EU?
Hello, I submitted my trader information in March 2024 for the Digital Services Act. Last Friday I got App Store Connect email saying that my info couldn't be verified and that I need to resubmit otherwise my apps won't be available in the EU in 14 days. This is quite scary, I don't want to have my apps removed but I cannot resubmit either. In ASC Business section I see "In Review" as the status for my Digital Services Act compliance so it seems there is nothing I can do. Contacted developer support on Monday but haven't heard back. Anyone with the similar situation who can offer any advice?
7
0
1.4k
Jul ’24
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
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
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
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
Live Text API fails: "failed because the buffer is nil"
Hello, I am trying to play around with the Live Text API according to this docs - https://developer.apple.com/documentation/visionkit/enabling_live_text_interactions_with_images?changes=latest_minor But it always fails with [api] -[CIImage initWithCVPixelBuffer:options:] failed because the buffer is nil. I am running this on a UIImage instance that I got from VNDocumentCameraViewController. This is my current implementation that I run after the scanned image is displayed: private func setupLiveText() { guard let image = imageView.image else { return } let interaction = ImageAnalysisInteraction() imageView.addInteraction(interaction) Task { let configuration = ImageAnalyzer.Configuration([.text]) let analyzer = ImageAnalyzer() do { let analysis = try await analyzer.analyze(image, configuration: configuration) DispatchQueue.main.async { interaction.analysis = analysis } } catch { print(error.localizedDescription) } } } It does not fail, it returns non-nil analysis object, but setting it to the interaction does nothing. I am testing this on iPhone SE 2020 which has the A13 chip. This feature requires A12 and up.
4
0
2.3k
Sep ’22
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
Need clarifications regarding some properties of NEPacketTunnelNetworkSettings
Hello, I am working on a NEPacketTunnelProvider and I am not exactly sure if I correctly understand the NEPacketTunnelNetworkSettings. For example the ipv4Settings according to docs: This property contains the IPv4 routes specifying what IPv4 traffic to route to the tunnel, as well as the IPv4 address and netmask to assign to the TUN interface. So this seems like unless I set all the possible routes here, the tunnel should not work for all the traffic? Currently I have this: swift let ipv4Settings: NEIPv4Settings = NEIPv4Settings( addresses: ["192.169.89.1"], subnetMasks: ["255.255.255.255"] ) Which seems to work pretty well, both for WiFi and cellular. In the past I tried various other addresses, even manually including all the IPV4 routes but I never noticed any effect regarding the tunnel. Then there is the includedRoutes property. The routes that specify what IPv4 network traffic will be routed to the TUN interface. So this is basically another way to set the address like in the constructor for NEIPv4Settings? This seems to work best when I don't set anything. I tried setting all the routes but that did not change things a bit. The only difference is when I set includedRoutes to NEIPv4Route.default(). Then some apps stop working when the tunnel is active. This is strange, because even setting all the available routes + default one doesn't fix this "issue". What is the relation between these properties? It is best to not set includedRoutes if the tunnel works fine? And lastly. What about dnsSettings? This looks like another optional property. Does it make sense to manually specify DNS to point maybe to 1.1.1.1?
3
0
643
Apr ’21