Post

Replies

Boosts

Views

Activity

Reply to SMAppService - How does this work?
Got it to work thanks to your tips and suggestions. Created a unit to interact with SMAppService: unit ServiceManagementAppService; {$mode objfpc}{$H+} {$modeswitch objectivec1} {$linkframework ServiceManagement} interface uses Classes, SysUtils, CocoaAll; const SMAppServiceStatusNotRegistered =0; SMAppServiceStatusEnabled =1; SMAppServiceStatusRequiresApproval =2; SMAppServiceStatusNotFound =3; SmAppServiceStatusResult : Array [0..3] of string = ('Not registered', 'Enabled', 'Requires Approval', 'Not found' ); type SMAppServiceStatus = NSInteger; type SMAppService = objcclass external (NSObject) public function registerAndReturnError(error: NSErrorPtr): objcbool; message 'registerAndReturnError:'; function unregisterAndReturnError(error: NSErrorPtr): objcbool; message 'unregisterAndReturnError:'; function status:SMAppServiceStatus; message 'status'; end; implementation end. And in my main application for some random testing: procedure TForm1.Button1Click(Sender: TObject); var appService: SMAppService; StatusReturn : SMAppServiceStatus; Registered:boolean; begin try // Create a service appService := SMAppService.new; // Get current status StatusReturn := appService.status; ShowMessage('Status: '+IntToStr(Integer(StatusReturn))+LineEnding+ SmAppServiceStatusResult[StatusReturn]); // Resgister service Registered := appService.registerAndReturnError(nil); ShowMessage('Registering result: '+BoolToStr(Registered,'Success','Failed')); // Get current status StatusReturn := appService.status; ShowMessage('Status: '+IntToStr(Integer(StatusReturn))+LineEnding+ SmAppServiceStatusResult[StatusReturn]); // Resgister service Registered := appService.unregisterAndReturnError(nil); ShowMessage('Unregistering result: '+BoolToStr(Registered,'Success','Failed')); // Get current status StatusReturn := appService.status; ShowMessage('Status: '+IntToStr(Integer(StatusReturn))+LineEnding+ SmAppServiceStatusResult[StatusReturn]); except Showmessage('fail'); end; end; Note: while testing it seemed I needed to sign the app bundle of my application I haven't tested this yet in the App Store (I know that I need to make the user make this choice) I hope this is useful to someone and feel free to correct me if I goofed up somehow. 😊 Thanks again!
Mar ’25
Reply to SMAppService - How does this work?
Thank you for the very clear and helpful assist! 😊 I may be able to convert the ObjC calls to Objective Pascal so I could call these functions directly (with some luck and patience). I assume that signing the application is a requirement when testing? If I cannot get this to work, then I'll use your suggestion - let me tinker for a bit and see what I can get to work 😊 I'll come back here if I have a working solution - as it could be useful for others. Note: The approach with helper tools seemed rather unnecessarily complicated, so it is nice to hear that I can do this straight in the main application. Things like this make it harder and harder to enjoy developing the little tools I make for fun. 😉 Thanks again for helping! It is very much appreciated.
Mar ’25
Reply to NetFSMountURLSync call fails on Apple Silicon
I looked at Swift a few times ... I think not liking XCode is not helping 😉 Cool thing about Lazarus: cross platform development works great (most of the time). OK, coming back to the real (other) issue; So I grabbed you Swift code and that worked on both Intel and Arm - as expected. Now comes the kicker, which makes me feel a little stupid, ... I ran my own code again and guess what ... it works without modification (did a full shutdown last night). I don't know what to tell you ... I either goofed up (not impossible), or the reboot helped ... Either way; I guess that solves that ... thanks Quinn! Very much appreciate you chiming in 👍🏻 Just for other non-Swift developers, add these imports to the beginning of Quinn's code. Took me a second to realize this - thanks again Quinn! 😊 import Foundation import NetFS
Topic: App & System Services SubTopic: Core OS Tags:
Dec ’22
Reply to NetFSMountURLSync call fails on Apple Silicon
Haha, that's funny - now you made me look for that T-Shirt 😜 Just kidding though. I do not dislike C ... I just liking Pascal better 😁 Thank you for replying! To answer your questions: Yes, this is an GUI app, started from Finder with double click (not a command line application). Scheme used for testing: smb Some additional testing on my end: I took the effort this morning to write a tiny dedicated test application to test the NetFSMountURLSync parameter variations. And all these variations work on the Intel Mac (macOS 12.6): URL: smb://username:password@serverip/sharename username null, password null, mount path null, kNAUIOptionNoUI enabled, kNetFSMountAtMountDirKey enabled URL: smb://serverip/sharename username set, password set, mount path null, kNAUIOptionNoUI enabled, kNetFSMountAtMountDirKey enabled URL: smb://serverip/sharename username set, password set, mount path /Users/username/mountpoint, kNAUIOptionNoUI enabled, kNetFSMountAtMountDirKey enabled URL: smb://username:password@serverip/sharename username null, password null, mount path /Users/username/mountpoint, kNAUIOptionNoUI enabled, kNetFSMountAtMountDirKey enabled I tried all of these additionally with kNetFSMountAtMountDirKey disabled (mount options null), with open_options null, with kNAUIOptionForceUI instead kNAUIOptionNoUI and the possible combinations with these as well. All of these work on both my Intel Mac's (running 12.6, 2016 MBP and 2013 MacPro). Testing this on the 16" MBP M1 Max (also running 12.6): ALL tests fail and make the application freeze, both Intel binary and ARM64 (AARCH64) binary fail all tests. Initially the GUI freezes, then promptly the beach ball appears (not entirely unexpected when using Sync instead of ASync), then the beachball even freezes frequently and the application is just "on hold" and any sign of live from the application stops (in Console) ... For each test I get an error like the ones below (the number behind gNetAuthAuthAgentPort changes with each new test). default 13:10:02.167473+0200 project1 GetNetAuthAuthAgentPort: Calling bootstrap_look_up3() for com.apple.netauth.user.auth; uid = 501, euid = 501 default 13:10:02.167576+0200 project1 GetNetAuthAuthAgentPort: gNetAuthAuthAgentPort = 51459
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’22