Post

Replies

Boosts

Views

Activity

Are Privacy Nutrition Labels in App Store Connect automatically updated based on Privacy Manifest files in the app and third-party SDKs?
Hello, I include a Privacy Manifest file in my app and specify one Privacy Nutrition Label Type (Email Address, for marketing purposes). My app uses some third-party SDKs like RevenueCat that contain Privacy Manifest files with nutrition label types specified (Purchases History for RevenueCat for example). Xcode can generate a report that aggregates all the data types that are collected by the app. But is App Store Connect updated when I upload a build? Or do I have to manually setup the App Privacy info? Thanks
0
0
57
1d
SwiftUI: detect the beginning of a View using scrollPosition in a V/HStack
Hello, I want to detect when a ScrollView is scrolled at the top of a specific View in a LazyVStack. Here is the code I use: struct ContentView: View { @State private var scrollID: Int? var body: some View { HStack { VStack { Text(scrollID?.formatted() ?? "Unknown") Button("Go") { withAnimation { scrollID = 7 } } Divider() ScrollView { LazyVStack(spacing: 300) { ForEach(0...100, id: \.self) { int in Text(int.formatted()) .frame(maxWidth: .infinity) .background(.red) } } .scrollTargetLayout() } .scrollPosition(id: $scrollID, anchor: .top) } } } } As I specify a top anchor, I was expecting to see the scrollID binding being updated when the red Text View is at the top of the ScrollView. But I noticed that scrollPosition updates the binding way before the red Text View is positioned at the top of the ScrollView, which is not what I want. In this image, you can see the binding is already at one even though there is a lot of space between the View and the top of the ScrollView. Maybe the Stack spacing is taken into account? And manually setting the binding scroll at the position I want, just above the red Text for 7, which makes me think the views IDs are correct. Is my understanding wrong about this modifier? How can I detect the top (beginning) of the View? (If this is a SwiftUI bug, I filed #FB13811349)
2
0
128
3d
NavigationSplitView crashes if I select an item in the sidebar after I removed other items
My NavigationSplitView crashes if I select an item in the sidebar after I removed other items: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1c44d488c) How to reproduce: Launch the app from the attached project: https://gist.github.com/alpennec/a45f5ff94382dc922718906a60a35220 Tap on “Add” Select the new added item in the sidebar In the detail view, tap “Delete” Select “All” in the sidebar The app crashes: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1c44d488c) It occurs if I use just Strings or Core Data objects (I tried with plain String because I thought it was maybe an issue with Core Data but it’s not apparently). What is wrong? Is that a bug? Filed #FB13561900 for this.
3
0
340
Jan ’24
Calendar nextDate/enumerateDates methods with backward direction does not work for September
I’m trying to get the previous date that matches the 9nth month in the Gregorian calendar (which is September) from Date.now (which is in December 2023 right now). The expected date is then in 2023. The first date returned is in 1995. Why? I filed the feedback FB13462533 var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone.autoupdatingCurrent let matchingDateComponents: DateComponents = DateComponents(month: 09) let date: Date? = calendar.nextDate( after: Date.now, matching: matchingDateComponents, matchingPolicy: .nextTime, direction: .backward ) print(date) // Optional(1995-08-31 23:00:00 +0000)
4
0
370
Dec ’23
In Swift, how can I get the "last Sunday of a month before the current date"?
I want to find the "last Sunday of a month before the current date" in Swift, but using the Calendar nextDate function doesn't work (always returns nil). var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = .gmt let lastSundayDateComponents: DateComponents = DateComponents( weekday: 1, weekdayOrdinal: -1 ) let previousLastSundayDate: Date? = calendar.nextDate( after: Date.now, matching: lastSundayDateComponents, matchingPolicy: .nextTime, repeatedTimePolicy: .first, direction: .backward ) print(previousLastSundayDate ?? "Not found") // "Not found" If I use a positive weekdayOrdinal, it's working normally and the same nextDate method provides the correct date. let firstSundayDateComponents: DateComponents = DateComponents( weekday: 1, weekdayOrdinal: 1 ) When I check if the date components can provide a valid date for the given calendar, it returns false... let lastSundayInNovember2023DateComponents: DateComponents = DateComponents( year: 2023, month: 11, weekday: 1, weekdayOrdinal: -1 ) // THIS RETURNS FALSE let isValid: Bool = lastSundayInNovember2023DateComponents.isValidDate(in: calendar) print(isValid) // false ... even if the correct date can be created. let lastSundayInNovember2023: Date = calendar.date(from: lastSundayInNovember2023DateComponents)! print(lastSundayInNovember2023) // 2023-11-26 00:00:00 +0000 Is that a bug in Foundation?
2
0
506
Dec ’23
SwiftUI Map: is it possible to add an inset to the map visible rectangle?
In UIKit, we can add an insets to a MKMapView with setVisibleMapRect to have additional space around a specified MKMapRect. It's useful for UIs like Apple Maps or FlightyApp (see first screenshot attached). This means we can have a modal sheet above the map but still can see all the content added to the map. I'm trying to do the same for a SwiftUI Map (on iOS 17) but I can't find a way to do it: see screenshot 2 below. Is it possible to obtain the same result or should I file a feedback for an improvement?
2
0
1.1k
Sep ’23
SwiftUI + Core Data: animation on Core Data object properties does not work.
I want to animate part of my View when a property on a Core Data object is updated. These Core Data objects are ObservableObject so when I update a property on the object using a binding (like a Toggle) or a Button, I expect it to animate. But it’s not working. If I toggle a boolean property on my object, there is no animation. If I change a Boolean value in a Button using a withAnimation block, it does not animated. If I do the same with an ObservableObject class (boolean is a Published property), the animation is respected. A workaround is to use another property (isFavoriteWrapped) and to call objectWillChange.send() manually in the property setter. But this feels wrong. The expected behaviour should be similar to what we see with the ObservableObject. I opened a FB12174214.
0
0
814
May ’23
MKLocalPointsOfInterestRequest does not return the same results than MKLocalSearch.Request or MKLocalSearchCompleter
Hello, My app uses Core Location to request for Points Of Interest near the user. I used the different APIs provided by Apple: MKLocalPointsOfInterestRequest, MKLocalSearch.Request and MKLocalSearchCompleter. They do not provide the same results at all, whereas the configurations for the requests are very similar. The MKLocalPointsOfInterestRequest provides very few places (if any, sometimes The operation couldn’t be completed. (MKErrorDomain error 4.) The others give more results but not identical. The code for the different requests is provided below. Is this the expected behaviour? If no, have I missed something? Is this a bug? Thanks PS: Tested on Xcode 14.3, iOS 16.0. MKLocalPointsOfInterestRequest let center: CLLocationCoordinate2DMake = CLLocationCoordinate2DMake(41.38891, 9.16205) let poiRequest: MKLocalPointsOfInterestRequest = MKLocalPointsOfInterestRequest(center: coordinate, radius: 3_000) poiRequest.pointOfInterestFilter = MKPointOfInterestFilter(including: [.beach]) let poiSearch: MKLocalSearch = MKLocalSearch(request: poiRequest) let resultsPOI = try await poiSearch.start() print(resultsPOI.mapItems.compactMap(\.name)) This give me the following result: ["Plage de Stagnolu"] MKLocalSearch.Request let center: CLLocationCoordinate2DMake = CLLocationCoordinate2DMake(41.38891, 9.16205) let searchRequest: MKLocalSearch.Request = MKLocalSearch.Request() searchRequest.region = MKCoordinateRegion(center: coordinate, latitudinalMeters: 4_000, longitudinalMeters: 4_000) searchRequest.pointOfInterestFilter = MKPointOfInterestFilter(including: [.beach]) searchRequest.resultTypes = .pointOfInterest searchRequest.naturalLanguageQuery = "beach" let search: MKLocalSearch = MKLocalSearch(request: searchRequest) let results = try? await search.start() print(results.mapItems.compactMap(\.name)) This give me se following results. ["Plage du Petit Sperone", "Plage de 3 Pointes", "Plage de Saint-Antoine Bonifacio", "Plage de Fazzio", "Piantarella Beach", "Plage du Grand Sperone", "Capu Testagro", "Plage de Balistra", "Plage de Stagnolo", "Plage de Cala Longa", "Plage de La Tonnara", "Plage Porto Novo", "Plage de Sant\'Amanza", "Rena Majori", "Plage de Rondinara", "Plage de Santa Giulia", "Spiaggia Rena Bianca", "Plage De Roccapina", "Cala Spinosa", "Naracu Nieddu Beach", "Porto Cervo Beach", "Lido Dog Beach", "Plage de Figari", "Capocchia Du Purpu", "Spiaggia Zia Culumba"] MKLocalSearchCompleter func search(coordinate: CLLocationCoordinate2D) { completer.region = MKCoordinateRegion(center: coordinate, latitudinalMeters: 4_000, longitudinalMeters: 4_000) completer.pointOfInterestFilter = MKPointOfInterestFilter(including: [.beach]) completer.resultTypes = .pointOfInterest completer.queryFragment = "beach" } func completerDidUpdateResults(_ completer: MKLocalSearchCompleter) { print(completer.results.map(\.title)) } This give me the following result: ["Porto Istana Beach", "Sandbanks Beach", "Spiaggia La Cinta", "Piantarella Beach", "Platja de la Barceloneta", "Whitstable Beach", "West Wittering Beach", "Cala Millor"]
0
2
959
Apr ’23
Swift Packages: exclude developments resources/assets from package used in archived app.
When using Swift Packages in Xcode, is there a way to exclude files conditionally (in DEBUG or similar)? I know I can exclude files but I want them while in development. I have a package that contains developments resource/assets (used to seed a Core Data database for the simulator + for Previews, with images and files), but I don't want to include these files in the package used by the real app when archiving. Can we achieve that?
2
0
1.8k
Feb ’23
Xcode Export Localizations for an iOS app using Swift Package Manager packages fails: No such module UIKit
I'm building an iOS app (the supported destinations in the app target are iOS, iPad and Mac - Designed for iPad). I've many SPM frameworks in order to split my codebase in different features. I want to export the localisations for the different packages and the app using Xcode but it fails. I followed the Apple guide regarding SPM localization: the packages contains a Resources folder with a folder for each language supported. I specified the platforms .iOS(.v16) in the packages. But it seems that exporting the localisations using the Product > Export Localizations feature in Xcode compiles also the packages and app for macOS. Here is the error message: Showing Recent Messages /Users/axel/Developer/AppName/Packages/Helpers/Sources/Helpers/UIKit/UIImage+Extension.swift:7:14: No such module 'UIKit' /Users/axel/Developer/AppName/Packages/Helpers/Sources/Helpers/UIKit/UIImage+Extension.swift:7:14: UIKit is not available when building for macOS. Consider using `#if canImport(UIKit)` to conditionally import this framework. Is there a way to have the export feature work when building an iOS app with packages specified for iOS?
2
0
1.6k
Feb ’23
iOS Location Services: updates not received when device has been locked for a while.
Hello I’ve a question regarding CLLocationManager as I’m observing a strange behaviour when receiving location updates. And I don’t really know what could be the culprit here. Some information regarding the device: Device: iPhone Xs Max OS: iOS 16.1 beta 4 App Background Modes: locations updates checked. CLLocationManager setup: CLAuthorizationStatus: authorizedWhenInUse CLAccuracyAuthorization: fullAccuracy allowsBackgroundLocationUpdates is ON pausesLocationUpdatesAutomatically is OFF (but toggle to turn in on in the POC) activityType (CLActivityType): .otherNavigation (but tried other options). desiredAccuracy (CLLocationAccuracy) : kCLLocationAccuracyNearestTenMeters (to receive GPS updates, and not cell towers) distanceFilter CLLocationDistance): kCLDistanceFilterNone (-1) or 0. When I record with the device unlocked, everything is working fine with the app either in foreground or in background. It receives location updates as I walk around with quite good accuracy (between 5 and 15 meters, see attachment). But I notice that when the device is locked in my pocket, the location service stops receiving updates after a while (like few minutes). I tried with Wi-Fi off and it behaves the same. You can see that in my screenshots attached: many values are incorrect (speed, course). When I open the app again (not crashed), the locations are received again but the horizontalAccuracy is not very good: it’s as if it was not using the GPS anymore. I tried with low power mode enabled and disabled, and I think it behaves the same but maybe not? Is the low power mode responsible for this discrepancies?  As far as I know, it does not modify location services accuracy (only network, background tasks, etc.). Thanks
2
0
2.0k
Oct ’22
Xcode 14b2 Previews with SPM: AppHostMustHaveGetTaskAllowError: XCPreviewAgent.app not code signed properly "XCPreviewAgent.app" must be code signed in order to use on-device previews. Check your code signing settings for the target. com.apple.dt.U
I'm trying to use Previews in a Swift Package in Xcode 14b2 but it's not working (it was working in Xcode 13). I have the following error message but I don't know how to solve it. "XCPreviewAgent.app" must be code signed in order to use on-device previews. Check your code signing settings for the target. com.apple.dt.UVPreviewAgent-watchOS.watchkitapp {     url: file:///Applications/Xcode-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/Library/Xcode/Agents/XCPreviewAgent.app     version: 20.0.32.2     attributes: [         ObjectIdentifier(0x00000001638e5d18): ["OS_ACTIVITY_DT_MODE": "YES", "SQLITE_ENABLE_THREAD_ASSERTIONS": "1"],     ] }
1
0
1.1k
Jun ’22