Posts

Post not yet marked as solved
15 Replies
3.6k Views
I use this method to check Apple Event (Automation) permission: bool checkAuth (string : appId) { OSStatus status = noErr; if (@available(macOS 10.14, *)) { NSAppleEventDescriptor *targetAppEventDescriptor; targetAppEventDescriptor = [NSAppleEventDescriptor descriptorWithBundleIdentifier:appId.toNSString()]; status = AEDeterminePermissionToAutomateTarget(targetAppEventDescriptor.aeDesc, typeWildCard, typeWildCard, true); }return status == noErr; } The problem is that the execution freezes once in 100 times at API: AEDeterminePermissionToAutomateTarget and the user is not prompted for authorization. usage example:  checkSIPforAppIdentifier("com.microsoft.Word"); I have inserted necessary key in info.plist: <key>NSAppleEventsUsageDescription</key> <string>*** uses this feature to do do Typography actions.</string> My App is not sandboxed. PS: this issue is not consistently reproducible , once I restart the machine it works
Posted Last updated
.
Post not yet marked as solved
3 Replies
2.3k Views
I want to create shortcut of my application on desktop programatically and also add it to the docbar. At present i am doing it using bristow and emmet executables using shell script. I want to know is there any API in any of the frameworks that helps me to do using swift
Posted Last updated
.
Post not yet marked as solved
1 Replies
3.1k Views
In Mojave 10.14, I am able to reset Apple events using tccutil reset AppleEvents. In 10.14.1 it looks like they have upgraded this tool and USAGE isusage: tccutil [-h] [--list] [--insert INSERT] [-v] [-r REMOVE] [-e ENABLE] [-d DISABLE] [--version] [ACTION]But when i run below command, i am seeing errorstccutil --listTCC Database structure is unknown.Error opening Database.I added terminal in Full Disk Access, What else need to be done to get tccutil working ?
Posted Last updated
.
Post not yet marked as solved
0 Replies
281 Views
How to distribute/install outlook add-ins for Mac programatically. From Microsoft documentation we are side loading add-in manually by adding the file or URL, wanted to know if there is any other way where I can distribute my add-in without user adding it manually
Posted Last updated
.
Post not yet marked as solved
2 Replies
956 Views
I followed this documentation https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/plugin_apps_developer_guide.pdflooks like outdated. Is it possible to add adobe Reader Plugin. If yes where to start, which tool or language can be used to develop plugins.
Posted Last updated
.
Post not yet marked as solved
0 Replies
721 Views
Is there any framework in macOS to print a non pdf document. PDF kit is showing print panel that too only for PDF documents.Code snippet : let pdfView = PDFView() let path = URL(fileURLWithPath: "/Users/syamala/Desktop/Book1.pdf") let pdfDoc = PDFDocument(url: path) pdfView.document = pdfDoc let wnd = NSWindow() pdfView.autoScales = true pdfView.displaysPageBreaks = false wnd.setContentSize(pdfView.frame.size) wnd.contentView = pdfView pdfView.print(with: NSPrintInfo.shared, autoRotate: true)Shell command lp /Users/syamala/Desktop/Book1.pdf , even this prints only pdf docs but not non-pdf docs.Is there any swift native framework to print a document from local directory or shell command to print a document.
Posted Last updated
.
Post marked as solved
5 Replies
834 Views
Below are the two ways i am doing it, but wanted to know which is best way to do it and whyFirst wayTimer.scheduledTimer(withTimeInterval: 43200, repeats: true) { timer in let randomNumber = Int.random(in: 1...20) print("Number: \(randomNumber)") if randomNumber == 20 { timer.invalidate() } }second waylet date = Date().addingTimeInterval(43200) let timer = Timer(fireAt: date, interval: 0, target: self, selector: #selector(runCode), userInfo: nil, repeats: false) RunLoop.main.add(timer, forMode: .common) @objc func runCode() { print("Running code after every 5 seconds") }
Posted Last updated
.
Post not yet marked as solved
5 Replies
926 Views
I can open multiple windows using a loop. Now I want to open these windows one by one. That means when I close one window the next window will be opened, I mean till the close of the first window next window should not be opened. Using below code all windows are getting opened at a time.let selectedFiles = ["file1","file2"] for eachfile in selectedFiles { let storyBoard : NSStoryboard = NSStoryboard(name: "Main", bundle:nil) let newViewController = storyBoard.instantiateController(withIdentifier: "MainView") as? ViewController if newViewController != nil { newViewController.ParentView = self self.presentAsModalWindow(newViewController!) } }I want the second window to open only after closing first window
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
I am using below piece of code to delete a fileif FileManager.default.fileExists(atPath: Path) { do { try FileManager.default.removeItem(atPath: Path) } catch { print(error) } }Path is /Library/LaunchAgents/com.example.agent.plistI am getting below errorError Domain=NSCocoaErrorDomain Code=513 "“com.example.agent.plist” couldn’t be removed because you don’t have permission to access it." UserInfo={NSFilePath=/Library/LaunchAgents/com.example.agent.plist, NSUserStringVariant=( Remove), NSUnderlyingError=0x600000c76af0 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}}How can i delete a file with admininistrative priveleges from swift. Is there a way i can do without involving apple scripts and shell scripts using native swift?
Posted Last updated
.
Post not yet marked as solved
1 Replies
767 Views
From below description https://developer.apple.com/documentation/bundleresources/information_property_list/nsfileproviderdomainusagedescription?changes=_2_1__8The user implicitly grants your app access to a file managed by a file provider when selecting the file in an Open or Save panel, dragging it onto your app, or opening it in Finder. Your app can access that file right away and any time in the futureIn my application i select a file from open Panel and create a duplicate using CopyItem API try fileMgr.copyItem(atPath: uploadfilePath, toPath: newTempFilePath) .. I see catalina user consent coming, when i click on dont allow , i am not entering catch block and API is successful. When i checked read permissionsFileManager.default.isReadableFile(atPath: SelectedPath) , it returns true.
Posted Last updated
.
Post not yet marked as solved
1 Replies
509 Views
So when i run below code , i get Catalina User consent "Your App wants to access Documents folder"do { //return [FileAttributeKey : Any] let attr = try FileManager.default.attributesOfItem(atPath: "/Users/catalina/Documents/Test.docx") var fileSize = att r[FileAttributeKey.size] as! UInt64 //if you convert to NSDictionary, you can get file size old way as well. let dict = attr as NSDictionary fileSize = dict.fileSize() } catch { print("Error: \(error)") }Even when i click on Don't allow, still the API returns attributes and API never throws any error. How can i catch the exception here and redirect user to give permissions in System Preferences.
Posted Last updated
.
Post not yet marked as solved
0 Replies
472 Views
So when i run below code , i get Catalina User consent "Your App wants to access Documents folder"do { //return [FileAttributeKey : Any] let attr = try FileManager.default.attributesOfItem(atPath: "/Users/catalina/Documents/Test.docx") var fileSize = attr[FileAttributeKey.size] as! UInt64 //if you convert to NSDictionary, you can get file size old way as well. let dict = attr as NSDictionary fileSize = dict.fileSize() } catch { print("Error: \(error)") }Even when i click on Don't allow, still the API returns attributes and API never throws any error. How can i catch the exception here and redirect user to give permissions in System Preferences.
Posted Last updated
.
Post not yet marked as solved
0 Replies
512 Views
I see difference in .app compiled in Xcode and then Copied to applications and the one installed by creating with packages app. In Catalina I see extra user consents coming trying to access Documents. When installed I don’t see these user consents Want to understand the difference between compiled app in developer environment and the one installed
Posted Last updated
.