# Xcode

version 9.2.0

The Xcode Plugin generate files that are used by the Xcode IDE to open Gradle projects into Xcode (`File` - `Open…​`). The generated Xcode project delegates build actions to Gradle.

What exactly the `xcode` plugin generates depends on which other plugins are used:

Table 1. Xcode Plugin behavior
Plugin | Description
--- | ---
None | Generates minimal solution file.
C++ Application | Adds a target representing the C++ application to the project file.
C++ Library | Adds a target for each specified linkage representing the shared and/or static library to the project file.
Swift Application | Adds a target representing the Swift application to the project file.
Swift Library | Adds a target for each specified linkage representing the shared and/or static library to the project file.
XCTest | Adds a target representing the XCTest bundle to the project file.

## Usage

Example 1. Applying the Xcode Plugin
build.gradle.kts

    plugins {
        xcode
    }

build.gradle

    plugins {
        id 'xcode'
    }

## Tasks

The Xcode Plugin adds a number of tasks to your project. The main tasks that you will use are the `xcode`, `cleanXcode` and `openXcode` tasks.

The following diagram shows the relationships between tasks added by this plugin.

Figure 1. Xcode Plugin default task graph

### Lifecycle Tasks

`xcode` — Task

  Depends on: `projectNameXcodeWorkspace` and all `xcodeProject` tasks

  Generates all Xcode configuration files.

`cleanXcode` — Delete

  Depends on: all Xcode project and workspace file clean tasks

  Removes all Xcode configuration files.

`openXcode` - Task

  Depends on: `xcode`

  Open the Xcode workspace inside the IDE.

### IDE Workspace Tasks

`xcodeWorkspaceWorkspaceSettings` - GenerateWorkspaceSettingsFileTask

  Generates the `projectName.xcworkspace` file. This task is only available on the root project.

`xcodeWorkspace` - GenerateXcodeProjectFileTask

  Depends on: `xcodeWorkspaceWorkspaceSettings`

  Generates the `projectName.xcworkspace` file. This task is only available on the root project.

### IDE Project Tasks

Both the C++ Application Plugin and C++ Library Plugin introduce the same tasks for generating Xcode projects to be included in an Xcode workspace.

`xcodeProjectWorkspaceSettings` — GenerateWorkspaceSettingsFileTask

  Generates the `projectName.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings` file.

`xcodeScheme` — GenerateSchemeFileTask

  Generates the `projectName.xcodeproj/xcshareddata/xcschemes/ProjectName.xcscheme` file.

`xcodeProject` — GenerateXcodeProjectFileTask

  Depends on: `xcodeProjectWorkspaceSettings` and `xcodeScheme` (if buildable binary present)

  Generates the `projectName.xcodeproj/project.pbxproj` file.

## Configuration

The Xcode Plugin doesn’t allows any customization of the generated files.