Create custom right-click menu for OS X app, developed on Linux - macos

I am creating an app for Mac OS, but it is being built on Linux. Because of this, I am not able to use tools such as Xcode, and I am not developing in swift. Rather, the .app directory is being put together according to Apple's documentation, and the entrypoint/executable of my app is a shell script.
I need to customize the menu which appears when you right click on the app (either on the dock icon or in Finder). Is there a way to do this, without using cocoa, etc.?

The menu I believe you are referring to is called "Services".
In order to add a menu item there for your application you would create a script to enable including it there. Xcode isn't needed or required, however, you'll need to know at the very least some basic AppleScript or Javascript to accomplish what you want. (see examples from the link)
↳ Mac Automation Scripting Guide

Related

How to run Swift Terminal app on another Mac

This is my first Swift app. Most of my coding experience is in C++ and C#, but I’m fairly new at programming.
I made a Terminal app, called PhotoSorter, using Swift. After building it, I pulled the executable out of the product folder in Xcode and ran it. It works great on my own laptop, but when I try to run the executable on another Mac, I get the following error:
“The alias ‘PhotoSorter’ can’t be opened because the original item can’t be found.”
Question: How are you supposed to create a Swift executable in Xcode that can be ran on any other Mac? Ideally, I want something that the end-user can just right-click/double-click to open.
Looking at your question again, I see you're using Xcode. In that case, the best way to distribute your program is to choose "Archive" from the "Product" menu, and when your app is done building, click the "Distribute App" button in the window that appears. Then you can choose your code signature and create a code-signed version of your app (or distribute via the App Store if you're into that sort of thing).
The immediate answer to your question, though, is that you're making an alias instead of copying the file. I assume you've used the mouse to drag and drop out of Xcode's "Products" pseudo-folder. The default action when you do that is to make an alias (which is like a shortcut on Windows). You can override that by holding down the Option key while you drag, but it's better to go the Archive route.

RCP application menus in Mac OS

I am struggling to figure out how RCP applications on Mac OS work with "About" and "Preferences" actions. I create them with ActionFactory and place them to relevant file menus. Works fine everywhere. However, on Mac OS those actions get placed into application menu by something which knows better where to put other peoples good actions. But of course they don't work.. Any idea why?
(eclipse target platform 3.7, OSX - the latest El Capitan)
For the 3.x style action bar advisor add the menu item in the normal place but use an ActionContributionItem and set the menu item in be invisible on the Mac:
So for Quit something like:
IWorkbenchAction quitAction = ActionFactory.QUIT.create(window);
register(quitAction);
ActionContributionItem quitItem = new ActionContributionItem(quitAction);
quitItem.setVisible(!Util.isMac());
menu.add(quitItem);
'About' and 'Preferences' can also be specified like this.
Util is org.eclipse.jface.util.Util.
Eclipse will find these items and move them to the correct place.

Deploy a Swift OS X app locally?

I am not new to programming, but I am new to Swift. I have developed a small app that I have no intention of distributing, I just want to use it for myself. Everything works just as desired in XCode and now I want to deploy that app locally. How can I run my app on my machine without needing to have XCode also running? I just want to see my app in my Applications folder and run it when I want. Does XCode put build files somewhere that I can access them and use outside of XCode?
On the Product menu there is an Archive option. Select that to create an archive of your app.
Xcode should then automatically open the Organiser window with the archive of your app selected.
You'll see a big blue button called Upload to App Store on the right with two smaller buttons below it. The one you want is called Export... Press it and you'll get a pane giving you various export options with different kinds of signing.
The bottom option creates an unsigned .app file which you can put in your Applications directory.
NB As Eric D says, you can just drag the app out of the products directory, but unless you edit the scheme, that will give you a debug build with less optimisation and with asserts activated.
Update for Xcode 11.2
As Bell B. Cooper points out, the process has changed slightly. Now when you archive an app, you get a window listing the apps and a big blue "Distribute" button. Pressing this, gets you a dialog box giving you the various options. Which one you choose depends on what you want to do with the executable. With Catalina, unless it's just for your own use, you probably want to go for one of the options that involves signing the app.
Edit: while this answer still works, it targets old Xcode versions and uses the debug version of your executable. For recent Xcode versions, and for using the release version of your executable, see JeremyP's answer.
Each time you build an OS X application with the current scheme, Xcode automatically populates the "Products" folder with the related app bundle.
You can find this folder in the Project Navigator:
Xcode > Project Navigator > "Products" folder
Your .app is in there and ready to be used and/or copied to the /Applications folder.

Creating feature in mac app to override the users security setting

I'm a newbie at mac osx development. I would like to know if there's any way to override the mac desktop security settings to allow an application - which is not registered in the Mac App Store, to be installed?
The setting should come from the app that I'm trying to install. That means, whenever I install the app to any mac computer, regardless of its security settings as the following,
Allow applications downloaded from:
Mac App Store
Mac App Store and identified developers
Anywhere
The app should set the settings to Anywhere, allowing it to be installed.
Any help would be very much appreciated.
Launch System Preferences from the Apple menu.
Choose “Security & Privacy” and then click the “General” tab, followed by clicking the lock icon in the corner to unlock the settings.
Look for “Allow applications downloaded from:” and choose “Anywhere”.
Accept the security warning and allow.
Note that you should be careful and aware that now the job of protecting the system from malicious apps belongs to you instead of the OS.
Right click the (app) icon and click 'open' in contextual menu - no need to disable the OS security.
This is not possible. The existence of that setting is intended to protect users from malicious executables. If there were a way for any arbitrary executable to override that setting, what protection would it offer? Malicious executables would simply change the setting to "Anywhere" like you suggest, bypassing the security features of Mac OS X.
You need to sign your application using a Mac Developer certificate, which you can obtain from Apple. That will mark your app as built by an "identified developer" and it will launch just fine without changing any settings.
Control Click the app icon to override this security feature. This is a one off, you don't have to change your settings, you can do it per-app.
There is one other way...
All you have to do to do it manually is to open up Terminal, cd into the .app application, cd into the Contents folder, then cd into the MacOS folder, then type ./YourAppNameHere and execute by typing Enter.

how to add item in right click context menu of file and folder in objective c

I am developing an cocoa application for Mac and what i need is to add an item in the context menu that appears when user right-clicks on specific file and folder (i.e. when user click on file or folder by pressing ctrl key of keyboard).
I am new to Cocoa application development. I have searched in google for it and found that it can be implemented by using CFPlugIn. Does anyone know how to use CFPlugIn to implement this or any other method to add item in context menu of specific file or folder??
Thanks in advance
You can use system services for contextual menu. you should refer Services Implementation Guide. take a look at Services step out in Snow Leopard article.
If you wish to sell your product on apple app store than you should not follow dropbox.
This is no longer supported in Mac OS X 10.6 and Mac OS X 10.7. Earlier versions of Mac OS X had support for contextual menu plugins, but this feature has since been removed.
What is it you're trying to accomplish in the broader sense? If you give us an idea of what your goal is, we may be able to suggest an alternate way to accomplish it.
Using System Extensions and a FinderSync extension you can accomplish this.
https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Finder.html

Resources