When users share a file with my app I am having trouble 5-10% of the time obtaining the file meta data, specifically creation and modified time and size.
Using SwiftUI with the code below..
.onOpenURL { url in
var fileSize: Int64 = 0
var creationTime: Date = Date(timeIntervalSince1970: 0)
var modificationTime: Date = Date(timeIntervalSince1970: 0)
do {
let fileAttributes = try FileManager.default.attributesOfItem(atPath: url.path)
fileSize = fileAttributes[FileAttributeKey.size] as? Int64 ?? 0
creationTime = fileAttributes[FileAttributeKey.creationDate] as? Date ?? Date(timeIntervalSince1970: 0)
modificationTime = fileAttributes[FileAttributeKey.modificationDate] as? Date ?? Date(timeIntervalSince1970: 0)
<SNIPPED CODE no other tries though and not involving above variables>
} catch {
// quite confident I am ending up here because variables after the above code aren’t being set and there are no other try blocks,
// so FileManager.default.attributesOfItem(atPath: url.path) must be throwing….
}
<SNIPPED CODE>
To attempt to resolve this, I added in a 0.5 second wait cycle if creationTime == 0 and modificationTime == 0 , so if obtaining both metadata fails, wait 0.5 seconds and try again, try this a max of 3 times and then give up. I don’t know how often I am entering this code (didn’t instrument the app for it), but am still getting times when metadata comes back blank which means this code wasn’t successful after 3 tries.
I assume the file would only become visible and sharable with my app after it has completed being written by the original app/process. Perhaps it hasn’t finalized yet? Is there a way to detect this so I can tell the user in my share screen to wait and try again?
I am assuming that the file has finished writing though since when I read the data from the file contents, it’s good data and complete even when metadata failed.
I will be instrumenting the above code in my next app version, just hoping to fix it right now since users are emailing saying my app is broken.
Thanks!
Core OS
RSS for tagExplore the core architecture of the operating system, including the kernel, memory management, and process scheduling.
Post
Replies
Boosts
Views
Activity
The sample code uses a static variable of the PeripheralViewController class to account for congestion in the BLE stack - which is frowned upon by the Swift 6 compiler.
Why does this variable need to be static in the first place?
Suppose there is a key in the keychain that is protected by an ACL which specifies .userPresence as its access control - is it possible to prevent the user from being prompted to authenticate with biometrics and to force authentication via the device passcode instead?
Crashed: com.apple.root.default-qos
0 libobjc.A.dylib 0x275c objc_release + 16
1 libobjc.A.dylib 0x275c objc_release_x0 + 16
2 libobjc.A.dylib 0x5acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116
3 libobjc.A.dylib 0x4f00 objc_destructInstance + 80
4 libobjc.A.dylib 0x4ea4 _objc_rootDealloc + 80
5 CoreServices 0x47f0 std::__1::__hash_table<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::__unordered_map_hasher<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::hash<objc_selector*>, std::__1::equal_to<objc_selector*>, true>, std::__1::__unordered_map_equal<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::equal_to<objc_selector*>, std::__1::hash<objc_selector*>, true>, std::__1::allocator<std::__1::__hash_value_type<objc_selector*, objc_object* __strong> > >::__deallocate_node(std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, void*>>) + 36
6 CoreServices 0x47ac std::__1::__hash_table<std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::__unordered_map_hasher<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::hash<objc_selector*>, std::__1::equal_to<objc_selector*>, true>, std::__1::__unordered_map_equal<objc_selector*, std::__1::__hash_value_type<objc_selector*, objc_object* __strong>, std::__1::equal_to<objc_selector*>, std::__1::hash<objc_selector*>, true>, std::__1::allocator<std::__1::__hash_value_type<objc_selector*, objc_object* __strong> > >::~__hash_table() + 28
7 CoreServices 0x4760 -[LSRecord dealloc] + 36
8 CoreServices 0x472c -[LSBundleRecord dealloc] + 72
9 CoreServices 0x1bb7c -[LSApplicationProxy .cxx_destruct] + 60
10 libobjc.A.dylib 0x5acc object_cxxDestructFromClass(objc_object*, objc_class*) + 116
11 libobjc.A.dylib 0x4f00 objc_destructInstance + 80
12 libobjc.A.dylib 0x4ea4 _objc_rootDealloc + 80
13 CoreServices 0xb42d4 +[LSBundleProxy clearBundleProxyForCurrentProcess] + 48
14 CoreServices 0xb436c __45+[LSBundleProxy bundleProxyForCurrentProcess]_block_invoke.21 + 36
15 libdispatch.dylib 0x3dd4 _dispatch_client_callout + 20
16 libdispatch.dylib 0x72d8 _dispatch_continuation_pop + 600
17 libdispatch.dylib 0x1b1c8 _dispatch_source_latch_and_call + 420
18 libdispatch.dylib 0x19d8c _dispatch_source_invoke + 832
19 libdispatch.dylib 0x6dc4 _dispatch_queue_override_invoke + 504
20 libdispatch.dylib 0x15894 _dispatch_root_queue_drain + 392
21 libdispatch.dylib 0x1609c _dispatch_worker_thread2 + 156
22 libsystem_pthread.dylib 0x48f8 _pthread_wqthread + 228
23 libsystem_pthread.dylib 0x10cc start_wqthread + 8
In iOS 18 if a number is registered with CallKit to be blocked, then if that number is also in contacts, then the number isn't blocked.
If a user has added a number to their contacts, then in all probability they might not want the number blocked, so this might seem reasonable behaviour.
However the point is, this is new behaviour for CallKit in iOS 18, and its never been like this before going back several years to the very first release. Why suddenly change it now, after all these years, without notice nor documentation, and take away that option from the user, should for some reason, they want to block a number which is also in their contacts.
This is quite a disruptive change for apps using CallKit.
Our macOS application does not support case sensitive file systems. We have customers claiming that they purchased a new Mac and it was case sensitive by default without them taking any action.
I am looking for an authoritative answer to the question: Is there any Mac that ships case sensitive by default? Or is this something that the end user must configure?
Is it known how to open in macOS Sequoia the Endpoint Security Extensions Pane. is there any anchor available for
open "x-apple.systempreferences:com.apple.ExtensionsPreferences"?
My app saves its document files by default into ~/Documents. It does some important domain-specific stuff when a document is deleted. I monitor for deletion using https://github.com/eonist/FileWatcher
Unfortunately several users have noticed my app doing this cleanup work even when they have not deleted the corresponding document. We've traced it through and realised it's the iCloud "Optimise Mac Storage" feature, or "Store in iCloud > Desktop and Documents". I'm not sure which because I don't use these features of macOS at all, and also they seem to have been renamed or changed in Sonoma.
Either way, I'm wondering:
a) how I can tell in Swift whether a file has actually been deleted, or whether it's been "offloaded" to iCloud by macOS.
b) how can I test this?
My research is pointing at urlubiquitousitemdownloadingstatus but it's hard to play with it without knowing how to test it.
Hi, I’m an app developer and I would like to suggest that there is an API that allows me to check if the user has set their date and time setting to automatic. That setting should be accessible as a read only value.
This would allow several apps to operate offline as there is no longer a need to check the internet for an accurate time to prevent users from skipping time ahead.
I have implemented this check on my app on Android and it has been very well received as it is able to operate offline again. It would be a huge plus to be able to make my app offline compatible again.
How can I read a dataless file from within the same or another FileProvider extension?
When I pass the visible URL to AVAsset from AVFoundation, it throws the following error:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x15b01b1e0 {Error Domain=NSPOSIXErrorDomain Code=11 "Resource deadlock avoided"}, NSLocalizedFailureReason=An unknown error occurred (11), AVErrorFailedDependenciesKey=(
"assetProperty_Tracks"
), NSURL=file:///Users/<<username>>/Library/CloudStorage/<<file-path>>, NSLocalizedDescription=The operation could not be completed}
The code snippet works fine if executed as a separate Swift process.
I'm using AVAsset with AVAssetExportSession to export a subset of the file being read. So I can't use NSFileProviderManager.requestDownloadForItem(withIdentifier:, requestedRange:) because I don't know the offset range required by the AVFoundation library.
After the release of iOS17, our app has collected JavaScriptCore crashes, and the crash has recently appeared in iOS17 and above. The number of crashes collected recently is increasing.
We have tried various methods to troubleshoot and locate。
2024-05-08_20-45-00.5216_+0800-fdb980f66f56d73b944ccc3466922d7fd0690089.crash
2024-05-09_12-35-57.5470_+0800-70e61e8796f6967e04d1f523c54dde7b19dea31c.crash
T
2024-05-13_14-30-03.2084_+0800-d9598b08a153f5214b51257400423d4079049578.crash
he crash stack is as follows:
The issue
While testing how our app behaves on iOS 18 beta 6, we found an issue on one of our iPhones:
At some point, the app creates CBCentralManager in order to trigger an alert to request Bluetooth permission;
The alert is not shown;
centralManagerDidUpdateState never gets called, the state is always .unknown.
Below is a sample code I used to reproduce it easier:
class ViewController: UIViewController, CBCentralManagerDelegate {
var centralManager: CBCentralManager?
@IBOutlet weak var stateLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
print("Test app ready")
}
@IBAction func onPressedRequestPermission(_ sender: Any) {
self.stateLabel.text = "Requested BLE permission"
centralManager = CBCentralManager(delegate: self, queue: nil)
}
func centralManagerDidUpdateState(_ central: CBCentralManager) {
var stateString = ""
switch central.state {
case .poweredOn: stateString = "poweredOn"
case .unknown: stateString = "unknown"
case .resetting: stateString = "resetting"
case .unsupported: stateString = "unsupported"
case .unauthorized: stateString = "unauthorized"
case .poweredOff: stateString = "poweredOff"
@unknown default: stateString = "unknownDefault"
}
print("CBCentralState changed: \(stateString)")
self.stateLabel.text = "CBCentralState: \(stateString)"
}
}
I ran this code on two devices - one with the issue and one without it, and compared the logs from Console. I noticed that the last similar logs were
15:44:25.428118+0200 tccd AUTHREQ_PROMPTING: msgID=8163.2, service=kTCCServiceBluetoothAlways, subject=Sub:{...
After that, the bug-free device printed this within the next ~250ms:
15:44:25.432285+0200 SpringBoard Asked to bootstrap a new process for handle: [osservice<com.apple.tccd>:8144]
...
15:44:25.675380+0200 SpringBoard Received request to activate alertItem: <SBUserNotificationAlert: 0xc4289cf00; title: Allow “test1” to find Bluetooth devices?; source: tccd; pid: 8144>
and showed the request for Bluetooth permission.
At the same time, there were no such logs on the problematic device, and the request was not displayed.
Other apps behavior
nRF Connect app cannot request Bluetooth permission too on the same device. Usually it does that immediately after the first launch, but this time we saw only an error "Your device reports an unknown error for Bluetooth use." and no BT request alert.
The question
How can we programmatically detect that there is some unknown issue with Bluetooth in a similar way how nRF Connect does that?
Working on a file server in c/c++ and need to do following:
Validate user credentials (mac Username & password)
Impersonate user security context in a thread running in a daemon, so that I can enumerate user's home directory and files/folders.
Regarding 2, found API: pthread_setugid_np - is this the right approach? If so, how do I verify user credentials and call this API?
Found this section in TN2083:
Does this mean that its really not possible to impersonate user and access their home directory etc if the user isn't logged in via terminal/console? or if they have FileVault enabled?
Hi, I'm trying to use the FileProvider Diagnostics Profile for macOS to get more details while debugging my FileProviderExtension. But when installing it it says its already expired:
Any chance of getting an updated one that's not expired?
Hi,
after updating to iOS 18 beta 6, I’ve been experiencing unexpected behavior with CoreBluetooth when trying to discover primary services and characteristics of Bluetooth devices. This issue wasn’t present in previous iOS versions, such as iOS 17, where the same code and setup worked flawlessly.
Issue Details:
iOS 17: The primary services and characteristics are discovered without any issues.
iOS 18 Beta 6: Primary services and characteristics are not being discovered at all, leading to incomplete or failed Bluetooth communication.
Troubleshooting Steps Taken:
Verified Bluetooth permissions and settings in the app.
Tested the same codebase on devices running iOS 17 and iOS 18 beta 6.
Used nRF Connect to compare service
Has anyone else experienced this issue?
discovery results between different iOS versions.
When capturing materialized information from materializedItemsDidChange in NSFileProviderReplicatedExtension, the isDownloaded property of NSFileProviderItem is not set during the call to enumerate items (NSFileProviderEnumerationObserver:enumerateItems(for:startingAt:)).
Both the IsDownloaded and isMostRecentVersionDownloaded properties are returning false, even though the item is fully materialized
How to capture this information from file provider extension ?
Any help would be greatly appreciated. Thanks!
Our team has two products. The first product adds two /Library/LaunchDaemon startup items and one /Library/LaunchAgents startup item, which run normally after installation.
A few months later, our team developed another product, which adds two /Library/LaunchDaemon startup items and one /Library/LaunchAgents startup item. However, we found that on some customers' systems, these startup items for the second product do not load correctly, and the processes do not start. Restarting the system does not resolve the issue. This occurs across systems running versions 14.5 to 14.6.1.
The app's signatures, notarization, and Gatekeeper validations all pass. Eventually, we discovered that by disabling and then re-enabling our team's startup items in the System Settings - Login Items, all the startup items from our team load correctly. Could this be a caching bug related to new startup items from the same team?
We are having a problem in our C++ app with dlopen returning memory addresses which were previous reserved using mmap() with the MAP_ANON | MAP_PRIVATE | MAP_JIT flags. The mmap is memory is 4Kb page-aligned and returns normally, however sometime later dlopen() is returning an address within the mmap range when no munmap() has been performed. This looks like a bug in the macOS kernal memory manager.
Back in July, I opened support ticket FB14442215 where one of our Engineers was able to create a similar and reproducible problem using Preview to load a large bitmap. This ticket has not yet been acted upon, still showing a status of "Open" .
Any help or suggestions would be most welcome.
Norm Green
norm(dot)green(at)gemtalksystems(dot)com
I pipe powermetrics' stdout to another process. When the reader process exits, powermetrics will encounter an error the next time it writes to stdout but it is evidently ignoring this because it continues to run forever. This needs to be fixed so powermetrics can function as a useful UNIX citizen.
Hello Team,
I am working on a carrier app and want to get the status of IMS registration and deregistration. I understand that a public API is not available. Can we access a private API through an agreement with Apple? Please guide me. Thanks.