---
title: 'Apple Apps and Bazel'
---

This page contains resources that help you use Bazel to build macOS and iOS
projects. It links to a tutorial, build rules, and other information specific to
using Bazel to build and test for those platforms.

## Working with Bazel {:#working-with-bazel}

The following resources will help you work with Bazel on macOS and iOS projects:

*  [Tutorial: Building an iOS app](/versions/6.1.0/tutorials/ios-app)
*  [Objective-C build rules](/versions/6.1.0/reference/be/objective-c)
*  [General Apple rules](https://github.com/bazelbuild/rules_apple){: .external}
*  [Integration with Xcode](/versions/6.1.0/install/ide)

## Migrating to Bazel {:#migrating-to-bazel}

If you currently build your macOS and iOS projects with Xcode, follow the steps
in the migration guide to start building them with Bazel:

*  [Migrating from Xcode to Bazel](/versions/6.1.0/migrate/xcode)

## Apple apps and new rules {:#apple-apps-new-rules}

**Note**: Creating new rules is for advanced build and test scenarios.
You do not need it when getting started with Bazel.

The following modules, configuration fragments, and providers will help you
[extend Bazel's capabilities](/versions/6.1.0/rules/concepts)
when building your macOS and iOS projects:

*  Modules:

   *  [`apple_bitcode_mode`](/versions/6.1.0/rules/lib/apple_bitcode_mode)
   *  [`apple_common`](/versions/6.1.0/rules/lib/apple_common)
   *  [`apple_platform`](/versions/6.1.0/rules/lib/apple_platform)
   *  [`apple_platform_type`](/versions/6.1.0/rules/lib/apple_platform_type)
   *  [`apple_toolchain`](/versions/6.1.0/rules/lib/apple_toolchain)
   *  [`XcodeVersionConfig`](/versions/6.1.0/rules/lib/XcodeVersionConfig)

*  Configuration fragments:

   *  [`apple`](/versions/6.1.0/rules/lib/apple)

*  Providers:

   *  [`ObjcProvider`](/versions/6.1.0/rules/lib/ObjcProvider)

## Xcode selection {:#xcode-selection}

If your build requires Xcode, Bazel will select an appropriate version based on
the `--xcode_config` and `--xcode_version` flags. The `--xcode_config` consumes
the set of available Xcode versions and sets a default version if
`--xcode_version` is not passed. This default is overridden by the
`--xcode_version` flag, as long as it is set to an Xcode version that is
represented in the `--xcode_config` target.

If you do not pass `--xcode_config`, Bazel will use the autogenerated
[`XcodeVersionConfig`](/versions/6.1.0/rules/lib/XcodeVersionConfig) that represents the
Xcode versions available on your host machine. The default version is
the newest available Xcode version. This is appropriate for local execution.

If you are performing remote builds, you should set `--xcode_config` to an
[`xcode_config`](/versions/6.1.0/reference/be/objective-c#xcode_config)
target whose `versions` attribute is a list of remotely available
[`xcode_version`](/versions/6.1.0/reference/be/objective-c#xcode_version)
targets, and whose `default` attribute is one of these
[`xcode_versions`](/versions/6.1.0/reference/be/objective-c#xcode_version).

If you are using dynamic execution, you should set `--xcode_config` to an
[`xcode_config`](/versions/6.1.0/reference/be/objective-c#xcode_config)
target whose `remote_versions` attribute is an
[`available_xcodes`](/versions/6.1.0/reference/be/workspace#available_xcodes)
target containing the remotely available Xcode versions, and whose
`local_versions` attribute is an
[`available_xcodes`](/versions/6.1.0/reference/be/workspace#available_xcodes)
target containing the locally available Xcode versions. For `local_versions`,
you probably want to use the autogenerated
`@local_config_xcode//:host_available_xcodes`. The default Xcode version is the
newest mutually available version, if there is one, otherwise the default of the
`local_versions` target. If you prefer to use the `local_versions` default
as the default, you can pass `--experimental_prefer_mutual_default=false`.
