<!--
{
  "availability" : [
    "macOS: 10.6.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSRunningApplication",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRunningApplication"
  },
  "title" : "NSRunningApplication"
}
-->

# NSRunningApplication

An object that can manipulate and provide information for a single instance of an app.

```
class NSRunningApplication
```

## Overview

Some properties of an app are fixed, such as the bundle identifier. Other properties may vary over time, such as whether the app is hidden. Properties that vary can be observed with key-value observing, in which case the description comment for the method notes this capability.

Properties that vary over time are inherently race-prone. For example, a hidden app may unhide itself at any time. To ameliorate this, properties persist until the next turn of the main run loop in a common mode. For example, if you repeatedly poll an unhidden app for its hidden property without allowing the run loop to run, it will continue to return <doc://com.apple.documentation/documentation/Swift/false>, even if the app hides, until the next turn of the run loop.

[`NSRunningApplication`](/documentation/AppKit/NSRunningApplication) is thread safe, in that its properties are returned atomically. However, it is still subject to the main run loop policy described above. If you access an instance of [`NSRunningApplication`](/documentation/AppKit/NSRunningApplication) from a background thread, be aware that its time-varying properties may change from under you as the main run loop runs (or not).

An [`NSRunningApplication`](/documentation/AppKit/NSRunningApplication) instance remains valid after the app exits. However, most properties lose their significance, and some properties may not be available on a terminated application.

To access the list of all running apps, use the  [`runningApplications`](/documentation/AppKit/NSWorkspace/runningApplications) method in [`NSWorkspace`](/documentation/AppKit/NSWorkspace).

## Topics

### Getting running application instances

[`convenience init?(processIdentifier: pid_t)`](/documentation/AppKit/NSRunningApplication/init(processIdentifier:))

Returns the running application with the given process identifier, or nil if no application has that pid.

[`class func runningApplications(withBundleIdentifier: String) -> [NSRunningApplication]`](/documentation/AppKit/NSRunningApplication/runningApplications(withBundleIdentifier:))

Returns an array of currently running applications with the specified bundle identifier.

[`class var current: NSRunningApplication`](/documentation/AppKit/NSRunningApplication/current)

Returns an `NSRunningApplication` representing this application.

### Activating applications

[`func activate(options: NSApplication.ActivationOptions) -> Bool`](/documentation/AppKit/NSRunningApplication/activate(options:))

Attempts to activate the application using the specified options.

[`func activate(from: NSRunningApplication, options: NSApplication.ActivationOptions) -> Bool`](/documentation/AppKit/NSRunningApplication/activate(from:options:))

Attempts to activate the application using the specified options.

[`var isActive: Bool`](/documentation/AppKit/NSRunningApplication/isActive)

Indicates whether the application is currently frontmost.

[`struct ActivationOptions`](/documentation/AppKit/NSApplication/ActivationOptions)

The following flags are for [`activate(options:)`](/documentation/AppKit/NSRunningApplication/activate(options:)).

[`var activationPolicy: NSApplication.ActivationPolicy`](/documentation/AppKit/NSRunningApplication/activationPolicy)

Indicates the activation policy of the application.

[`enum ActivationPolicy`](/documentation/AppKit/NSApplication/ActivationPolicy-swift.enum)

Activation policies (used by [`activationPolicy`](/documentation/AppKit/NSRunningApplication/activationPolicy)) that control whether and how an app may be activated.

### Hiding and unhiding applications

[`func hide() -> Bool`](/documentation/AppKit/NSRunningApplication/hide())

Attempts to hide or the application.

[`func unhide() -> Bool`](/documentation/AppKit/NSRunningApplication/unhide())

Attempts to unhide or the application.

[`var isHidden: Bool`](/documentation/AppKit/NSRunningApplication/isHidden)

Indicates whether the application is currently hidden.

### Application information

[`var localizedName: String?`](/documentation/AppKit/NSRunningApplication/localizedName)

Indicates the localized name of the application.

[`var icon: NSImage?`](/documentation/AppKit/NSRunningApplication/icon)

Returns the icon for the receiver’s application.

[`var bundleIdentifier: String?`](/documentation/AppKit/NSRunningApplication/bundleIdentifier)

Indicates the `CFBundleIdentifier` of the application.

[`var bundleURL: URL?`](/documentation/AppKit/NSRunningApplication/bundleURL)

Indicates the URL to the application’s bundle.

[`var executableArchitecture: Int`](/documentation/AppKit/NSRunningApplication/executableArchitecture)

Indicates the executing processor architecture for the application.

[`var executableURL: URL?`](/documentation/AppKit/NSRunningApplication/executableURL)

Indicates the URL to the application’s executable.

[`var launchDate: Date?`](/documentation/AppKit/NSRunningApplication/launchDate)

Indicates the date when the application was launched.

[`var isFinishedLaunching: Bool`](/documentation/AppKit/NSRunningApplication/isFinishedLaunching)

A Boolean value that determines whether the receiver’s process has finished launching.

[`var processIdentifier: pid_t`](/documentation/AppKit/NSRunningApplication/processIdentifier)

Indicates the process identifier (pid) of the application.

[`var ownsMenuBar: Bool`](/documentation/AppKit/NSRunningApplication/ownsMenuBar)

Returns whether the application owns the current menu bar.

### Terminating applications

[`func forceTerminate() -> Bool`](/documentation/AppKit/NSRunningApplication/forceTerminate())

Attempts to force the receiver to quit.

[`func terminate() -> Bool`](/documentation/AppKit/NSRunningApplication/terminate())

Attempts to quit the receiver normally.

[`var isTerminated: Bool`](/documentation/AppKit/NSRunningApplication/isTerminated)

Indicates that the receiver’s application has terminated.

[`class func terminateAutomaticallyTerminableApplications()`](/documentation/AppKit/NSRunningApplication/terminateAutomaticallyTerminableApplications())

Terminates invisibly running applications as if triggered by system memory pressure.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)