Hi Claude31I re-jigged a bit of code around to the following:struct ContentView: View {
@State private var showingSheet = true
var body: some View {
RequestHome().sheet(isPresented: $showingSheet) {
RegisterHome()
}
}
}This gives me the effect I was trying to achieve - a sheet display on launch which I'll conditionalize later on.Craig
Post
Replies
Boosts
Views
Activity
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?
Hi Quinn
It's more a security reason not allow files escaping the from the original device.
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.
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")
}
@OOPer7 that's exactly what's happening! So do you have another suggestion to achieve the experience of waiting to the user to interact with the button before continuing the onDisplay function? I tried using a UIAlertViewController being a model dialog but couldn't find a way to make the dialog appear - probably the same issue with DispatchSemaphore(value: 0). Many thanks!
@OOPer I added some context for you.
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
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
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
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
@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.
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()
}
}
Haven't heard anything from Apple support since filing a bug report.
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 😅