Post

Replies

Boosts

Views

Activity

Reply to High battery drain using Xcode 13
On my iMac when using Xcode 13. the issue seems to be linked to the simulator used by the SwiftUI preview canvas. When it first loads, it will peg the simulator at around 200% CPU usage and increase watt usage from around 60W to over 100W even after I pause and close the canvas. Only way to clear it seems to be either killing the simulator process or Xcode. If I just compile to a simulator device every time I want to check the UI changes without ever opening the canvas after Xcode starts, other than a short spike during compile, it will hover around 60W. a bit of a pain but a workaround while Apple sort out the issue.
Oct ’21
Reply to Xcode source control not working 12.5.1
I've figured out the issue but have not found a practical solution yet. Source control options work for projects located inside my home directory. All my projects are in a root /Data folder. If I create a symbolic link inside the /Data folder to a test project on the desktop works as expected. If I move the project inside the /Data folder, it does not work with all the options disabled except Clone and New Repository. Moving all the projects to the home folder is not an option. Xcode can read/write fine to the /Data folder. I've created a new folder in /Data2 and moved the test project to it, but the issue persists so it seems anything not in the home folder will have the source control options disabled. Works fine on my MBP and Mac mini.
Oct ’21
Reply to About UUID when implementing promotion offer
Not sure if I understand the issue, but if you need to use a lowercased UUID string you can just convert the Swift UUID back to a string and then lowercase it. UUID().uuidString.lowercased() As per the documentation, The string representation of the nonce must be lowercase. not the UUID itself. It seems that the reason that it needs to be lowercased is for when generating the signature on the server. nonce A unique UUID value that your server defines. The string representation of the nonce used in the signature must be lowercase. Generating a Signature for Promotional Offers https://developer.apple.com/documentation/storekit/original_api_for_in-app_purchase/subscriptions_and_offers/generating_a_signature_for_promotional_offers
Sep ’21
Reply to SwiftUI NavigationLink pops out by itself
Adding a NavigationLink with an empty view didn't work for me. I solved my issue removing all NavigationLinks from the ForEach and using a single one to control the navigation to the detail view, a tap gesture and 2 state variables to keep track on what is being tapped on. The example broken code and fix can be found at Paul Hudson's site. https://www.hackingwithswift.com/forums/swiftui/unable-to-present-please-file-a-bug/7901/8237 Below is the complete working version import SwiftUI struct NavigationViewOptions { enum OptionType { case main, optional } typealias Option = (id: UUID, value: String, type: Self.OptionType) static var options: [Option] = [ (UUID(), "Option 1", .main), (UUID(), "Option 2", .optional), (UUID(), "Option 3", .main), (UUID(), "Option 4", .main), (UUID(), "Option 5", .optional), ] static func buildView(for option: Option) -> some View { switch option.type { case .main: return Text("Main Option selected\n\(option.value)").font(.title).fontWeight(.bold) case .optional: return Text("Optional Option selected\n\(option.value)").font(.title3).italic().fontWeight(.medium) } } } struct NavigationViewWorking: View { // State variables to leep track of what option has been tapped on and when to navigate to new view @State private var selectedOption: NavigationViewOptions.Option = (id:UUID(),"",.main) @State private var showDetail: Bool = false var body: some View { NavigationView { ScrollView{ VStack (alignment:.leading) { Text("NAVIGATION FIX FOR:\nUnable to present. Please file a bug.") .padding(.bottom, 40) ForEach(NavigationViewOptions.options, id: \.id) { option in Text(option.value) .font(.title) .padding(.vertical, 10) .foregroundColor(.accentColor) // same color as navigationLink // handle tap on option .onTapGesture { selectedOption = option showDetail = true } } Spacer() NavigationLink("", destination: NavigationViewOptions.buildView(for: selectedOption), isActive: $showDetail) .opacity(0) } .navigationTitle("Options") } // INITIAL DETAIL VIEW Text("Select option from the left") } } }
May ’21
Reply to Navigation Link results in Unable to present. Please file a bug. message
Adding a NavigationLink with an empty view didn't work for me. I solved my issue removing all NavigationLinks from the ForEach and using a single one to control the navigation to the detail view, a tap gesture and 2 state variables to keep track on what is being tapped on. The example broken code and fix can be found at Paul Hudson's site. https://www.hackingwithswift.com/forums/swiftui/unable-to-present-please-file-a-bug/7901/8237 Below is the complete working version import SwiftUI struct NavigationViewOptions { enum OptionType { case main, optional } typealias Option = (id: UUID, value: String, type: Self.OptionType) static var options: [Option] = [ (UUID(), "Option 1", .main), (UUID(), "Option 2", .optional), (UUID(), "Option 3", .main), (UUID(), "Option 4", .main), (UUID(), "Option 5", .optional), ] static func buildView(for option: Option) -> some View { switch option.type { case .main: return Text("Main Option selected\n\(option.value)").font(.title).fontWeight(.bold) case .optional: return Text("Optional Option selected\n\(option.value)").font(.title3).italic().fontWeight(.medium) } } } struct NavigationViewWorking: View { // State variables to leep track of what option has been tapped on and when to navigate to new view @State private var selectedOption: NavigationViewOptions.Option = (id:UUID(),"",.main) @State private var showDetail: Bool = false var body: some View { NavigationView { ScrollView{ VStack (alignment:.leading) { Text("NAVIGATION FIX FOR:\nUnable to present. Please file a bug.") .padding(.bottom, 40) ForEach(NavigationViewOptions.options, id: \.id) { option in Text(option.value) .font(.title) .padding(.vertical, 10) .foregroundColor(.accentColor) // same color as navigationLink // handle tap on option .onTapGesture { selectedOption = option showDetail = true } } Spacer() NavigationLink("", destination: NavigationViewOptions.buildView(for: selectedOption), isActive: $showDetail) .opacity(0) } .navigationTitle("Options") } // INITIAL DETAIL VIEW Text("Select option from the left") } } }
May ’21
Reply to Unable to present. Please file a bug.
I also experienced the same issue using multiple NavigationLinks where on iPhone most times worked OK even though the error was displayed in the console but on iPad links would not work in most cases. I've solved it using tap gesture and a single navigation link. You can see the fix on Paul Hudson's site. https://www.hackingwithswift.com/forums/swiftui/unable-to-present-please-file-a-bug/7901/8237
May ’21