Posts

Post not yet marked as solved
0 Replies
63 Views
I have an executable in macOS that I m launching as a User Agent. The same executable can be launched in multiple ways like either user can directly click the exe to launch it, or user can launch it from the terminal using ./ etc. One similar way is when the user launches the exe as a User Agent(i.e daemon in user session). In this scenarios, I want to identify in my exe If my user has launched it as agent to perform certain task. I wanted to know how can I accurately determine this? I have tried figuring out If there is some unique session that agents operate in, but I could not find anything. Can someone help here? Is this even possible?
Posted Last updated
.
Post not yet marked as solved
0 Replies
42 Views
I have macOS application and I want to provide an action for it in the 'Shortcuts' app QuickAction list. I was using InApp handling to present my intent created in the intent.intentdefinition file as action in the shortcuts app and it was working. However, this action perform a very lightweight task so I intent to have the action implemented as an extension in my xcode project. According to my minimum deployment(i.e macOS 11.0) I found that 'Intents Extension' could be used. I have added the 'Intents extension' target to my main application and created an intent using the intent.intentdefinition file. However, my intent does not appear in the shortcuts app. I have verified it multiple time to ensure I am not missing anything, but still the intent is not present in the shortcuts app action. I wanted to be know, Is this even possible? cause this apple documentation only mentions about iOS and watchOS app. It also does not mention If our custom intent(created using Intents extension) in the intents extension can be exposed to the shortcuts app. For macOS 13.0+, I have used the 'AppIntents extension' and I m able to achieve the same. So, I suppose the same should be possible using the 'Intents extension'
Posted Last updated
.
Post not yet marked as solved
0 Replies
76 Views
I have added an "App Intents Extension" target to my main application in macOS. This generated the below two files: TWAppIntent.swift import AppIntents struct TWAppIntent: AppIntent { static var title: LocalizedStringResource = "TWAppIntentExtension" static var parameterSummary: some ParameterSummary { Summary("Get information on \(\.$TWType)") } //launch app on running action static var openAppWhenRun: Bool = true // we can have multiple parameter of diff types @Parameter(title: "TWType") var TWType: String func perform() async throws -> some IntentResult & ReturnsValue<String> & ProvidesDialog { return .result(value: TWType, dialog: "Logged break.") } } TWAppIntentExtension.swift import AppIntents @main struct TWAppIntentExtension: AppIntentsExtension { } I m able to build the extension target and I my intent action is available in the shortcuts app. However, on launching a shortcut with the above created intent action. I m getting the below popups: I have identified what is causing this error. Setting the openAppWhenRun to true is causing this error. I don't get this when it is set to false. This property is supposed to launch the application, but can someone help me understand why is it happening? This is only causing the error when using this property for AppIntent Extension and not for In app handling for the AppIntent. Can we not launch our application from AppIntent extension?
Posted Last updated
.
Post not yet marked as solved
1 Replies
529 Views
I m trying to create an xcode project with cpp-swift interoperability(introduced in xcode15) using cmake xcode generator. I m able to invoke cpp code in swift and vice-versa but when opening the project in xcode, the build setting for 'C++ and Objective-C Interoperability' is still set to 'C/Objective C' like in image below. I want to set it to 'C++/Objective-C++'. I m using the below cmake for this: . . add_library(cxx-support ./Sources/CxxSupport/Student1.cpp ./Sources/CxxSupport/Teacher.swift ) #include the directory to access modulemap content target_include_directories(cxx-support PUBLIC ${CMAKE_SOURCE_DIR}/Sources/CxxSupport) target_compile_options(cxx-support PUBLIC "$<$<COMPILE_LANGUAGE:Swift>:-cxx-interoperability-mode=default>" ) . . I Have also tried the below in cmake, but it didn't work. #set(SWIFT_OBJC_INTEROP_MODE "objcxx" CACHE STRING "") #target_compile_options(cxx-support PUBLIC #"SWIFT_OBJC_INTEROP_MODE=objcxx") Any help on how this can be achieved?
Posted Last updated
.
Post marked as solved
3 Replies
171 Views
I wanted to identify the shutdown event in macOS, so that If my application is running and the user performs a system shutdown then my application could be notified of the shutdown event and perform finalization. I came across NSWorkspaceWillPowerOffNotification which is exactly what I require, however, I created a sample application to observe for this notification. Is is observed that right before the system shuts down, the OS terminates my application invoking applicationWillTerminate(_:) delegate and the observer method for 'NSWorkspaceWillPowerOffNotification' is not invoked. I could perform my finalization in the applicationWillTerminate, but I wanted to know why is the observer not getting invoked. Also why is NSWorkspaceWillPowerOffNotification, even provided by apple when it invoked the termination delegate before shutdown? below is how I m adding the observer: NotificationCenter.default.addObserver(forName: NSWorkspace.willPowerOffNotification, object: nil, queue: nil, using: AppDelegate.handlePowerOffNotification) Below is my observer function, which just logs: public static func handlePowerOffNotification(_ notification: Notification) { NSLog (AppDelegate.TAG + "System will power off soon! Perform any necessary cleanup tasks.") // custom logger to log to a file TWLog.Log ("System will power off soon! Perform any necessary cleanup tasks.") }
Posted Last updated
.
Post not yet marked as solved
0 Replies
142 Views
I have a bundled application that contains a widget extension. On launching the application once the widget appears in the widget gallery, However, I have observed that If my widget extension is not sandboxed, the widget fails to show in the widget gallery. Is this expected? I am using the same xcode project and just that AppSandbox capability for the widget extension target is causing this. Can someone please explain why is this happening?
Posted Last updated
.
Post not yet marked as solved
1 Replies
157 Views
Can someone update about the current state of the Automator app in macOS. Automator seems like a valuable tool for automating tasks on macOS but in the recent years I have noticed a growing emphasis on the Shortcuts app for automation. It would be great if you could clarify the following: • Current Status of Automator: Is there any official statement regarding the continued support of the Automator app in future macOS versions? • Future of Automator: Does Apple plan to introduce new features or updates for Automator in upcoming releases? • Indifference to Shortcuts App: From what I understand both the ‘Automator’ and the ‘Shortcuts’ app are used for creating workflows/shortcuts to automate tasks. What is it that Automator app has to offer which cannot be done using the Shortcuts app? assuming the continued support for the Automator app. Can all the automator workflows not be automated using the shortcuts app? I understand that Apple is constantly innovating and introducing new tools. However, clarity regarding the future of Automator would be helpful for users like myself. In addition, as a developer I wanted to offer some actions for my application in the Automator app, so that the user can make use of it to create some workflows. But from what I found in the apple documentation here, these action are created using the ‘Automator action’ Project type template in the xcode. However, in the current version of xcode 15, this project type seems to be missing. Does it indicate that apple no longer provides support for applications to create new automator action? If not, how can I provide automator actions for my xcode application?
Posted Last updated
.
Post not yet marked as solved
0 Replies
120 Views
I have created an intent using AppIntent and this intent(TWIntent in the code below) can be seen in the shortcuts app as an action to create the shortcut. I am using AppShortcutProvider to create the shortcut so that user can directly make use of it. However, my shortcut does not appear in the shortcut app. The phrases used also do not launch the intent in the spotlight search. Below is my AppShortcutProvider file: @available(macOS 13.0, *) struct TWShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: TWIntent(), phrases: [ "Open Intent in \(.applicationName)", "Open \(.applicationName) Intent", "Open my Intent in \(.applicationName)", "Open my \(.applicationName) Intent", "Open TWIntent" ], shortTitle: "Open TWIntent", systemImageName: "rectangle.stack.fill" ) } static var shortcutTileColor: ShortcutTileColor = .lightBlue } Is there something I m missing? Also can these phrases be used for siri launch in macOS because the documentation mentions that macOS does not have siri capability? Below is my AppIntent file: import SwiftUI @available(macOS 13, *) struct TWIntent: AppIntent { static let title: LocalizedStringResource = "TWIntent" static var description = IntentDescription("try adding this sample action as your TW shortcut") //launch app on running action static var openAppWhenRun: Bool = false static var parameterSummary: some ParameterSummary { Summary("Get information on \(\.$TWType)") } @Parameter(title: "TWType", description: "The type to get information on.") var TWType: String func perform() async throws -> some IntentResult & ReturnsValue<String> & ProvidesDialog { //perform essential task here to update the application content return .result(value: TWType, dialog: "Logged a 15 minute break.\(TWType)") } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
187 Views
I have a basic Xcode project where I am adding a swift file with the below AppIntent. This causes the AppIntent action to be added in the Shortcuts app in MacOS. I wanted to know how is this AppIntent directly be able to add the Intent action in the shortcuts app. I have checked the build setting in the Xcode project but I did not find anything being generated that could have caused this. Can someone help me understand what internally happens that causes the action to be added to the shortcuts app? import AppIntents import SwiftUI @available(macOS 13, *) struct TWIntent: AppIntent { static let title: LocalizedStringResource = "TWMeditationIntent" static var description = IntentDescription("try adding this sample action as your TW shortcut") static var parameterSummary: some ParameterSummary { Summary("Get information on \(\.$TWType)") } // we can have multiple parameter of diff types @Parameter(title: "TWType", description: "The type to get information on.") var TWType: String func perform() async throws -> some IntentResult & ReturnsValue<String> & ProvidesDialog { NSLog(AppDelegate.TAG + "Inside perform() in MeditationIntent") return .result(value: TWType, dialog: "Logged a 15 minute break.\(TWType)") } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
182 Views
I have an exception handling frame for an Xcode application in macOS, which contains Cpp and Swift code. I am using the Unix signals frame for handling exceptions using sigaction. My sigaction signal handler get invoked when there is a swift or Cpp exception. However for some exceptions like SIGSEGV, the signal handler gets called repeatedly. To handle this I am using the SA_RESETHAND flag so that the handler gets invoked only once, and then the default action for the signal take over to terminate the process. This approach works well when an exception occurs due to Cpp code, however when it occurs due to Swift code, the signal handler still gets invoked repeatedly. Can someone explain why is this happening and What is the solution to this?
Posted Last updated
.
Post not yet marked as solved
3 Replies
266 Views
I wanted to perform handling for the exception in my mac and ios application, I am following this link, where it is suggested to follow either the mach exception handling or use Unix signals. I did not find many resources that could be followed to implement mach exception as suggested. Below are the few resources I could find. Can someone point to the some documentation that apple provides for this or some other helpful documentation. https://gist.github.com/rodionovd/01fff61927a665d78ecf
Posted Last updated
.
Post not yet marked as solved
1 Replies
286 Views
I am having a bundled application(.app file) and I am wanting to run this application via ssh session which does not have GUI access. Launching this application in a desktop GUI session, runs the application perfectly. However, on running it on the same machine via ssh session produces an error. Note: My application does not bring up any GUI window(it' just produces some logs on the terminal), so running it in a non-GUI environment should have worked. I get the below error when trying to launch the unix exe in the .app bundle( ./Myapp.app/Contents/MacOS/Myapp ) on the terminal. I have observed that applicationDidFinishLaunching(_:) gets called and then the below error occurs. +[NSXPCSharedListener endpointForReply:withListenerName:replyErrorCode:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted I tried running other bundled applications via ssh, but all seems to produce the same error. Can someone confirm Is running bundled application in a non GUI session not allowed by Apple. If its allowed, how can I solve this? Even running the .app file using the open command fails to launch the application, although it produces a different error which is consistent across different applications.
Posted Last updated
.
Post not yet marked as solved
0 Replies
184 Views
I have a very basic macOS bundled application with just the empty delegate methods implemented. I want to run this application as a daemon, and so I have created the below daemon property list file. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.demo.GUIDaemon.plist</string> <key>RunAtLoad</key> <true/> <key>StandardErrorPath</key> <string>/Users/vipul.g/MySystemWorkspace/stderr.log</string> <key>StandardOutPath</key> <string>/Users/vipul.g/MySystemWorkspace/stdout.log</string> <key>Program</key> <string>/Users/vipul.g/Library/Developer/Xcode/DerivedData/Build/Products/Debug/GUIDaemon.app/Contents/MacOS/GUIDaemon</string> </dict> </plist> After loading the daemon, I can see the application running in the Activity monitor, but only the below delegates can be observed getting invoked in the logs. Other delegate like didBecomeActive, willResignActive are not being invoked. Is this the expected behaviour for launching a bundled application as daemon? Also there are some additional items logged, which I m not sure If they are denoting If something went wrong. Can someone confirm what should be expected? 024-03-14 18:09:59.452 GUIDaemon[45883:5345352] inside main.swift 2024-03-14 18:09:59.454 GUIDaemon[45883:5345352] applicationWillFinishLaunching(_:) 2024-03-14 18:09:59.567 GUIDaemon[45883:5345352] TISFileInterrogator updateSystemInputSources false but old data invalid: currentCacheHeaderPtr nonNULL? 0, ->cacheFormatVersion 0, ->magicCookie 00000000, inputSourceTableCountSys 0 Keyboard Layouts: duplicate keyboard layout identifier -17410. Keyboard Layouts: keyboard layout identifier -17410 has been replaced with -28673. Keyboard Layouts: duplicate keyboard layout identifier -30769. Keyboard Layouts: keyboard layout identifier -30769 has been replaced with -28674. Keyboard Layouts: duplicate keyboard layout identifier -14934. Keyboard Layouts: keyboard layout identifier -14934 has been replaced with -28675. 2024-03-14 18:09:59.664 GUIDaemon[45883:5345352] applicationDidFinishLaunching(_:)
Posted Last updated
.
Post not yet marked as solved
0 Replies
175 Views
I have a very basic macOS bundled application with just the empty delegate methods implemented. I am wanting to launch this application as a daemon but when I am loading my daemon, it fails to run with the error: The application cannot be opened for an unexpected reason, error=Error Domain=NSCocoaErrorDomain Code=257 "The file “GUIDaemon” couldn’t be opened because you don’t have permission to view it." UserInfo={NSURL=file:///Users/vipul.g/Library/Developer/Xcode/DerivedData/Build/Products/Debug/GUIDaemon.app/, NSFilePath=/Users/vipul.g/Library/Developer/Xcode/DerivedData/Build/Products/Debug/GUIDaemon.app, NSUnderlyingError=0x600000034870 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}} Below is my daemon property list file. Can someone help what am I doing wrong here. I have made sure that my app has all the permission required. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.demo.GUIDaemonApp.plist</string> <key>RunAtLoad</key> <true/> <key>StandardErrorPath</key> <string>/Users/vipul.g/MySystemWorkspace/stderr.log</string> <key>StandardOutPath</key> <string>/Users/vipul.g/MySystemWorkspace/stdout.log</string> <key>ProgramArguments</key> <array> <string>/usr/bin/open</string> <string>/Users/vipul.g/Library/Developer/Xcode/DerivedData/Build/Products/Debug/GUIDaemon.app</string> </array> </dict> </plist>
Posted Last updated
.
Post marked as solved
2 Replies
335 Views
I have added an "App Intents Extension" target to my main application in macOS. This generated the below two files: TWAppIntent.swift import AppIntents struct TWAppIntent: AppIntent { static var title: LocalizedStringResource = "TWAppIntent" static var parameterSummary: some ParameterSummary { Summary("Get information on \(\.$TWType)") } // we can have multiple parameter of diff types @Parameter(title: "TWType") var TWType: String func perform() async throws -> some IntentResult { return .result(dialog: "Executed TWAppIntent.") } } TWAppIntentExtension.swift import AppIntents @main struct TWAppIntentExtension: AppIntentsExtension { } I m able to build the extension target and I my intent action is available in the shortcuts app. However, on launching a shortcut with the above created intent action. I m getting the below popups: From what I understand, I m getting this error because I have not added my 'TWAppIntent' to the TWAppIntentExtension.swift file which is the entry point for the extension, but I could not find any documentation around how to add it. Can someone help on how to do it or Is there something else that I m doing wrong?
Posted Last updated
.