Posts

Post not yet marked as solved
1 Replies
655 Views
Hello, I have an app in the App Store that is your typical cleaner app. The app searches for files from deleted apps and can remove them. Under macOS Sonoma the app does no longer work. When deleting files, the following message appears in the Console: System Policy: App(1636) deny(1) file-write-unlink The app has scoped bookmarks for the folder and additionally I added Full Disk Access for my app - it still does not work? Is there another layer on top of that? The app works perfectly fine on Big Sur, Monterey and Ventura. Regards, Sascha
Posted
by inexcitus.
Last updated
.
Post marked as solved
1 Replies
362 Views
Hello, in my app I need the current amount of free space on a certain volume. I use the following code to the this information: if let mountedVolumeURLs = FileManager.default.mountedVolumeURLs(includingResourceValuesForKeys: nil) { for volumeUrl in mountedVolumeURLs { guard let values = try? self.url.resourceValues(forKeys: [.volumeTotalCapacityKey, .volumeAvailableCapacityKey]) else { continue } let totalBytes = values.allValues[.volumeTotalCapacityKey] as? UInt64 ?? 0 let freeBytes = values.allValues[.volumeAvailableCapacityKey] as? UInt64 ?? 0 // This is not always correct. } } When writing to a volume and then calling the code above, a wrong amount is returned. I suspect that there is still some cacheing going on. Is there any function that I can call to get this information from the file system without any cacheing? I guess an alternative would be to get a list of all files, get their sizes, add them up and subtract that number from the total bytes of the volume. But maybe there is a more elegant solution. I also tried something like this: let handle = try FileDescriptor.open(volumeUrl.path, .writeOnly, options: .create, permissions: .ownerReadWrite, retryOnInterrupt: true) fcntl(handle.rawValue, F_FULLFSYNC) But this did not help. I would appreciate any help. Regards
Posted
by inexcitus.
Last updated
.
Post not yet marked as solved
3 Replies
612 Views
I am trying to load an app icon from an icns file. I am using the following code: guard let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.microsoft.VSCode") else { return nil } let icon = NSWorkspace.shared.icon(forFile: url.path) This seems to work very fine for all apps that I tested. All of them? No. Loading the icon for Visual Studio Code takes 4-5 seconds. Are there any other, faster methods? I also tried to use NSImage(contentsOfFile: url.path) which also takes very long. I have uploaded the icns file here: https://sascha-simon.com/Code.icns How can this behavior be explained?
Posted
by inexcitus.
Last updated
.
Post marked as solved
4 Replies
985 Views
I have a couple of Apple devices in my network (both computers and mobile devices). I was wondering if it is possible, to get the model identifier like Macmini9,1 if I have the IP address and/or the Mac address. I am using the NetServiceBrowser and NetService classes to find the devices. If the device has the AirPlay service, I can get the model identifier. However, not all of my devices seem to implement/publish this service. Is there a more general approach? macOS seems to know this information. In the Finder a specific icon is shown, so I guess the model identifier must be published somehow.
Posted
by inexcitus.
Last updated
.
Post marked as solved
3 Replies
1.2k Views
Xcode always creates targets /schemes for referenced Swift packages. In my app there are 14 Swift packages that are referenced. My app itself has two targets (app and an auto launcher) and Xcode creates targets for two schemes. I don't understand why those schemes are created (and why not for every package). Is there any way to disable this feature? Can someone explain why Xcode creates schemes for referenced Swift packages? I deleted the schemes several times, but Xcode simply recreates them.
Posted
by inexcitus.
Last updated
.
Post marked as solved
6 Replies
2.5k Views
Hello, I have many apps that use LoginItem logic to enable the auto start. I always used the function SMLoginItemSetEnabled to enable or disable the launch of the LoginItem. I am using macOS Ventura Beta for quite some time now and I noticed that whenever I launch one of my apps, a message appears. It says that my app added some functions. When I click on the message, the Login Items section of the System Preferences opens and my recently opened app is listed under "Allow in the Background". I want to port my apps to the new logic but I am not quite sure how to do that. I don't want my apps to appear under the "Allow in the Background" section but rather in the "Open at Login" section. I am using the following code to enable or disable the auto start under macOS 13.0+: if autoLogin { try? SMAppService.mainApp.unregister() } else { try? SMAppService.mainApp.register() } This works very well. If I check my switch, the app appears under the "Open at Login" section. If I disable the switch, the app disappears from this list. Great, this is what I want. However...when I restart my Mac, the app is launched automatically. And now there is a new entry in the "Allow in the Background" section again. What am I doing wrong? Should I register or unregister the LoginItem instead? This is not really what I want, it appears in the wrong section and I think this is confusing for users. I read somewhere else that the user consent is stored, even when resetting with sfltool or something like that. Does the item appear in this section (and is launched automatically) because I launched the app earlier without my new logic? Is this simply a bug? has anyone a working example of how to properly support auto launching an application under macOS Ventura and earlier versions? Regards, Sascha
Posted
by inexcitus.
Last updated
.
Post not yet marked as solved
3 Replies
1.1k Views
Hello, I am trying to get a FileHandle for a specific file on an external hard disk. My app is sandboxed and in order to be able to get a FileHandle I am showing a NSOpenPanel so the user can grant permission to access this disk. After the user has granted permissions, I use the following code to get the handle: guard let readDescriptor = try? FileDescriptor.open(readUrl.path, FileDescriptor.AccessMode.readWrite) else { return } I get the following error when this code runs: The operation couldn’t be completed. Operation not permitted What I don't understand is the fact that this code only fails on disks that have the MS-DOS file system. I have tested various USB sticks, SD cards and external hard drives. It works fine for the APFS, but once I format the device as MS-DOS, the code fails. Has anyone any idea why that is? Regards, Sascha
Posted
by inexcitus.
Last updated
.
Post not yet marked as solved
3 Replies
2.6k Views
I am using the App Store Connect API to receive information about my app. I have noticed that the API is so extremely slow. Are there any tipps to speed up the requests? Take this request for example: https://api.appstoreconnect.apple.com/v1/builds?filter[app]=1234854699&limit=1&fields[builds]=iconAssetToken To me, this seems like a pretty straightforward request. Out of all build, get the latest one and return it. However, this request takes between 3 and 5 seconds. I need to send this request for each of my apps, so getting the builds alone can take up to 20 seconds which is not acceptable. Other requests are very slow as well. For simple requests like that I expect response times within a couple of hundreds milliseconds. Am I missing something? I have used Postman to send the request. I did not send any additional headers, only the Authorisation one.
Posted
by inexcitus.
Last updated
.
Post marked as solved
3 Replies
999 Views
Hello, I am trying to implement some sort of minimal I/O benchmarking feature. I can calculate the write speeds with the following code: guard var handle = FileHandle(forUpdatingAtPath: url.path) else { return } var writtenData: UInt64 = 0 var totalWrittenData: UInt64 = 0 var writeSpeed: UInt64 = 0 let data = Data(repeating: 0, count: 16 * 1024 * 1024) // 16 MB test block let startTime = Date.now.timeIntervalSince1970 while Date.now.timeIntervalSince1970 - startTime < 5.0 { handle.write(data) try? handle.synchronize()self.totalWrittenData += blockSize let duration = Date.timestamp - self.startTime writeSpeed = UInt64(Double(self.totalWrittenData) / duration) if writtenData > blockSize * 16 { writtenDara = 0 try? handle.seek(toOffset: 0) } } // On my PCE-Express SSD this results in roughly 1800MB/s. This value matches the value reported by other benchmarking apps. // Remove everything at the end of the file try? handle.truncate(atOffset: blockSize) try? handle.synchronize() try? handle.seek(toOffset: 0) var index = 0 while index < 5 { autoreleasepool { var startTime = Date.timestamp let bytes = try? handle.readToEnd() let duration = Date.timestamp - startTime          Swift.print(bytes?.count, duration) try? handle.seek(toOffset: 0) } index += 1 } The code works - in theory. Although I really like that the operating system and drivers do some cacheing to optimise performance - in my use case I don't want files to be cached. The read results are always around 8GB/s for my PCE-Express SSD and also for some older USB Sticks, so the data seems to come directly from the memory. I found a couple of other threads which led me to some older C functions, specifically this code: // Open file. let fd = fopen(fileUrl.path, "r") // Find the end fseek(fd, 0, SEEK_END) // Count bytes let fileByteSize = ftell(fd) // Return to start fseek(fd2, 0, SEEK_SET) // Disable cache setvbuf(fd2, nil, _IONBF, 0) // Find the end fseek(fd2, 0, SEEK_END) let readBytes = fread(pointer, 1, fileByteSize, fd2) readBytes += UInt64(readBytes.count) When executing this code (or parts of it), it also works fine - but the data is also coming from the cache. What am I missing? I also tried the FileManager. Of course I am not an expert, however I think that the FileManager is "just" a wrapper around all those C functions. Is there any way to ignore the cacheing mechanism and tell macOS / the driver to read the data directly from the drive? Regards, Sascha
Posted
by inexcitus.
Last updated
.
Post not yet marked as solved
4 Replies
4.2k Views
Hello, I am the developer of an app that is published on the App Store. This app connects to Bluetooth devices to read their battery levels. However, it seems that CoreBluetooth, which is used to discover and connect to devices, has completely stopped working on macOS Monterey. The delegate methods are no longer triggered. When I start my app I see the following messages in the output area: [CoreBluetooth] No name or address The Console app shows a lot of this messages: error 14:56:23.730415+0200 bluetoothd Server.Core sdp attributes is empty I don't know if this is related in any case. Are there any new entitlements or something like that? I did not change any single line and on Big Sur, everything works fine. A customer of mine, which also uses the beta version, already contacted me, so this seems to be a general issue - at least with my app? The app also works fine on Big Sur for the customer.
Posted
by inexcitus.
Last updated
.
Post marked as solved
1 Replies
756 Views
Hello, I have a macOS app that is available on the Mac App Store. Yesterday I wanted to copy the link of my app. I opened App Store Connect which was still loading. I saw the correct link and clicked it. However, just in the moment when I clicked it, the page layout changed and the link became the link "Create iOS app". HOw I have my macOS build that is released and a new iOS version 1.0 for my app. I can not delete the iOS version. Is it possible or do I have to live with a useless build that will anooy me for the next couple of years? Regards
Posted
by inexcitus.
Last updated
.
Post marked as solved
5 Replies
1.6k Views
I am trying to develop an application that also contains an extension for the Finder. The extension can be used to create a new text file at the current Finder location. I have only added the following permissions to the entitlements file for both the main app and the extension: com.apple.security.files.user-selected.read-only I have implemented the FIFinderSync protocol in my extension. I added a menu item to create a new text file. Whenever I execute this method, the following error is shown in the Console: Sandbox: Extension(4032) deny(1) file-write-create /Users/username/Documents/New Text.txt The simplest way to get around this error is to add the following key: com.apple.security.temporary-exception.files.home-relative-path.read-write However, applications using this entitlement will be rejected during app review. The extension is initialised with this code: FIFinderSyncController.default().directoryURLs = [URL(fileURLWithPath: "/")] How can I prevent this error to be thrown? I could use security scoped bookmarks, open a dialog and then save this bookmark. However, I have tested plenty of extension available in the App Store and none of them have shown any NSOpenPanel, the files have been created without any problems. Any help is appreciated.
Posted
by inexcitus.
Last updated
.
Post marked as solved
5 Replies
2.1k Views
Hello, I ran into a big problem for which I don't know how to proceed. Every developer can create up to five Developer ID certificates. Those certificates are used if you want to release your app outside the Mac App Store. I have an app on the Mac App Store that also offers a helper application, which is downloadable on my homepage. I have created a new version of this helper application and wanted to send it to the notarization service of Apple. Xcode displayed an error that I do not have a valid Devloper ID certificate (because the private key is missing) and I can not create a new one because I already created five certificates. I can download the certificates without problem, but I can not get the private key. At least one developer certificate was created on my machine, but It does not seem to work. Because I assumed that there is no way of getting these certificates back (always create backups!), I contacted Apple to see if they are willing to revoke any old certificates so I can create a new one (I know that at least the first two certificates are not being used, so they could be revoked, but Apple does not revoke old certificates). Right now, Apple decides whether they grant me an exception to create additional certificates. Let's assume Apple declines this request...what can I do? Can I create a second developer account? I don't care about the 99€, but it does not seem that this is allowed. Big Sur will be released tomorrow and I really need to sign this app. And yes, I know that I should keep a backup copy of my private keys in the future ;) Is there anything I can do (especially if Apple declines the request)? Any help is highly appreciated. Kind Regards, Sascha
Posted
by inexcitus.
Last updated
.
Post not yet marked as solved
3 Replies
1.1k Views
Hello, I am trying to calculate the upload speed of my WiFi network adapter. I have noticed that the value for the sent bytes (upload) is always double the expected value. I am running a speediest and my downstream is 30Mb/s. However, my upload speed in my app shows a little less than 8 MB/s which is actually double the value (it should be approx. 4MB/s). Playground - https://developer.apple.com/forums/content/attachment/63d94243-0f1b-426d-97bf-86a0be2dfe58 This issue can be reproduced with the attached Playground. What could be the reason for this? It does not happen with Download speed.
Posted
by inexcitus.
Last updated
.