use (framework)

Declares a required framework for use with AppleScript/Objective-C.

NOTE: The importation of frameworks via the use statement is only supported in script libraries, not in other scripts or applets.

Syntax

use framework specifier

Placeholders

specifier
Specifier data for the resource. This may be a base name ("AppKit"), a full name ("AppKit.framework"), or a POSIX path ("/System/Library/Frameworks/AppKit.framework").

Examples

Most script libraries that use AppleScript/Objective-C, should have at least one of these two use statements:

use framework "Foundation"
use framework "AppKit"

You can also import other frameworks, such as MapKit:

use framework "MapKit"

Discussion

When you declare a required framework, AppleScript ensures the framework is loaded before running your script. To ensure that your AppleScript/Objective-C script libraries work correctly in any application, declare all needed frameworks explicitly; otherwise, there is no guarantee that a given framework will be available, and your script may encounter errors.

NOTE: The version parameter is not supported for frameworks; to check whether or not a framework supports a certain feature, use NSClassFromString or -respondsToSelector:.

TOP | CONTINUE