<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Scripting Bridge",
  "identifier" : "/documentation/ScriptingBridge/SBApplication/init(processIdentifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Scripting Bridge"
    ],
    "preciseIdentifier" : "c:objc(cs)SBApplication(im)initWithProcessIdentifier:"
  },
  "title" : "init(processIdentifier:)"
}
-->

# init(processIdentifier:)

Returns an instance of an `SBApplication` subclass that represents the
target application identified by the given process identifier.

```
init?(processIdentifier pid: pid_t)
```

## Parameters

`pid`

A BSD process ID specifying an application that is OSA-compliant.
Often you can get the process ID of a process using the
<doc://com.apple.documentation/documentation/Foundation/Process/processIdentifier>
method of `NSTask`.

## Return Value

An initialized `SBApplication` that you can use to communicate
with the target application specified by the process ID. Returns `nil` if no
such application can be found or if the application does not have a
scripting interface.

## Discussion

You should avoid using this method unless you know nothing about an external
application but its PID. In most cases, it is better to use
[`init(bundleIdentifier:)`](/documentation/ScriptingBridge/SBApplication/init(bundleIdentifier:)), which will dynamically locate
the external application’s path at runtime, or
[`init(url:)`](/documentation/ScriptingBridge/SBApplication/init(url:)-6xbe5), which is not dependent on the external
application being open at the time the method is called.

## See Also

[`+  applicationWithProcessIdentifier:`](/documentation/ScriptingBridge/SBApplication/applicationWithProcessIdentifier:)

Returns the shared instance representing a target application specified by
its process identifier.



---

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)