Post

Replies

Boosts

Views

Activity

Reply to SwiftUI External Events without SwiftUI Lifecycle
ok after weeks of getting nowhere on this, I found the cause. For me this was caused by having multiple .onOpenURL's similar to you. I had one in each view that I wanted to action the url. While it worked most times, this was causing unpredictable results intermittently for my app and gave this error each time. So I moved the .onOpenURL to the App file then used an environment variable to pass the url to the views I wanted to action it. something like this: struct MyApp: App {     @State var deepLink: URL? = nil     var body: some Scene {         WindowGroup {             ContentView()                 .environment(\.deepLink, self.deepLink)                 .onOpenURL { url in                     guard url.scheme == "myApp" else { return }                     self.deepLink = url /* clear the environment variable so you can send the same url twice */                     DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(200), execute: {                         self.deepLink = nil                     })                 }         }     } } remember to setup your environment variables import SwiftUI struct deepLinkKey: EnvironmentKey {     static var defaultValue: URL? = nil } extension EnvironmentValues {     var deepLink: URL? {         get { self[deepLinkKey.self] }         set { self[deepLinkKey.self] = newValue }     } } then in the views u want to use it in var body: some View { content() .onChange(of:deepLink, perform: { url in guard url?.scheme == "myApp" else { return }              /* parse the url here*/ }) } btw thanks for mentioning onOpenURL, otherwise I would never have found it.
Oct ’20
Reply to Picker Unavailable
in 14.2 rc the error is different but reproduced the same way. to reproduce: open the picker (photos show) then tap on search bar then scroll down slightly and error appears. previously it said "Picker Unavailable", now it says "Unable to load items" with a button that says "try again", after tapping the button the photos appear again until u scroll down again.
Oct ’20
Reply to Unable to submit app for review (Error with screenshot)
fixed this issue for me. there was a few old screenshots that were loaded under different sizes that don't show up in the 'App Preview and Screenshots' section. I had to go to 'Media Manager' and go through each of the sizes (they are collapsed by default) so I had to expand them to see the other screenshots. deleted them and was able to submit. Would be nice if there were more descriptive error messages as it appears everyone is getting the same error message for a multitude of different issues. wasted 2 days on this...
Nov ’20
Reply to Charts: customising chartYAxis values
This is absolutely the wrong way to do it - It relies on debug descriptions - but until we find another solution, this will work: .chartYAxis {       AxisMarks() { value in                     AxisGridLine()                     AxisTick()                     AxisValueLabel {                         Text("\(abbreviateAxisValue(string: self.parseAxisValue(value: value) ?? ""))")            }      } } func parseAxisValue(value: AxisValue) -> String? {         let input = String(describing: value)         let regex = /\((\d*.0)|\((0)|\((-\d*.0)/         if let match = input.firstMatch(of: regex) {             return "\(match.1 ?? match.2 ?? match.3 ?? "")"         }         return nil     } func abbreviateAxisValue(string: String) -> String {         let decimal = Decimal(string: string)         if decimal == nil {             return string         } else {             if abs(decimal!) > 1000000000000.0 {                 return "\(decimal! / 1000000000000.0)t"             } else if abs(decimal!) > 1000000000.0 {                 return "\(decimal! / 1000000000.0)b"             } else if abs(decimal!) > 1000000.0 {                 return "\(decimal! / 1000000.0)m"             } else if abs(decimal!) > 1000.0 {                 return "\(decimal! / 1000.0)k"             } else {                 return "\(decimal!)"             }         } }
Jun ’22