macOS is the operating system for Mac.

Posts under macOS tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

How to declare a TableColumn with nullable field?
How does one declare a TableColumn with a nullable field? I have a Book model with several nullable fields: struct Book: Codable, Equatable, Identifiable { // ... let productURL: String? // ... } This is how I'm trying define the corresponding TableColumn: TableColumn("Product URL", value: \.productURL) { book in Text(String(book.productURL ?? "")) } Though this results in several errors: Referencing initializer 'init(_:value:comparator:content:)' on 'TableColumn' requires that 'Book' inherit from 'NSObject' Referencing initializer 'init(_:value:comparator:content:)' on 'TableColumn' requires that 'Book' inherit from 'NSObject' Referencing initializer 'init(_:value:comparator:content:)' on 'TableColumn' requires the types 'KeyPathComparator' and 'SortDescriptor' be equivalent Referencing initializer 'init(_:value:comparator:content:)' on 'TableColumn' requires the types 'KeyPathComparator' and 'SortDescriptor' be equivalent Other, non-nullable columns work just fine. For example: TableColumn("ID", value: \.id) { book in     Text(String(book.id)) } TableColumn("Slug", value: \.slug) TableColumn("Category", value: \.category) TableColumn("Title", value: \.title) // ...
8
0
2.7k
Nov ’23
Swift Process with Psuedo Terminal (PTY)
Hi! I'm looking for some insight and guidance on using the Foundation.Process type with a PTY (Psuedo Terminal) so that the subprocess can accept input and behave as if it was running via a terminal. The reason for needing a PTY is that for programs like ssh or in my case (xcodes) which ask for user input including passwords, running these via Foundation.Process does not display the prompts to the user as the output is usually buffered (this works fine in the Xcode debugger console but when running via a real terminal that is buffered the prompts are never displayed in the terminal) Looking at other threads it seems like correct approach here is create a PTY and use the filehandles to attach to the Process. While I've got this to work to the point where prompts are now shown, I cant seem to figure out how to pass input back to the process as these are being controlled by the PTY. Here is my Process setup: let process = Process() // Setup the process with path, args, etc... // Setup the PTY handles var parentDescriptor: Int32 = 0 var childDescriptor: Int32 = 0 guard Darwin.openpty(&parentDescriptor, &childDescriptor, nil, nil, nil) != -1 else {   fatalError("Failed to spawn PTY") } parentHandle = FileHandle(fileDescriptor: parentDescriptor, closeOnDealloc: true) childHandle = FileHandle(fileDescriptor: childDescriptor, closeOnDealloc: true) process.standardInput = childHandle process.standardOutput = childHandle process.standardError = childHandle With this setup I then read the parent handle and output any result it gets (such as the input prompts): parentHandle?.readabilityHandler = { handle in   guard let line = String(data: handle.availableData, encoding: .utf8), !line.isEmpty else {     return   }   logger.notice("\(line)") } When process.run() is executed the program runs and I can see it asks for Apple ID: input in my terminal, however, when typing input into the terminal the process does not seem to react to this input. I've tried forwarding the FileHandle.standardInput: FileHandle.standardInput.readabilityHandler = { handle in   parentHandle?.write(handle.availableData) } But this doesn't seem to work either. What is the recommended way to setup a PTY with Foundation.Process for executing arbitrary programs and having them behave as if they were being run in a terminal context? Most of the resources I found online are about other languages and I'd like to stick with Foundation.Process vs. doing anything custom in C/C++ if possible as it just makes it easier to reason about / maintain. The resources for Swift on this topic are very lacking and I've checked out some open source projects that claim to do this but most require manually sending input to the PTY handle vs. accepting them from the user in a terminal. Any insight / help is very much appreciated!
9
0
2.9k
Mar ’24
Can't add new email address with iCloud+ Custom Domain
I've set up a couple of domains (seemingly) successfully with iCloud+ Custom Domains. All the DNS entries are correct. Now, when I attempt to add an email address I get the error "There was a problem with adding this email address. Please try again later." This has been happening for over 24 hours. I'm not quite sure how to proceed - I know this is in Beta, but I keep reading how it is working for other people so its hard to think this is a general problem. I'm adding entirely new domains so there is no chance that the email addresses are previously known by Apple / used for a previous AppleID. Any ideas please?
11
0
2.6k
Apr ’24
Kernel panic crash with 2 external LG displays - Monterey 12.0.1 MacBook Pro (16-inch, 2019)
After installing Monterey 12.0.1, my MacBook Pro crashes if I have the laptop retina display open and both LG monitors connected. Worked fine on Big Sur, no other changes. I can run the retina and one LG display, or run both LG displays with the laptop lid closed, but it kernel panics after about 60 seconds if all three displays are on. MacBook Pro (16-inch, 2019) 2.3 GHz 8-Core Intel Core i9 32 GB 2667 MHz DDR4 AMD Radeon Pro 5500M 4 GB 1 TB SSD (APPLE SSD AP1024N) Monitors: LG 27UD68-P Each connected through a separate USB-C hub via HDMI Both plugged in on the right-hand side of the MacBook
54
6
21k
Aug ’23
Mouse scrolling stops working in macOS Monterey
Hi all I have MacBook Pro M1. Yesterday I upgraded my Mac with new macOS Monterey 12.0.1. Since that upgrade my Apple mouse sometimes stops scrolling. It happens when I leave Mac, it goes to sleep mode and when I come back and try to scroll it doesn't work To fix it I turn my mouse off and the turn on. Who has the same problem let me know in comments please
324
6
112k
Oct ’23
Azure DevOps (TFS) in Safari keeps asking password
After upgrading to macOS Monterey, Safari keeps showing authentication prompts for the on-premises Azure DevOps instance. Interesting that I can keep pressing the cancel button on the login form, and it works. In other browsers (Microsoft Edge, Chrome), all works fine -- I enter login/password one time and it never asks me again. In the browser tab, I see that the /connect request got stuck, but I don't know how to troubleshoot it further. Any suggestions? Environment information: macOS version: 12.0.1 Safari version: 15.1 Azure DevOps Server 2020 Update 1.1
7
0
4.3k
Sep ’23
SwiftUI Mac OS toolbar button seems behind other elements
Hi I use a WindowsGroup with a NavigationView and inside of this a list as a sidebar and an HStack for the content. In addition I use a toolbar with several icons. It seems, that the toolbar is behind the content if the button contains only an image. It works correctly if I use an image and a text for the button. Only when I move the mouse pointer over the toolbar icon the icon becomes active and stays active. It doesn't matter where I place the toolbar or whether I use a padding for the content or not. And if I remove the top padding for the content the complete content area goes from edge to edge. I guess that I missed some modifier for the toolbar and/or the content, but can't figure out which one. Thank you for helping Swift version 5.5.1 Xcode 13.1 MacOS Monterey (12.0.1)     var body: some Scene {         WindowGroup {             NavigationView{                 List {                     Text("One")                     Text("Two")                 }                 Text("Hello, world!")                     .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)                     .background(Color.gray)                     .padding(.all, .zero)                     .padding(.top, 1.0) // removed this in video 2                     .toolbar {                         ToolbarItemGroup(placement: .navigation) {                             Button(action: {                             }, label: {                                 Image(systemName: "sidebar.left").imageScale(.large)                             })                             Button(action: {                             }, label: {                                 HStack{                                     Image(systemName: "sidebar.left").imageScale(.large)                                     Text("")                                 }                             })                         }                     }             }         }         .windowStyle(HiddenTitleBarWindowStyle())     }
2
0
2.8k
Aug ’23
ProRes encoding on M1 Max fails for high bit depth buffers
I have code that has worked for many years for writing ProRes files, and it is now failing on the new M1 Max MacBook. Specifically, if I construct buffers with the pixel type "kCVPixelFormatType_64ARGB", after a few frames of writing, the pixel buffer pool becomes nil. This code works just fine on non Max processors (Intel and base M1 natively). Here's a sample main that demonstrates the problem. Am I doing something wrong here? //  main.m //  TestProresWriting // #import <Foundation/Foundation.h> #import <AVFoundation/AVFoundation.h> int main(int argc, const char * argv[]) {     @autoreleasepool {         int timescale = 24;         int width = 1920;         int height = 1080;         NSURL *url = [NSURL URLWithString:@"file:///Users/diftil/TempData/testfile.mov"];         NSLog(@"Output file = %@", [url absoluteURL]);         NSFileManager *fileManager = [NSFileManager defaultManager];         NSError *error = nil;         [fileManager removeItemAtURL:url error:&error];         // Set up the writer         AVAssetWriter *trackWriter = [[AVAssetWriter alloc] initWithURL:url                                                    fileType:AVFileTypeQuickTimeMovie                                                         error:&error];         // Set up the track         NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:                                        AVVideoCodecTypeAppleProRes4444, AVVideoCodecKey,                                        [NSNumber numberWithInt:width], AVVideoWidthKey,                                        [NSNumber numberWithInt:height], AVVideoHeightKey,                                        nil];                  AVAssetWriterInput *track = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo                                                         outputSettings:videoSettings];         // Set up the adapter         NSDictionary *attributes = [NSDictionary                                     dictionaryWithObjects:                                     [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_64ARGB], // This pixel type causes problems on M1 Max, but works on everything else                                      [NSNumber numberWithUnsignedInt:width],[NSNumber numberWithUnsignedInt:height],                                      nil]                                     forKeys:                                     [NSArray arrayWithObjects:(NSString *)kCVPixelBufferPixelFormatTypeKey,                                      (NSString*)kCVPixelBufferWidthKey, (NSString*)kCVPixelBufferHeightKey,                                      nil]];         /*         NSDictionary *attributes = [NSDictionary                                     dictionaryWithObjects:                                     [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32ARGB], // This pixel type works on M1 Max                                      [NSNumber numberWithUnsignedInt:width],[NSNumber numberWithUnsignedInt:height],                                      nil]                                     forKeys:                                     [NSArray arrayWithObjects:(NSString *)kCVPixelBufferPixelFormatTypeKey,                                      (NSString*)kCVPixelBufferWidthKey, (NSString*)kCVPixelBufferHeightKey,                                      nil]];         */         AVAssetWriterInputPixelBufferAdaptor *pixelBufferAdaptor = [AVAssetWriterInputPixelBufferAdaptor                             assetWriterInputPixelBufferAdaptorWithAssetWriterInput:track                             sourcePixelBufferAttributes:attributes];         // Add the track and start writing         [trackWriter addInput:track];         [trackWriter startWriting];         CMTime startTime = CMTimeMake(0, timescale);         [trackWriter startSessionAtSourceTime:startTime];         while(!track.readyForMoreMediaData);         int frameTime = 0;         CVPixelBufferRef frameBuffer = NULL;         for (int i = 0; i < 100; i++)         {             NSLog(@"Frame %@", [NSString stringWithFormat:@"%d", i]);             CVPixelBufferPoolRef PixelBufferPool = pixelBufferAdaptor.pixelBufferPool;             if (PixelBufferPool == nil)             {                 NSLog(@"PixelBufferPool is invalid.");                 exit(1);             }             CVReturn ret = CVPixelBufferPoolCreatePixelBuffer(nil, PixelBufferPool, &frameBuffer);             if (ret != kCVReturnSuccess)             {                 NSLog(@"Error creating framebuffer from pool");                 exit(1);             }             CVPixelBufferLockBaseAddress(frameBuffer, 0);             // This is where we would put image data into the buffer.  Nothing right now.             CVPixelBufferUnlockBaseAddress(frameBuffer, 0);             while(!track.readyForMoreMediaData);             CMTime presentationTime = CMTimeMake(frameTime+(i*timescale), timescale);             BOOL result = [pixelBufferAdaptor appendPixelBuffer:frameBuffer                                            withPresentationTime:presentationTime];             if (result == NO)             {                 NSLog(@"Error appending to track.");                 exit(1);             }             CVPixelBufferRelease(frameBuffer);         }         // Close everything         if ( trackWriter.status == AVAssetWriterStatusWriting)             [track markAsFinished];         NSLog(@"Completed.");     }     return 0; }
21
0
5.6k
Oct ’23
Xcode 13 on Apple silicon not running app with error A build only device cannot be used to run this target.
On xcode 13, I have macos project that runs fine on intel machine. On apple silicon (M1 Plus) I get the error "A build only device cannot be used to run this target.", when I try to run from Xcode. This seems to be an ios error. All Google suggested fixes involve picking a new device which is an ios fix. Right? Bulids fine and Archive app runs fine. I get the error for both intel and Arm64 architectures. I tried building for Target deployment target device families and Deployment as: macos 12.0 sdk any suggestions?
6
0
3.2k
Jan ’24
Kernel Panics on M1 Mac on Monterrey Beta with OWC Hub
Have had Macs since the early 2000s and buy a new Mac every year or two tops. Over the past decade only remember a couple kernel panics. However upgraded from my MBP16 to a MBP14 M1 Max (completely maxed out). And since getting have had about 8+ kernel panics. Where all of the sudden the mac freezes (not spinning wheel) but rather the whole screen and even trackpad and clock etc freezes and then the fans go full throttle, and then the machine restarts after about 30 seconds. Was using Monterrey betas all year on the intel mac. And when getting the new mac upgraded to latest betas as well. I like probably most mac laptop devs, plugin a hub. OWC Thunderbolt 4. Noticed the panics seemed to be happening when plugging in or unplugging from the hub such as in the morning and evening. On beta 2 consistently. On beta 3, seemed like Apple fixed the bug since didn't happen when plugging/unplugging, but a couple days later it happened again when unplugging. This time, it froze but fan didn't turn on and didnt auto restart so I had to force restart it. Hasn't haven't again yet in the past couple of days, but worried it will. Has anyone reported this issue before on M1 Macs when using a hub such as OWC and on latest
2
0
1.2k
Jul ’23
Diskmanagement.disenter error 49218
Hello everyone, I'm having a little issue with mounting my external hard drive lately. I've tried quite a few methods in hope of getting it to work again, but so far, no luck. I hope someone can help me solve this issue, or those who have the same problem may also share your insights. My external hard drive was working fine about a week ago. But one day, I ejected the hard drive and the icon disappeared, so I thought it was safe to unplug it. When I did, it said the hard drive was not properly removed. It still works fine when I use it the next day, but the same thing happened. It said the drive was not properly removed after I ejected the drive, waited for the icon to disappear, and then unplugged the drive. After that, it never works again, and the attached images are the info I got when I tried to mount or run first aid on this drive. Please help & thank you in advance! Computer: 27" iMac - MacOS Monterey External Hard Drive: WD_Black 4TB. APFS encrypted
68
10
62k
Jan ’24
How to make an M1-only (native-only) app?
I moved my Intel-based project to my new M1 machine (Pro Max), and it builds and runs fine, but only as a Intel/Rosetta app. I read that xCode builds a hardware-specific app for testing and debugging, but the app it's building for me is running as an Intel app (regardless of whether I'm running it under xCode or launching it stand-alone). Under Architectures, it says: Standard Architectures (Apple Silicon, Intel) - $(ARCHS_STANDARD) What should I put there to force it to make an M1-only app? (I'm making an app just for my own use, not for distribution.)
8
1
6.9k
Oct ’23
file provider does not get loaded on addDomain
I have created working fileprovider, that works perfectly on my local machine. Codesigned in xcode, with our company sign certificate as Developer ID Application. No provisioning profile. Also notarized result dmg. Works as expected on my local machine. But won't load on any other machine. Calling [NSFileProviderManager addDomain: ...], ends up with error: Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.} Code=-2001 should mean, that no file provider manager extension was found in an app bundle. I have made a TestFileProvider application that is totally simplified File Provider example. This too does work only on my own machine. Relevant code from app: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSFileProviderDomain* fileProviderDomain = [[NSFileProviderDomain alloc] initWithIdentifier:@"com.xxxxx.dwc.FileProvider" displayName:@"TestDomain"]; [NSFileProviderManager addDomain:fileProviderDomain completionHandler:^(NSError * _Nullable error) { if (error) NSLog(@"add domain: %@", error); else NSLog(@"add domain SUCCESS"); }]; } There are also these errors, that are related, but I do not understand what are they implying neither how to fix: kernel Sandbox: fileproviderd(448) deny(1) file-read-data /Applications/TestFileProvider.app fileproviderd [ERROR] PluginRecord doesn't have container url for fileproviderd [WARNING] No provider found with identifier (null) for calling bundle (null) on second attempt. I'm clueless on how to fix this. Is this related to codesign ? Or is it necessary to start fileprovider with different method call ?
4
1
3.1k
Sep ’23
Badge label not appearing in Monterey 12.0.1
Using the Lazarus IDE and Free Pascal the following code works in previous macOS versions, but not in Monterey: procedure TForm1.FormActivate(Sender: TObject); begin NSApp := NSApplication.sharedApplication; end; procedure TForm1.Button1Click(Sender: TObject); begin NSApp.dockTile.setBadgeLabel(NSStr('1')); end; Any ideas why it fails in Monterey? There are no related errors in the system console log.
3
0
846
Nov ’23
macOS bundled OpenSSH 8.6p1 seems don't support FIDO keys
Since 8.2p1 OpenSSH support for FIDO/U2F hardware authenticators, add "ed25519-sk" and "ecdsa-sk" key type. macOS Monterey 12.2 bundled OpenSSH (version: 8.6p1) doesn't include built-in security keys support, but it seems that user can specify middle ware library to use FIDO authenticator-hosted keys (see man ssh-add, man ssh_config and man ssh-agent). I try to implement FIDO security key provider library, but bundled ssh-agent seems don't try to load the implemented library and simply return with "unknown or unsupported key type": $ ssh-agent -d -P "/*" SSH_AUTH_SOCK=SOME_VALUE; export SSH_AUTH_SOCK; echo Agent pid SOME_VALUE; debug1: new_socket: type = SOCKET debug2: fd 3 setting O_NONBLOCK debug1: new_socket: type = CONNECTION debug3: fd 4 is O_NONBLOCK debug1: process_message: socket 1 (fd=4) type 25 debug2: process_add_identity: entering debug1: parse_key_constraint_extension: constraint ext sk-provider@openssh.com debug1: process_add_identity: add sk-ssh-ed25519@openssh.com SHA256:KEY_HASH "KEY_COMMENT" (life: 0) (confirm: 0) (provider: /path/to/libsk-libfido2.so) debug1: new_socket: type = CONNECTION debug3: fd 4 is O_NONBLOCK debug1: process_message: socket 1 (fd=4) type 11 debug2: process_request_identities: entering debug1: process_message: socket 1 (fd=4) type 13 debug1: process_sign_request2: entering Confirm user presence for key ED25519-SK SHA256:KEY_HASH process_sign_request2: sshkey_sign: unknown or unsupported key type User presence confirmed Manually install OpenSSH from third-party (such as MacPorts/Homebrew, or simply build it from source code) works, but third-party OpenSSH can't read passwords stored in Keychain. Is bundled OpenSSH disable hardware key support at build time? Advice most appreciated. Thank you!
13
19
5.9k
Oct ’23
Inquiry about the failure to decrypt the profile when registering the DEP of MacOS.
The MAC device is a device that has been manually added to the Apple Business Manager. DEP profiles are normally installed in both iOS and iPadOS. Profile descript error occurs only when attempting DEP of MacOS. (If you look at the picture, a decryption error occurs in the remote device registration step.) I asked Apple's customer center about this problem,  and it is said that it is caused by the lack of a key called "automatic registration on the MDM server" The key cannot be found in the Apple official document related to the profile below. https://developer.apple.com/documentation/devicemanagement/mdm/ Information received during DEP enroll of Macmini using Apple silicon. {    'LANGUAGE': 'en_US',    'PRODUCT': 'Macmini 9,1',    'SERIAL': 'CXXXXXXXXXXV',    'UDID': '0XXXXX27-XXXX-XXXX-XXXX-XZXXXXXXXXX',    'VERSION': '21C52' } Information received during DEP enroll of iPAD {    'LANGUAGE': 'en_US',    'PRODUCT': 'iPad5,4',    'SERIAL': 'DXXXXXXXXXXQ',    'UDID': '9aXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX6d',    'VERSION': '19C63' } Profile to be transmitted to the device (same as MacOS, iOS, IPadOS) {    'AccessRights': 8191,    'CheckInURL': 'https://apm.xxxxx.com/checkin',    'CheckOutWhenRemoved': True,    'IdentityCertificateUUID': '00000000-0000-0000-0000-000000000000',    'PayloadDescription': 'MDM Profile',    'PayloadDisplayName': 'MDM',    'PayloadIdentifier': 'com.xxxxx.xxxxxxx.mdm',    'PayloadOrganization': 'MDM provider',    'PayloadType': 'com.apple.mdm',    'PayloadUUID': '00000000-0000-0000-0000-000000000000',    'PayloadVersion': 1,    'PromptUserToAllowBootstrapTokenForAuthentication': True,   'ServerCapabilities': ['com.apple.mdm.per-user-connections','com.apple.mdm.bootstraptoken'],    'ServerURL': 'https://apm.xxxxx.com/server',    'SignMessage': False,    'Topic': 'com.apple.mgmt.External.206bfa63-f76a-4381-9e50-6f74241d14d9' }  Because it uses the same profile structure, it is not understood that iOS/iPadOS operates normally and errors occur only in MacOS. If there is anything that can help me, please let me know. Thank you.
3
0
1.7k
May ’24