Xcode projet with auxiliary binaries
The test project of the myAlert tool can serve as a demo of how to configure an Xcode Project containing an auxiliary binary and even embedded binaries as for FullProf4Mac, Esmeralda, PkFit4Mac, etc.
Goals of the myAlert tool
The goal of the "myAlert" tool is to offer Alert dialogues to applications having no GUI such as C or Fortran command line applications, shell scripts, etc.
myAlert is an Objective C command line tool which accepts the following arguments:
-v verbose if placed in 1rst position
-t a title string
-m a message string
-i alert type: 0=Warning 1=Critical 2=Informational
-d delay in seconds of alert autoclosing (0=permanent)
-n name of an icon file to be placed in the bundle folder Contents/Resources
Command line call:
$./myAlert -t "A title" -m 'An important message!' -i 1 -d 20 -n "../Resources/myIcon.png
C Language call:
strcpy(command, "'");
strcat(command, AlertFilePath);
strcat(command, "'"); // do not move it to the end of the command!
//======= the alert's parameters ==================
strcat(command, " -t 'My Alert' -m 'My Message' -n 'icon.png'");
//=======================================
i=system(command);
Xcode project
The myAlert binary must be added to the Contents/MacOS folder of the bundle of the application that needs alerts.
The optional icon file must be in Contents/Resources
TestAlert.app
Contents
MacOS
TestAlert <-- binary calling myAlert
myAlert <-- command line tool
Resources
icon.png
We explain below how to implement myAlert in an Xcode project. so that the application can be codesigned and sandboxed.
The following is an update to Xcode 10 of this recipe:
<http://www.smallersystems.com/blog/2008/05/embedding-a-command-line-tool-within-a-cocoa-application/>
The initial test project TestAlert2 with no alerts.
The 1st step is adding to the project a new target for myAlert.
The new target and its source code "myAlert.m":
The new target is given the same ID and Info.plist as the main application.
myAlert is not yet compiled and its name is shown in red in TestAlert2/Products (left column)
Select the Scheme myAlert and build it. Its name will turn black.
When building the application's bundle Xcode must copy myAlert to the MacOS folder of TestAlert2.app:
Then myAlert must be associated with the scheme of the main application:
The a target dependecie is created between the main application and myAlert.
If SKIP_INSTALL is set to NO for myAlert, Xcode will create a "Generic Xcode archive" which cannot be signed and uploaded to Apple. In other words the target myAlert is installed by Xcode as an application while it must be kept as a normal file.
So we set SKIP_INSTALL to YES: