Is there an attribute like `#![windows_subsystem(windows)]` for macOS? - macos

According to this release note, there is a new #![windows_subsystem(windows)] attribute that does not display a console when running a windowed application. It works on Windows and everything is fine.
I don't know what to do to make it work for macOS too. When I launch my app on macOS, it displays a console. Is there a way to hide the console even for a Mac application?

Cargo builds Unix-style executable.
In order to not open the terminal on launch, you have to create an OSX application wrapper, a.k.a bundle. You could use cargo-bundle for this need.

Related

How to launch a Cocoa app at login with ServiceManagement

I'm build an agent app in Cocoa which needs to be launched at login.
I did exactly what TIMSCHROEDER said. It was prefect in debug mode. But, since I archived and export my app to a macOS Application, I can't launch it anymore.
I'm using Xcode 8.3 on macOS 10.12.4.
I had the same issue when I was testing launch at log in and changing the Bundle Identifier of helper app did the trick.
Try it. It will work

Why does my exported Cocoa Mac application crash (or not even open) upon launch?

Using Xcode Version 7.2 on my OS X 10.10.5.
I have a Cocoa application written in Objective-C that utilizes Google's CorePlot library. When I run the app (Product --> Run), it runs perfectly fine.
However, when I archive the project (Product --> Archive --> Export --> Export as a Mac Application), and then run the created '.app' by double-clicking it, the app crashes right away without even loading.
There's no reason for it to crash; the archive was done successfully, and the first window/ViewController don't try to access saved variables that would not be present on a first run.
Basically, double-clicking the app doesn't even open the app icon in the dock or show a window being created - it's like the app won't even open.
This same crash/no loading happens when I try to open/install the app using any of the options under "Export"
It turns out this issue can occur if your app has trouble importing or finding certain classes/files.
In my case, for some reason, when I opened my project and ran the app, it would find CorePlot's CorePlot.h file. However, when I archived the app and exported it to be used on other people's computers, it would not archive and export 'CorePlot.h'.
As a result, my app would crash right away as it could not find 'CorePlot.h'.

What is the difference between launching a Mac OS X app via the Finder/open and executing the app binary directly?

I'm experiencing an issue with a Qt app on Mac OS X 10.10.5, whereby a QFileDialog will not close properly when canceled. While this may be a bug in Qt, I only see this bug when running the app as a normal user would, e.g. opening it in the Finder (or via command line open). If I launch the app via Xcode or by calling the binary directly, there is no issue.
Launch the app via calling the binary directly on the command line or within Xcode, e.g. ./MyApp.app/Contents/MacOS/MyApp
Launch the app via the Finder or open, e.g. open ./MyApp.app
What are the differences between these two methods - and how does it impact a running application?
The major difference is the working folder. You don't have any control over what it is, but it will be different between the two invocations.
What directory are you showing the QFileDialog in? You should probably start in a well-defined place, like the user's home.

How to tell finder that my application is installed?

I am working on a cocoa application. I see a strange behaviour on Mac OS 10.6.8..!
My Cocoa application has an Automator action inside it. I want it to be listed in Automator as soon as I install it.
The conditions are as follows:
1. After installation, user should not go to the installed path.
2. User should not launch the application.
I mean, I am seeing this bug only for above mentioned situations. If I go to the installed folder, or launch the application, the automator app gets listed.
I didn't see this defect on Mac OS 10.7.5 or Mac OS 10.8.2..
Also I tried touch command via terminal just in case thinking that if any kind of Access updating is required and all. But that wasn't the case.
Any suggestions? Can I run any kind or Shell/Applescript while installing [After installation of the application] so that I can list the automator action in automator?
Any advice or help would be great!!
You can have a .txt file with the below script and then you have to add postflight script when taking .pkg file in Package Maker.
open "/Applications/yourAppName.app"
Try this Terminal command.
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister .../Whatever.app
You shouldn't hard-code the path, though, as users sometimes stick apps in weird locations (citation: I do it :).

Why does my Firemonkey app open a terminal window on OSX but not on Win32?

I created a simple testbed app in Delphi XE2, and compiled both a Win32 and OSX version of the application.
I zipped up the OSX version, along with a copy of the libcgunwind dylib runtime file and copied this files to a Mac i have access to.
When I unzipped the file, the mac recognized my OSX application and I double clicked it.
This, in turn, opened up a terminal window for some unknown reason along with my simple app's form.
The application itself ran and behaved just fine, but I'm curious why a terminal window would open up on the Mac?
There is a free tool available for Delphi XE2 that will create the OSX deployment app bundle for you, from Windows, without the need for PAServer.
http://enesce.com/delphiosx_bundler
Check the readme for instructions.
IIRC this happens if you execute the binary directly instead via a bundle
Lazarus/FPC apps had the same problem. IIRC the directly executed binary also didn't get events under those circumstances, but those apps were Carbon based. That problem also went away when running via a bundle setup (which is pretty much a manifest, a few dirs and a symlink)
Your application needs to be run from the application bundle. If you run it directly, you'll get the side effect of seeing the terminal window with the command line that is running the application.
You'll want to read more about Application Bundles.
If you're using PAServer, after you run the program for the first time on the Mac, look in the following folder on the Mac for the application bundle:
/Users/[username]/Applications/Embarcadero/PAServer/scratch-dir/[profilename]
If your project is named Project1, you'll see an application bundle in that folder named Project1.
If you read the above wiki article, you'll know that Project1 has a "hidden" extension of .app, and the whole thing is really a folder with all of the required files to run the application.
To the Mac OS user, the application bundle appears as a single program file, complete with an icon. The user can double-click the application bundle to run the application, drag it to their dock, etc.
The application bundle will have the Delphi icon by default, but you can replace it with your own icon. On the Mac, simply right-click on the application bundle in Finder, and select Show Package Contents. In there, look in the Contents/Resources folder for the .icns file.
Use the Icon Composer application that was installed with XCode to create your .icns icon file from existing image files.
Peek around inside at the rest of the contents. You'll see the required dylib, your program file, and the Info.plist file, which is a text file with things like application IDs, signatures, and other important things.

Resources