I cannot seem to edit the original post but based on @OOPer's suggestion to retry the startAccessingSecurityScopedResource method I was able to get this working. Adding my code here as an example for anyone that may find this useful. Thank you @OOPer and @Claude31.
.fileImporter(isPresented: $isImporting, allowedContentTypes: [.zip], allowsMultipleSelection: false
) { result in
do {
guard let selectedFile: URL = try result.get().first else { return }
if selectedFile.startAccessingSecurityScopedResource() {
guard let dest = moveZip(sourceUrl: selectedFile) else { print("Error")
return
}
self.dfuFile = dest
selectedFile.stopAccessingSecurityScopedResource()
}
self.dfuFirmware = DFUFirmware(urlToZipFile: self.dfuFile, type: DFUFirmwareType.application)
self.dfuActive = true
} catch {
// Handle the Failure
print("Unable to read file")
print(error.localizedDescription)
}
}
Post
Replies
Boosts
Views
Activity
After debugging more of the application code we've found that there is different behaviour based on if the Service Changed characteristic is set. (See the Bluetooth 4.0 specification, Volume 3, Part G, Section 7.1) When that characteristic is enabled it seems that the iOS side uses cached values from the initial characteristic discovery but only on the iOS side, macOS works correctly.
This still isn't clear as the service changed characteristic is used to notify of when to not use the cached values. I will still be investigating why this issues only appears on iOS but I will mark this as closed for the time being. I will still monitor if anyone has any comments or insight! Thanks!
@OOPer That characteristic is the SW version which is static for the build. I've added an answer to this question after working though debug builds on the dev kit.