Post

Replies

Boosts

Views

Activity

Reply to Calendar nextDate/enumerateDates methods with backward direction does not work for September
I just tested with other time zones and the results are different... For some time zones, the result is correct, for others, not. I used the following code to print the result for all time zones. Optional(1970-08-31 23:00:00 +0000) for Europe/London Optional(1995-08-31 23:00:00 +0000) for Europe/Paris Optional(2002-08-31 22:00:00 +0000) for Europe/Vilnius Optional(2023-09-01 07:00:00 +0000) for America/Los_Angeles for zone in TimeZone.knownTimeZoneIdentifiers { var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone(identifier: zone) ?? .autoupdatingCurrent let matchingDateComponents: DateComponents = DateComponents(month: 9) let date: Date? = calendar.nextDate( after: Date.now, matching: matchingDateComponents, matchingPolicy: .nextTime, direction: .backward ) print(zone, date) }
Topic: App & System Services SubTopic: General Tags:
Dec ’23
Reply to numericText transition for normal SwiftUI View
Here is a solution that works in iOS 17: import SwiftUI struct TimerTransitionView: View { var body: some View { Text(Date(timeIntervalSince1970: 1696563619), style: .timer) .contentTransition(.numericText()) .transaction { t in t.animation = .default } } } #Preview { TimerTransitionView() } Thanks LiYanan04818 for the suggestion!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Reply to Core Data, CloudKit - Deduplication causes nil relationships
In their sample project Sharing Core Data objects between iCloud users, Apple now covers this situation. They added some code to handle the soft deletion of objects that are duplicates. To do so, they added a deduplicatedDate property on the Tag entity, then only remove the objects after some time. See the file PersistenceController+Deduplicate.swift. They also have to filter these objects marked as deduplicated from the UI (like in the TaggingView.swift).
May ’23
Reply to Swift Packages: exclude developments resources/assets from package used in archived app.
Thanks! Sounds to answer my question. I'll make sure to add the #if DEBUG to my preview providers in packages that don't use any assets (and in the app too). I didn't know this could be used in packages too (where is the compiler flag defined for the package, like it is for a project with Active Compilation Conditions?). For the packages that need assets, I'm not sure I correctly understand: For your debug build, build this new root package from #2. And for the release build, build just the original package. Can you tell me how to use either the package from #2 or the original package in the app? In the app target, I have to import the packages needed. Do I have to create a new app target so I can import either package from #2 or the original package?
Feb ’23
Reply to Location Stops When the App is Backgrounded after some time.
I'm observing the same thing on an iPhone XS Max running iOS 16.1 (beta 4). I've checked many times the configuration of my app and of the CLLocationManager. It should always receive updates but sometimes, it stops. When I put the app back into foreground, the updates are received again (the app was not killed). I've not found any pattern: sometimes it happens after 5 minutes, sometimes half an hour or more. It's happening with Low Power Mode enabled and disabled. Have you found a solution?
Oct ’22
Reply to Background Location Update stops randomly after some time
I'm observing the same thing on an iPhone XS Max running iOS 16.1 (beta 4). I've checked many times the configuration of my app and of the CLLocationManager. It should always receive updates but sometimes, it stops. When I put the app back into foreground, the updates are received again (the app was not killed). I've not found any pattern: sometimes it happens after 5 minutes, sometimes half an hour or more. It's happening with Low Power Mode enabled and disabled. Have anyone found a solution?
Oct ’22
Reply to iOS Location Services: updates not received when device has been locked for a while.
My previous code was not functional (edited in this forum without compiling), but the problem is the same (the correct configuration provided below was used during my tests). class LocationDataManager: NSObject, CLLocationManagerDelegate { private let locationManager: CLLocationManager = CLLocationManager() var activityType: CLActivityType = .automotiveNavigation { didSet { locationManager.activityType = activityType } } var desiredAccuracy: CLLocationAccuracy = kCLLocationAccuracyBestForNavigation { didSet { locationManager.desiredAccuracy = desiredAccuracy } } var pausesLocationUpdatesAutomatically: Bool = false { didSet { locationManager.pausesLocationUpdatesAutomatically = pausesLocationUpdatesAutomatically } } var distanceFilter: CLLocationDistance = kCLDistanceFilterNone { didSet { locationManager.distanceFilter = distanceFilter } } override init() { super.init() locationManager.delegate = self locationManager.activityType = .automotiveNavigation // controlled by the Picker locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation // controlled by the Picker locationManager.pausesLocationUpdatesAutomatically = false // controlled by the Toggle locationManager.distanceFilter = kCLDistanceFilterNone // controlled by the Picker locationManager.allowsBackgroundLocationUpdates = true } func start() { locationManager.requestWhenInUseAuthorization() locationManager.startUpdatingLocation() } func stop() { locationManager.stopUpdatingLocation() } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print(error) } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { print(locations.last) } func locationManagerDidPauseLocationUpdates(_ manager: CLLocationManager) { print(#function) } func locationManagerDidResumeLocationUpdates(_ manager: CLLocationManager) { print(#function) } }
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’22
Reply to iOS Location Services: updates not received when device has been locked for a while.
I include some basic code to better illustrate how the CLLocationManager is configured and used. class LocationDataManager: NSObject, CLLocationManagerDelegate { private let locationManager: CLLocationManager var activityType: CLActivityType = .automotiveNavigation { didSet { locationManager.activityType = activityType } } var desiredAccuracy: CLLocationAccuracy = kCLLocationAccuracyBestForNavigation { didSet { locationManager.desiredAccuracy = desiredAccuracy } } var pausesLocationUpdatesAutomatically: Bool = false { didSet { locationManager.pausesLocationUpdatesAutomatically = pausesLocationUpdatesAutomatically } } var distanceFilter: CLLocationDistance = kCLDistanceFilterNone { didSet { locationManager.distanceFilter = distanceFilter } } init() { locationManager = CLLocationManager() locationManager.activityType = .automotiveNavigation // controlled by the Picker locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation // controlled by the Picker locationManager.pausesLocationUpdatesAutomatically = false // controlled by the Toggle locationManager.distanceFilter = kCLDistanceFilterNone // controlled by the Picker locationManager.allowsBackgroundLocationUpdates = true } func start() { locationManager.requestWhenInUseAuthorization() locationManager.startUpdatingLocation() } func stop() { locationManager.stopUpdatingLocation() } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print(error) } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { print(locations.last) } func locationManagerDidPauseLocationUpdates(_ manager: CLLocationManager) { print(#function) } func locationManagerDidResumeLocationUpdates(_ manager: CLLocationManager) { print(#function) } }
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’22
Reply to Navigation: update multiple times per frame
In a project using Core Data where I pass multiple objects to the navigationDestination (see example below), I'm seeing a lot of "Update NavigationAuthority possible destinations tried to update multiple times per frame." when I navigate in the Stack. After few push and pop in the stack, the app freezes, the memory increases, the CPU runs at 100%, then the app crashes. I checked the logs from my device: the issues are different every time, but it seems to be linked to a UI update. .navigationDestination(for: Paragraph.self) { paragraph in ParagraphDetail( post: post,         paragraph: paragraph) // -> Update NavigationAuthority possible destinations tried to update multiple times per frame. } In a NavigationStack where I only pass one object in the navigationDestination (see below), I don't have this log message, and the app never freezes. .navigationDestination(for: Paragraph.self) { paragraph in ParagraphDetailOnlyParagraph(paragraph: paragraph) } To identify if it's related to Core Data or not, I reproduced the same NavigationStack with plain Structs, or simple Class objects. I don't see the log message, even when I pass multiple objects to the navigationDestination. The app never freezes. I'll file a FB. It seems to be a bug in beta 1.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Calendar nextDate/enumerateDates methods with backward direction does not work for September
I just tested with other time zones and the results are different... For some time zones, the result is correct, for others, not. I used the following code to print the result for all time zones. Optional(1970-08-31 23:00:00 +0000) for Europe/London Optional(1995-08-31 23:00:00 +0000) for Europe/Paris Optional(2002-08-31 22:00:00 +0000) for Europe/Vilnius Optional(2023-09-01 07:00:00 +0000) for America/Los_Angeles for zone in TimeZone.knownTimeZoneIdentifiers { var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone(identifier: zone) ?? .autoupdatingCurrent let matchingDateComponents: DateComponents = DateComponents(month: 9) let date: Date? = calendar.nextDate( after: Date.now, matching: matchingDateComponents, matchingPolicy: .nextTime, direction: .backward ) print(zone, date) }
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’23
Reply to Granularity/Accuracy of delivered locations with live updates
I'm also really interested in this. In my app, I want to make sure locations I receive are coming from a GPS and not from Wi-Fi/Cell towers. I used to specify a desiredAccuracy to kCLLocationAccuracyBest or kCLLocationAccuracyNearestTenMeters. How can I do that again with this new API? Is that even possible? Thanks!
Replies
Boosts
Views
Activity
Oct ’23
Reply to numericText transition for normal SwiftUI View
Here is a solution that works in iOS 17: import SwiftUI struct TimerTransitionView: View { var body: some View { Text(Date(timeIntervalSince1970: 1696563619), style: .timer) .contentTransition(.numericText()) .transaction { t in t.animation = .default } } } #Preview { TimerTransitionView() } Thanks LiYanan04818 for the suggestion!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’23
Reply to numericText transition for normal SwiftUI View
I tried it on Xcode Version 15.0 beta 8 (15A5229m) but it does not seem to be working. My text is not animated in the app (not a widget). Do you have any idea why?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’23
Reply to Core Data, CloudKit - Deduplication causes nil relationships
In their sample project Sharing Core Data objects between iCloud users, Apple now covers this situation. They added some code to handle the soft deletion of objects that are duplicates. To do so, they added a deduplicatedDate property on the Tag entity, then only remove the objects after some time. See the file PersistenceController+Deduplicate.swift. They also have to filter these objects marked as deduplicated from the UI (like in the TaggingView.swift).
Replies
Boosts
Views
Activity
May ’23
Reply to does the .backgroundTask SwiftUI modifier work with BGProcessingTaskRequest requests?
I have the same question! I filled a feedback FB12189714 if you want to reference it. Hopefully added in the next version and introduced at WWDC 23.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to How to put app-specific logic between migration steps?
Have you found an answer to your question? I have the same and I am not sure how to limit from A to A' then run some code before running the migration from A' to A". Should we specify the model version for the step to execute, then run some logic, then redo the same for another model version?
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Swift Packages: exclude developments resources/assets from package used in archived app.
Thanks! Sounds to answer my question. I'll make sure to add the #if DEBUG to my preview providers in packages that don't use any assets (and in the app too). I didn't know this could be used in packages too (where is the compiler flag defined for the package, like it is for a project with Active Compilation Conditions?). For the packages that need assets, I'm not sure I correctly understand: For your debug build, build this new root package from #2. And for the release build, build just the original package. Can you tell me how to use either the package from #2 or the original package in the app? In the app target, I have to import the packages needed. Do I have to create a new app target so I can import either package from #2 or the original package?
Replies
Boosts
Views
Activity
Feb ’23
Reply to Xcode Export Localizations for an iOS app using Swift Package Manager packages fails: No such module UIKit
Thanks! I added the compiler directives as the error suggests and I can now export localisations. I'll have a look hat the Swift package evolutions to better understand what platforms mean.
Replies
Boosts
Views
Activity
Feb ’23
Reply to Location Stops When the App is Backgrounded after some time.
I'm observing the same thing on an iPhone XS Max running iOS 16.1 (beta 4). I've checked many times the configuration of my app and of the CLLocationManager. It should always receive updates but sometimes, it stops. When I put the app back into foreground, the updates are received again (the app was not killed). I've not found any pattern: sometimes it happens after 5 minutes, sometimes half an hour or more. It's happening with Low Power Mode enabled and disabled. Have you found a solution?
Replies
Boosts
Views
Activity
Oct ’22
Reply to Background Location Update stops randomly after some time
I'm observing the same thing on an iPhone XS Max running iOS 16.1 (beta 4). I've checked many times the configuration of my app and of the CLLocationManager. It should always receive updates but sometimes, it stops. When I put the app back into foreground, the updates are received again (the app was not killed). I've not found any pattern: sometimes it happens after 5 minutes, sometimes half an hour or more. It's happening with Low Power Mode enabled and disabled. Have anyone found a solution?
Replies
Boosts
Views
Activity
Oct ’22
Reply to iOS Location Services: updates not received when device has been locked for a while.
My previous code was not functional (edited in this forum without compiling), but the problem is the same (the correct configuration provided below was used during my tests). class LocationDataManager: NSObject, CLLocationManagerDelegate { private let locationManager: CLLocationManager = CLLocationManager() var activityType: CLActivityType = .automotiveNavigation { didSet { locationManager.activityType = activityType } } var desiredAccuracy: CLLocationAccuracy = kCLLocationAccuracyBestForNavigation { didSet { locationManager.desiredAccuracy = desiredAccuracy } } var pausesLocationUpdatesAutomatically: Bool = false { didSet { locationManager.pausesLocationUpdatesAutomatically = pausesLocationUpdatesAutomatically } } var distanceFilter: CLLocationDistance = kCLDistanceFilterNone { didSet { locationManager.distanceFilter = distanceFilter } } override init() { super.init() locationManager.delegate = self locationManager.activityType = .automotiveNavigation // controlled by the Picker locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation // controlled by the Picker locationManager.pausesLocationUpdatesAutomatically = false // controlled by the Toggle locationManager.distanceFilter = kCLDistanceFilterNone // controlled by the Picker locationManager.allowsBackgroundLocationUpdates = true } func start() { locationManager.requestWhenInUseAuthorization() locationManager.startUpdatingLocation() } func stop() { locationManager.stopUpdatingLocation() } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print(error) } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { print(locations.last) } func locationManagerDidPauseLocationUpdates(_ manager: CLLocationManager) { print(#function) } func locationManagerDidResumeLocationUpdates(_ manager: CLLocationManager) { print(#function) } }
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to iOS Location Services: updates not received when device has been locked for a while.
I include some basic code to better illustrate how the CLLocationManager is configured and used. class LocationDataManager: NSObject, CLLocationManagerDelegate { private let locationManager: CLLocationManager var activityType: CLActivityType = .automotiveNavigation { didSet { locationManager.activityType = activityType } } var desiredAccuracy: CLLocationAccuracy = kCLLocationAccuracyBestForNavigation { didSet { locationManager.desiredAccuracy = desiredAccuracy } } var pausesLocationUpdatesAutomatically: Bool = false { didSet { locationManager.pausesLocationUpdatesAutomatically = pausesLocationUpdatesAutomatically } } var distanceFilter: CLLocationDistance = kCLDistanceFilterNone { didSet { locationManager.distanceFilter = distanceFilter } } init() { locationManager = CLLocationManager() locationManager.activityType = .automotiveNavigation // controlled by the Picker locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation // controlled by the Picker locationManager.pausesLocationUpdatesAutomatically = false // controlled by the Toggle locationManager.distanceFilter = kCLDistanceFilterNone // controlled by the Picker locationManager.allowsBackgroundLocationUpdates = true } func start() { locationManager.requestWhenInUseAuthorization() locationManager.startUpdatingLocation() } func stop() { locationManager.stopUpdatingLocation() } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print(error) } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { print(locations.last) } func locationManagerDidPauseLocationUpdates(_ manager: CLLocationManager) { print(#function) } func locationManagerDidResumeLocationUpdates(_ manager: CLLocationManager) { print(#function) } }
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Navigation: update multiple times per frame
In a project using Core Data where I pass multiple objects to the navigationDestination (see example below), I'm seeing a lot of "Update NavigationAuthority possible destinations tried to update multiple times per frame." when I navigate in the Stack. After few push and pop in the stack, the app freezes, the memory increases, the CPU runs at 100%, then the app crashes. I checked the logs from my device: the issues are different every time, but it seems to be linked to a UI update. .navigationDestination(for: Paragraph.self) { paragraph in ParagraphDetail( post: post,         paragraph: paragraph) // -> Update NavigationAuthority possible destinations tried to update multiple times per frame. } In a NavigationStack where I only pass one object in the navigationDestination (see below), I don't have this log message, and the app never freezes. .navigationDestination(for: Paragraph.self) { paragraph in ParagraphDetailOnlyParagraph(paragraph: paragraph) } To identify if it's related to Core Data or not, I reproduced the same NavigationStack with plain Structs, or simple Class objects. I don't see the log message, even when I pass multiple objects to the navigationDestination. The app never freezes. I'll file a FB. It seems to be a bug in beta 1.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Navigation: update multiple times per frame
I do have the same issues but haven’t found the solution yet. It seems to be related to FetchRequest. Are you using Core Data in your app?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22