# apple_common

{% dynamic setvar source_file "src/main/java/com/google/devtools/build/lib/starlarkbuildapi/objc/AppleCommonApi.java" %} {% dynamic setvar version "8.3.0" %} {% dynamic setvar original_path "/rules/lib/toplevel/apple_common" %} {% include "_buttons.html" %} Functions for Starlark to access internals of the apple rule implementations.

## Members

- apple_host_system_env
- apple_toolchain
- dotted_version
- platform
- platform_type
- target_apple_env
- XcodeProperties
- XcodeVersionConfig

## apple_host_system_env

    dict apple_common.apple_host_system_env(xcode_config)

Returns a dict of environment variables that should be set for actions that need to run build tools on an Apple host system, such as the version of Xcode that should be used. The keys are variable names and the values are their corresponding values.

### Parameters

Parameter | Description
--- | ---
`xcode_config` | required A provider containing information about the Xcode configuration.

## apple_toolchain

    unknown apple_common.apple_toolchain()

Utilities for resolving items from the apple toolchain.

## dotted_version

    DottedVersion apple_common.dotted_version(version)

Creates a new DottedVersion instance.

### Parameters

Parameter | Description
--- | ---
`version` | string; required The string representation of the DottedVersion.

## platform

    struct apple_common.platform

An enum-like struct that contains the following fields corresponding to Apple platforms:

- `ios_device`
- `ios_simulator`
- `macos`
- `tvos_device`
- `tvos_simulator`
- `visionos_device`
- `visionos_simulator`
- `watchos_device`
- `watchos_simulator`

These values can be passed to methods that expect a platform, like XcodeVersionConfig.sdk_version_for_platform.

## platform_type

    struct apple_common.platform_type

An enum-like struct that contains the following fields corresponding to Apple platform types:

- `ios`
- `macos`
- `tvos`
- `visionos`
- `watchos`

These values can be passed to methods that expect a platform type, like the 'apple' configuration fragment's multi_arch_platform method.

Example:

    ctx.fragments.apple.multi_arch_platform(apple_common.platform_type.ios)

## target_apple_env

    dict apple_common.target_apple_env(xcode_config, platform)

Returns a `dict` of environment variables that should be set for actions that build targets of the given Apple platform type. For example, this dictionary contains variables that denote the platform name and SDK version with which to build. The keys are variable names and the values are their corresponding values.

### Parameters

Parameter | Description
--- | ---
`xcode_config` | required A provider containing information about the Xcode configuration.
`platform` | required The apple platform.

## XcodeProperties

    Provider apple_common.XcodeProperties

The constructor/key for the `XcodeVersionProperties` provider.

If a target propagates the `XcodeVersionProperties` provider, use this as the key with which to retrieve it. Example:

    dep = ctx.attr.deps[0]
    p = dep[apple_common.XcodeVersionProperties]

## XcodeVersionConfig

    Provider apple_common.XcodeVersionConfig

The constructor/key for the `XcodeVersionConfig` provider.