The following plugin is in very early development. Don’t hesitate to try it out. If you encounter any problems, please open an issue on GitHub.

The Xcode IDE Plugin generates workspace and projects that are used by the Xcode IDE to open Gradle projects into Xcode (File - Open…​). The generated Xcode project delegates build actions to Gradle. For known product types, the plugin generates additional targets to be used by the Xcode indexer. It allows features like autocomplete and cmd-click navigation to work as expected.

The plugin generates Xcode projects depending on the other plugins applied:

Table 1. Xcode IDE Plugin behaviour
Plugin Description

Objective-C iOS Application

Adds a target representing the iOS application implemented in Objective-C to a Xcode project.

C Application

Adds a tool target representing the application implemented in C to a Xcode project.

C Library

Adds a dynamic library target representing the library implemented in C to a Xcode project.

C++ Application

Adds a tool target representing the application implemented in C++ to a Xcode project.

C++ Library

Adds a dynamic library target representing the library implemented in C++ to a Xcode project.

Objective-C Application

Adds a tool target representing the application implemented in Objective-C to a Xcode project.

Objective-C Library

Adds a dynamic library target representing the library implemented in Objective-C to a Xcode project.

Objective-C++ Application

Adds a tool target representing the application implemented in Objective-C++ to a Xcode project.

Objective-C++ Library

Adds a dynamic library target representing the library implemented in Objective-C++ to a Xcode project.

Swift Application

Adds a tool target representing the application implemented in Swift to a Xcode project.

Swift Library

Adds a dynamic library target representing the library implemented in Swift to a Xcode project.

None of the above

Does not generate any project. It is possible to compose your own Xcode project(s) using the build language.

Usage

Example 1. Applying the Xcode IDE Plugin
build.gradle
plugins {
   id 'dev.nokee.xcode-ide'
}
build.gradle.kts
plugins {
   id("dev.nokee.xcode-ide")
}

Tasks

The Xcode IDE Plugin adds three new tasks to your project: xcode, cleanXcode and openXcode (root project only). The following diagram shows the relationships between the tasks:

xcode ide task graph
Figure 1. Xcode IDE Plugin task graph

Lifecycle Tasks

xcodeTask

Aggregates tasks that generate the Xcode IDE workspace and projects. In a multi-project build, only the root project will generate an Xcode IDE workspace.

cleanXcodeDelete

Removes all generated Xcode IDE workspace and projects as well as the Xcode derived data folder for the workspace.

openXcode - Task

Depends on: xcode

Open the Xcode workspace inside the IDE. Only available on the root project.

Extensions

The plugin register an extension of type XcodeIdeProjectExtension. The extensions offer the capability of registering any number of XcodeIdeProject instances, each of which generates an Xcode Project. On the root project only, the plugin will register an extended extension of the type XcodeIdeWorkspaceExtension. The extended extension offers the added capability of configuring a XcodeIdeWorkspace instance which generates an Xcode Workspace.

Gradle Project Hierarchy Extension Type

Root project

XcodeIdeWorkspaceExtension

Any other projects

XcodeIdeProjectExtension

The plugin register both types of extensions under the name xcode on the Project object. It can be configure just like any other Gradle extension:

Example 2. Configuring the Xcode IDE extensions
build.gradle
plugins {
   id 'dev.nokee.xcode-ide'
}

xcode {
    // configuration goes here
}
build.gradle.kts
plugins {
   id("dev.nokee.xcode-ide")
}

xcode {
    // configuration goes here
}

Build Language

The following summary presents the mapping of each Xcode IDE concept to the Nokee build language. The mapping is roughly one-to-one.

Xcode Target (XcodeIdeTarget)

Represent a single product to build and the instructions for building the product from a set of files. Projects can contain one or more targets, each of which produces one product.

XcodeProject (XcodeIdeProject)

Represent a repository for all the files, resources, and information required to build one or more software products. It contains all the elements used to build your products and maintains the relationships between those elements.

Xcode Build Settings (XcodeIdeBuildSettings)

Represent information about how to perform a particular aspect of the product’s build process.

Xcode Workspace (XcodeIdeWorkspace)

Represent a group of projects to be worked on together.

Xcode Build Configuration (XcodeIdeBuildConfiguration)

Represent a group of build settings to build a variant of the product.

Configuration

The Xcode IDE project automatically registered as a result of a default behaviour allows only minimal configuration, such as adding additional targets, build configuration and build settings. Any additional Xcode IDE projects added via the build language are entirely configurable within the assumption imposed by the plugin. Head over to the Developing with Xcode IDE chapter to learn more about the integration between Gradle and Xcode provided by this plugin.