3.4 How to run Cocoa on its own
This section describes how you can run LispWorks as a Cocoa application, either by saving a LispWorks development image with a suitable restart function, or by delivering a LispWorks application which uses a nib file generated by Apple's Interface Builder.
3.4.1 LispWorks as a Cocoa application
The following startup function can be used to make LispWorks run as a Cocoa application. Typically, before calling
"run" you would create an application delegate with a method on
applicationDidFinishLaunching: to initialize the application's windows.
(defun init-function ()
(let ((app (objc:invoke "NSApplication"
(objc:invoke app "run"))))))
To use this, a bundle must be created, calling
init-function on startup. For example, the following build script will create
"configuration/macos-application-bundle.lisp" :load t)
(save-image (when (save-argument-real-p)
See "Saving a LispWorks image" in the
LispWorks User Guide and Reference Manual
for information on using a build script to create a new LispWorks image.
3.4.2 Using a nib file in a LispWorks application
For a complete example demonstrating how to build a standalone Cocoa application which uses a nib file, see these two files:
The area calculator example connects the nib file generated by Apple's Interface Builder to a Lisp implementation of an Objective-C class which acts as the MVC controller.
LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 15 Feb 2015