# README


## Just The Scripts

Xcode utilities to generate scripting definition and Objective-C header:

```
sdef "/Applications/Microsoft PowerPoint.app" > PowerPointScripting.sdef
sdp -fh --basename "PPT" PowerPointScripting.sdef
```

[SwiftScripting](https://github.com/tingraldi/SwiftScripting) scripts to generate Swift API:

```
/path/to/sbhc.py PPT.h
/path/to/sbsc.py PowerPointScripting.sdef
```


## Getting Set Up

To create Swift APIs for AppleScript, you'll need to download [SwiftScripting](https://github.com/tingraldi/SwiftScripting) from GitHub. Download the ZIP and extract it, or clone with git.

You'll also need to install Python bindings for libclang by running the following command in the terminal:

```
pip install clang==3.5
```

If you haven't done so already, install the Xcode command line tools by running the following command in the terminal:

```
xcode-select --install
```


## Generating AppleScript Interfaces for Objective-C
By default, Xcode ships with utilities to create scripting bridges for Objective-C. To create an Objective-C header for use with AppleScript, you will need to...

#### 1. Create a scripting definition from PowerPoint
```
sdef "/Applications/Microsoft PowerPoint.app" > PowerPointScriptingDefinition.sdef
```

`PowerPointScriptingDefinition.sdef` contains a scripting definition from `Microsoft PowerPoint.app`.

#### 2. Create an Objective-C header:
```
sdp -fh --basename "PPT" PowerPointScriptingDefinition.sdef
```

In the above command:

* basename: The prefix to use in the generated code. Shorter is preferable (i.e. "PPT" instead of "PowerPoint"). When generating a header for a specific version of the application, add the version to the basename (i.e. "PPT_v16").


### Converting The Objective-C Header to a Swift API

#### 3. Generating a Swift API
`sbhc.py` is contained in the SwiftScripting project. Run it using the following command:

```
/path/to/sbhc.py PPT.h
```

Where `PPT.h` is the name of the pregenerated header file from step 2.


You will also need to run `sbsc.py` (found in the same directory) to generate a Swift `enum` appropriate for the newly generated Swift API.

```
/path/to/sbsc.py PowerPointScriptingDefinition.sdef
```

Where `PowerPointScriptingDefinition.sdef` is the name of the scripting definition generated from step 1.
