Posts

Post not yet marked as solved
1 Replies
Hi I refactored my NavigationBarView and was able to me more "SwiftUI" like in the implementation. Hope this helps: import SwiftUI extension View { func onWillDisappear(_ perform: @escaping () -> Void) -> some View { modifier(ViewWillDisappearModifier(callback: perform)) } func onWillAppear(_ perform: @escaping () -> Void) -> some View { modifier(ViewWillAppearModifier(callback: perform)) } } struct ViewWillDisappearModifier: ViewModifier { let callback: () -> Void func body(content: Content) -> some View { content.background(UIViewControllerResponder(viewWillDisappear: callback)) } } struct ViewWillAppearModifier: ViewModifier { let callback: () -> Void func body(content: Content) -> some View { content.background(UIViewControllerResponder(viewWillAppear: callback)) } } private struct UIViewControllerResponder: UIViewControllerRepresentable { /// Notifies the view controller that its view is about to be added to a view hierarchy. var viewWillAppear: (() -> Void)? = nil /// Notifies the view controller that its view is about to be removed from a view hierarchy. var viewWillDisappear: (() -> Void)? = nil private let controller = ViewController() func makeUIViewController(context: UIViewControllerRepresentableContext<UIViewControllerResponder>) -> UIViewController { if let viewWillAppear = viewWillAppear { controller.viewWillAppear = viewWillAppear } if let viewWillDisappear = viewWillDisappear { controller.viewWillDisappear = viewWillDisappear } return controller } func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext<UIViewControllerResponder>) { } /// An object that manages a view hierarchy for your UIKit app. private class ViewController: UIViewController { var viewWillAppear: () -> Void = { } var viewWillDisappear: () -> Void = { } /// Notifies the view controller that its view is about to be added to a view hierarchy. /// - Parameter animated: If true, the view is being added to the window using an animation. override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) viewWillAppear() } /// /// Notifies the view controller that its view is about to be removed from a view hierarchy. /// - Parameter animated: If true, the view is being added to the window using an animation. override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) viewWillDisappear() } } } And in the View, this is how you interact with the events: struct MyView: View { var body: some View { NavigationStack { Text("Home") .navigationTitle("Some Text") .toolbar { ToolbarItem(placement: .primaryAction) { Button { print("Toolbar button pressed") } label: { Image(systemName: "plus") } } } } .onWillAppear { let appearance = UINavigationBarAppearance() appearance.titleTextAttributes = [.foregroundColor: UIColor.white] appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white] UINavigationBar.appearance().standardAppearance = appearance UINavigationBar.appearance().compactAppearance = appearance } .onWillDisappear { let appearance = UINavigationBarAppearance() appearance.titleTextAttributes = [:] appearance.largeTitleTextAttributes = [:] UINavigationBar.appearance().standardAppearance = appearance UINavigationBar.appearance().compactAppearance = appearance } } }
Post not yet marked as solved
15 Replies
Apparently an known issue in the Xcode 15 Release Notes The simulator may crash when opening Settings or Action Button settings on iPhone 15 Pro devices. (115388496) Used to work with BETA 8 🤷‍♂️ Seems to work with iPhone 15, just not the Pro device.
Post not yet marked as solved
3 Replies
Hi Claude31 I thought this might have to be the solution and of course it works. I did try making enum ServiceType: Int and doing repairs.allowRepairs[ServiceType.boat] which also worked so long as the dictionary value matched the index of the enum. So another issue will be JSON codable of Dictionary[ServiceType: ServiceDescriptor], all sorts of error here. Wouldn't happen to have some ideas around codable of a Dictionary[Enum: Protocols]?
Post not yet marked as solved
1 Replies
I managed to get the errors to go away. I "unchecked" DefaultValue+Extension.swift and DefaultValuePropertyWrapper.swift from being part of the test target and in the DefaultValueTest.swift file replaced @testable import MyFramework with import MyFramework. Compiles and the tests run successfully now 😅
Post not yet marked as solved
18 Replies
Haven't heard anything from Apple support since filing a bug report.
Post marked as solved
3 Replies
After some more trial and error I finally got the look I was after. HStack padding seemed to cause the issue. Here is the final result. import SwiftUI struct ContentView: View {     var body: some View {         VStack(alignment: .center, spacing: 64) {             Text("About My Data")                 .font(.title)                 .fontWeight(.heavy)                 .multilineTextAlignment(.center)                 .padding()             VStack(alignment: .leading, spacing: 32) {                 HStack {                     Image(systemName: "network")                             .font(.system(size: 36.0))                             .foregroundColor(.blue)                     VStack(alignment: .leading) {                        Text("Network Support")                         .font(.headline)                         .fontWeight(.bold)                     Text("Download your data from anywhere.")                         .font(.body)                         .foregroundColor(.gray)                     }                 }                 HStack {                     Image(systemName: "hand.raised.fill")                         .font(.system(size: 36.0))                         .foregroundColor(.blue)                     VStack(alignment: .leading) {                         Text("Data Privacy")                         .font(.headline)                         .fontWeight(.bold)                     Text("Scanned certificates are never stored on the device.")                         .font(.body)                         .foregroundColor(.gray)                     }                 }             }         }.padding()     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } }
Post marked as solved
3 Replies
@robnotyou, thanks for replying. I'm trying to achieve making the HStack full width with the image and the VStack text in both containers leading aligned. Because of the text size difference it's slight off.
Post not yet marked as solved
18 Replies
Hi Matt Do you have any updates on this? It's a real show stopper for us if you could please provide some guidance. Thanks
Post not yet marked as solved
6 Replies
Hey Quinn Nuh, this is for iOS devices. This code use to work on iOS14, but busted on iOS15 🤷‍♂️ I found probably feedback reference to the same issue (FB9414546), so maybe a bug... Cheers
Post not yet marked as solved
6 Replies
Hi Quinn Thanks for the reply. I removed kSecAttrSynchronizable added kSecUseDataProtectionKeychain. For now, I also removed kSecAttrAccessible as part of the initial query. Here is the refactored code: public func addItem(value: Data, forKey: String, accessControlFlags: SecAccessControlCreateFlags? = nil) { guard !forKey.isEmpty else {     return    } var query: [String: Any] = [kSecClass as String: kSecClassGenericPassword, kSecAttrService as String: Bundle.main.bundleIdentifier!, kSecAttrAccount as String: forKey, kSecValueData as String: value, kSecUseDataProtectionKeychain as String: true] // Check if any access control is to be applied. if let accessControlFlags = accessControlFlags { var error: Unmanaged<CFError>?       guard let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, kSecAttrAccessibleWhenUnlockedThisDeviceOnly, accessControlFlags, &error) else { return } query[kSecAttrAccessControl as String] = accessControl    } let status = SecItemAdd(query as CFDictionary, nil) guard status != errSecDuplicateItem else { return } guard status == errSecSuccess else { let message = SecCopyErrorMessageString(status, nil) as String? ?? "Unknown error" print(message) return } } And to invoke the function: try? addItem(value: "Hello World", forKey: "greeting", accessControlFlags: [.userPresence]) The error which occurs in both the simulator and device is -25293 The user name or passphrase you entered is not correct. Appreciate if you have any guidance on this one... Thanks
Post not yet marked as solved
3 Replies
Hi I have a LaunchViewController which is set as the initial view controller on the storyboard. The LaunchViewController checks a key in the UserDefaults then either navigates to the user licence or the welcome screen. class LaunchViewController: UIViewController { override func viewDidLoad() {     super.viewDidLoad() var viewControllerIdentifier = "Welcome" let storyboard = UIStoryboard(name: "Main", bundle: nil) // Check if the user agreement has been accepted. if !UserDefaults.standard.bool(forKey: "HasAchnowledgedUserLicence") { viewControllerIdentifier = "UserLicence" }       let viewController = storyboard.instantiateViewController(identifier: viewControllerIdentifier) navigationController?.pushViewController(viewController, animated: true)     } } As the user progresses through the app and needs to go back the Welcome screen, I execute this code: _ = navigationController?.popToRootViewController(animated: false)` If you think I should be setting the root view controller instead of performing a navigation as in: window?.rootViewController = viewConntoller window?.makeKeyAndVisible() Many thanks for helping
Post marked as solved
1 Replies
You need to evaluate policy first to determine if biometry is available. var biometryType: LABiometryType { var error: NSError? let context = LAContext() guard context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) else { return .none     }     return context.biometryType } // Test the biometry type switch self.biometryType { case .faceID: print("Face ID")     case .touchID: print("Touch ID")     case .none: print("None")     @unknown default: print("Unknown") }
Post marked as solved
1 Replies
It appears that this is not a bug. SecAccessControl provides protection for crypto operations (decryption, signature) with a private key. Object creation and deletion are not protected.
Post not yet marked as solved
4 Replies
Hi Quinn It's more a security reason not allow files escaping the from the original device.
Post not yet marked as solved
4 Replies
Thanks for the reply. Fixed the typo. The implementation of id and name are immutable once the instance has been created. If I undersrtand your answer UserData would be:final class UserData: ObservableObject, Codable { var account: AProfile? }Is that what you mean?