Post

Replies

Boosts

Views

Activity

Determining if a block of data was signed on the Secure Enclave
Hello, I'm exploring the Secure Enclave APIs, and I'm wondering if it's possible to "cryptographically" determine if a block of data was signed on the Secure Enclave. When I sign a block of data using the Secure Enclave (which implies using a key pair automatically generated by the enclave) and distribute the public key to others, is there any way to verify if the message was encrypted on it / its private key was generated by it? In other words, what I'm trying to achieve is to make sure that the public key hasn't been tampered with until it reaches its destination (including on-device threats, since otherwise I could've used a normal keychain item, perhaps?). For the purpose of this example, I'm not necessarily interested in figuring out if the key was signed on a certain device's enclave, but rather on any Secure Enclave. So, using something derived from the enclave's GID Key (described in the Apple Platform Security guide) would work for this.
2
0
204
1w
FB15286954: Loss of 2FA verification codes
Hello, I'll describe an issue I just reported as FB15286954, hoping to see your thoughts on it / what might've gone wrong. Earlier today, I created an account for a website on my iPhone running the release version of iOS 18.0 using Safari, then added 2FA via the Passwords app. I logged in, checked that it works, then closed Safari and did something else (not much on my phone). In the meantime the phone shut down due to low battery. When I charge it again, and open the Passwords app, I come to find out that the verification codes for this website are gone… What could've gone wrong? I was prompted by the website to save a code to check that 2FA was properly configured, so I think I saved it properly in the app (by the way, the password was still there, properly saved). I assume there was a syncing error between iCloud and my iPhone due to low battery? Is there any way to recover the verification codes? I'll try to reclaim the account through the website's support channels, but I'm wondering if I could still retrieve it somehow.
1
0
378
Sep ’24
SwiftData Predicates and .contains(where: )
Hi, I have the following predicate used in a SwiftData Query: #Predicate<Item> { searchText.isEmpty || $0.myarray.contains(where: { $0.text.localizedStandardContains(searchText) }) }) Even though this compiles, I get the unsupportedKeyPath error in the logs: Query encountered an error: SwiftData.SwiftDataError(_error: SwiftData.SwiftDataError._Error.unsupportedKeyPath) I thought I could use .contains(where:) inside predicates, but this doesn't work. What could be the problem? Item.myarray is an array of a Codable struct type, and searchText is a String.
3
1
1.1k
Feb ’24
Using iPadOS 17 / macOS 14 features in challenge submission
Hi! I just read the updated terms and conditions, and I have a question regarding the submission requirements: Your app playground must be fully functioning, and be built with and run on Swift Playgrounds 4.4 on iPadOS 16 or macOS 13.5 or Xcode 15 on macOS 13.5 or later. You may incorporate the use of Apple Pencil. This means that the app can be built on iPadOS 17 / macOS 14 as well (and perhaps add some features specific to iPadOS 17 / macOS 14 or later using features such as SwiftData?) but does the app need to be fully compatible with earlier versions as well? I think this means it should be compatible with all versions from iPadOS 16 / macOS 13.5 onwards?
4
1
1.1k
Feb ’24
SwiftUI Sheet race condition
Hi! While working on my Swift Student Challenge submission it seems that I found a race condition (TOCTOU) bug in SwiftUI when using sheets, and I'm not sure if this is expected behaviour or not. Here's an example code: import SwiftUI struct ContentView: View { @State var myVar: Int? @State private var presentSheet: Bool = false var body: some View { VStack { // Uncommenting the following Text() view will "fix" the bug (kind of, see a better workaround below). // Text("The value is \(myVar == nil ? "nil" : "not nil")") Button { myVar = nil } label: { Text("Set value to nil.") } Button { myVar = 1 presentSheet.toggle() } label: { Text("Set value to 1 and open sheet.") } } .sheet(isPresented: $presentSheet, content: { if myVar == nil { Text("The value is nil") .onAppear { print(myVar) // prints Optional(1) } } else { Text("The value is not nil") } }) } } When opening the app and pressing the open sheet button, the sheet shows "The value is nil", even though the button sets myVar to 1 before the presentSheet Bool is toggled. Thankfully, as a workaround to this bug, I found out you can change the sheet's view to this: .sheet(isPresented: $presentSheet, content: { if myVar == nil { Text("The value is nil") .onAppear { if myVar != nil { print("Resetting View (TOCTOU found)") let mySwap = myVar myVar = nil myVar = mySwap } } } else { Text("The value is not nil") } }) This triggers a view refresh by setting the variable to nil and then to its non-nil value again if the TOCTOU is found. Do you think this is expected behaivor? Should I report a bug for this? This bug also affects .fullScreenCover() and .popover().
3
0
1.3k
Feb ’24
Updating @Transient SwiftData attributes doesn't refresh SwiftUI Views
I noticed updating a @Transient attribute's value does not refresh SwiftUI views when using a SwiftData model with @Query or @Bindable. Here is a sample code (clicking the button changes the Transient attribute): import SwiftUI import SwiftData // SwiftUI App struct declaration @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } .modelContainer(for: MyModel.self) } } // My SwiftData test model @Model class MyModel { var myFirstArray: [Int] @Transient var mySecondElement: Bool = false init(myFirstArray: [Int] = [Int](), mySecondElement: Bool = false) { self.myFirstArray = myFirstArray self.mySecondElement = mySecondElement } } // The SwiftUI View struct ContentView: View { @Query var myModels: [MyModel] @Environment(\.modelContext) var modelContext var body: some View { VStack { if myModels.count != 0 { Text("Model:") // I expected this to update when the button is clicked Text("mySecondElement's value: \(myModels[0].mySecondElement ? "True" : "False" )") Button { // button that changes the transient attribute myModels[0].mySecondElement.toggle() print(myModels[0].mySecondElement) // this prints the actual value } label: { Text("Add mySecondElement data") } } } .onAppear { try? modelContext.delete(model: MyModel.self) if myModels.count == 0 { let model = MyModel(myFirstArray: [0, 1, 3]) modelContext.insert(model) } } } } I expected ContentView() to be refreshed when I clicked on the button. However, this seems to not be the case - it seems that attributes marked with @Transient don't publish updates to Views. Is this expected behaviour? Should I file a bug / feedback for this?
0
0
948
Feb ’24
Document-based SwiftData App Playgrounds
Is it possible to create SwiftData Document-based apps in App Playgrounds (or Swift Packages, since App Playgrounds are a special type of packages)? As explained in wwdc2023-10154, to create a document-based app you are required to provide an UTType that conforms to com.apple.package. This requires your file type to be declared and exported in the Info.plist file of an Xcode project, but App Playgrounds don't have them. Providing .package as a UTType seems to partially work: import SwiftUI import SwiftData @main struct SwiftDataFlashCardSample: App { var body: some Scene { #if os(iOS) || os(macOS) DocumentGroup(editing: Card.self, contentType: .package) { ContentView() } #else WindowGroup { ContentView() } .modelContainer(for: Card.self) #endif } } This way I am able to run the app, create and edit new document, and save it on disk. However, opening it again does not work (you cannot select it since it is a folder without a defined package type). Is there any workaround to this? I guess I could drop support for multiple documents entirely if this is not possible (I don't think this would affect my submission), but I would just like to check if there is any way to do this first.
0
1
812
Feb ’24
FB13516799: Training Tabular Regression ML Models on large datasets in Xcode 15 continuously "Processing"
Hi, In Xcode 14 I was able to train linear regression models with Create ML using large CSV files (I tested on about 30000 items and 5 features): However, in Xcode 15 (I tested on 15.0.1 and 15.1), the training continuously stays in the "Processing" state: When using a dataset with 900 items, everything works fine. I filed a feedback for this issue: FB13516799. Does anybody else have this issue / can reproduce it?
3
1
1.1k
Jan ’24
On which target will Swift Student Challenge submissions run on, when choosing Xcode 14 on macOS 13?
Hello! I am wondering on which target will the Swift Student Challenge submissions run on, when choosing the option to run on Xcode 14 on macOS 13. In Xcode, you can pick multiple simulators and devices as a target for an App Playground. If the submission will run on one of the Mac options, will it run as Designed for iPad or as a Mac Catalyst app?
3
1
1.1k
Apr ’23