docs/versions/6.2.0/reference/be/objective-c.mdx
</td>
</tr>
<tr>
<td id="j2objc_library.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
A list of <code>j2objc_library</code>, <code>java_library</code>,
<code>java_import</code> and <code>java_proto_library</code> targets that contain
Java files to be transpiled to Objective-C.
<p>All <code>java_library</code> and <code>java_import</code> targets that can be reached
transitively through <code>exports</code>, <code>deps</code> and <code>runtime_deps</code>
will be translated and compiled. Currently there is no support for files generated by Java
annotation processing or <code>java_import</code> targets with no <code>srcjar</code>
specified.
</p>
<p>The J2ObjC translation works differently depending on the type of source Java source
files included in the transitive closure. For each .java source files included in
<code>srcs</code> of <code>java_library</code>, a corresponding .h and .m source file
will be generated. For each source jar included in <code>srcs</code> of
<code>java_library</code> or <code>srcjar</code> of <code>java_import</code>, a
corresponding .h and .m source file will be generated with all the code for that jar.
</p>
<p>Users can import the J2ObjC-generated header files in their code. The import paths for
these files are the root-relative path of the original Java artifacts. For example,
<code>//some/package/foo.java</code> has an import path of <code>some/package/foo.h</code>
and <code>//some/package/bar.srcjar</code> has <code>some/package/bar.h</code
</p>
<p>
If proto_library rules are in the transitive closure of this rule, J2ObjC protos will also
be generated, compiled and linked-in at the binary level. For proto
<code>//some/proto/foo.proto</code>, users can reference the generated code using import
path <code>some/proto/foo.j2objc.pb.h</code>.
</p>
</td>
</tr>
<tr>
<td id="j2objc_library.entry_classes">
<code>entry_classes</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
The list of Java classes whose translated ObjC counterparts will be referenced directly
by user ObjC code. This attribute is required if flag <code>--j2objc_dead_code_removal
</code> is on. The Java classes should be specified in their canonical names as defined by
<a href="http://docs.oracle.com/javase/specs/jls/se8/html/jls-6.html#jls-6.7">the Java
Language Specification.</a>
When flag <code>--j2objc_dead_code_removal</code> is specified, the list of entry classes
will be collected transitively and used as entry points to perform dead code analysis.
Unused classes will then be removed from the final ObjC app bundle.
</td>
</tr>
<tr>
<td id="j2objc_library.jre_deps">
<code>jre_deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of additional JRE emulation libraries required by all Java code translated by this
<code>j2objc_library</code> rule. Only core JRE functionality is linked by default.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="objc_import.hdrs">
<code>hdrs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of C, C++, Objective-C, and Objective-C++ header files published
by this library to be included by sources in dependent rules.
<p>
These headers describe the public interface for the library and will be
made available for inclusion by sources in this rule or in dependent
rules. Headers not meant to be included by a client of this library
should be listed in the srcs attribute instead.
<p>
These will be compiled separately from the source if modules are enabled.
</td>
</tr>
<tr>
<td id="objc_import.alwayslink">
<code>alwayslink</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
If 1, any bundle or binary that depends (directly or indirectly) on this
library will link in all the object files for the files listed in
<code>srcs</code> and <code>non_arc_srcs</code>, even if some contain no
symbols referenced by the binary.
This is useful if your code isn't explicitly called by code in
the binary, e.g., if your code registers to receive some callback
provided by some service.
</td>
</tr>
<tr>
<td id="objc_import.archives">
<code>archives</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; required</code></p>
The list of <code>.a</code> files provided to Objective-C targets that
depend on this target.
</td>
</tr>
<tr>
<td id="objc_import.includes">
<code>includes</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
List of <code>#include/#import</code> search paths to add to this target
and all depending targets.
This is to support third party and open-sourced libraries that do not
specify the entire workspace path in their
<code>#import/#include</code> statements.
<p>
The paths are interpreted relative to the package directory, and the
genfiles and bin roots (e.g. <code>blaze-genfiles/pkg/includedir</code>
and <code>blaze-out/pkg/includedir</code>) are included in addition to the
actual client root.
<p>
Unlike <a href="/versions/6.2.0/reference/be/objective-c.html#objc_library.copts">COPTS</a>, these flags are added for this rule
and every rule that depends on it. (Note: not the rules it depends upon!) Be
very careful, since this may have far-reaching effects. When in doubt, add
"-iquote" flags to <a href="/versions/6.2.0/reference/be/objective-c.html#objc_library.copts">COPTS</a> instead.
</td>
</tr>
<tr>
<td id="objc_import.sdk_dylibs">
<code>sdk_dylibs</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Names of SDK .dylib libraries to link with. For instance, "libz" or
"libarchive".
"libc++" is included automatically if the binary has any C++ or
Objective-C++ sources in its dependency tree. When linking a binary,
all libraries named in that binary's transitive dependency graph are
used.
</td>
</tr>
<tr>
<td id="objc_import.sdk_frameworks">
<code>sdk_frameworks</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Names of SDK frameworks to link with (e.g. "AddressBook", "QuartzCore"). "UIKit" and
"Foundation" are always included when building for the iOS, tvOS and watchOS platforms.
For macOS, only "Foundation" is always included.
<p> When linking a top level Apple binary, all SDK frameworks listed in that binary's
transitive dependency graph are linked.
</td>
</tr>
<tr>
<td id="objc_import.sdk_includes">
<code>sdk_includes</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
List of <code>#include/#import</code> search paths to add to this target
and all depending targets, where each path is relative to
<code>$(SDKROOT)/usr/include</code>.
</td>
</tr>
<tr>
<td id="objc_import.textual_hdrs">
<code>textual_hdrs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of C, C++, Objective-C, and Objective-C++ files that are
included as headers by source files in this rule or by users of this
library. Unlike hdrs, these will not be compiled separately from the
sources.
</td>
</tr>
<tr>
<td id="objc_import.weak_sdk_frameworks">
<code>weak_sdk_frameworks</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Names of SDK frameworks to weakly link with. For instance,
"MediaAccessibility".
In difference to regularly linked SDK frameworks, symbols
from weakly linked frameworks do not cause an error if they
are not present at runtime.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="objc_library.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of targets that are linked together to form the final bundle.
</td>
</tr>
<tr>
<td id="objc_library.srcs">
<code>srcs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of C, C++, Objective-C, and Objective-C++ source and header
files, and/or (`.s`, `.S`, or `.asm`) assembly source files, that are processed to create
the library target.
These are your checked-in files, plus any generated files.
Source files are compiled into .o files with Clang. Header files
may be included/imported by any source or header in the srcs attribute
of this target, but not by headers in hdrs or any targets that depend
on this rule.
Additionally, precompiled .o files may be given as srcs. Be careful to
ensure consistency in the architecture of provided .o files and that of the
build to avoid missing symbol linker errors.
</td>
</tr>
<tr>
<td id="objc_library.hdrs">
<code>hdrs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of C, C++, Objective-C, and Objective-C++ header files published
by this library to be included by sources in dependent rules.
<p>
These headers describe the public interface for the library and will be
made available for inclusion by sources in this rule or in dependent
rules. Headers not meant to be included by a client of this library
should be listed in the srcs attribute instead.
<p>
These will be compiled separately from the source if modules are enabled.
</td>
</tr>
<tr>
<td id="objc_library.alwayslink">
<code>alwayslink</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
If 1, any bundle or binary that depends (directly or indirectly) on this
library will link in all the object files for the files listed in
<code>srcs</code> and <code>non_arc_srcs</code>, even if some contain no
symbols referenced by the binary.
This is useful if your code isn't explicitly called by code in
the binary, e.g., if your code registers to receive some callback
provided by some service.
</td>
</tr>
<tr>
<td id="objc_library.copts">
<code>copts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Extra flags to pass to the compiler.
Subject to <a href="/versions/6.2.0/reference/be/make-variables">"Make variable"</a> substitution and
<a href="/versions/6.2.0/reference/be/common-definitions#sh-tokenization">Bourne shell tokenization</a>.
These flags will only apply to this target, and not those upon which
it depends, or those which depend on it.
<p>
Note that for the generated Xcode project, directory paths specified using "-I" flags in
copts are parsed out, prepended with "$(WORKSPACE_ROOT)/" if they are relative paths, and
added to the header search paths for the associated Xcode target.
</td>
</tr>
<tr>
<td id="objc_library.defines">
<code>defines</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Extra <code>-D</code> flags to pass to the compiler. They should be in
the form <code>KEY=VALUE</code> or simply <code>KEY</code> and are
passed not only to the compiler for this target (as <code>copts</code>
are) but also to all <code>objc_</code> dependers of this target.
Subject to <a href="/versions/6.2.0/reference/be/make-variables">"Make variable"</a> substitution and
<a href="/versions/6.2.0/reference/be/common-definitions#sh-tokenization">Bourne shell tokenization</a>.
</td>
</tr>
<tr>
<td id="objc_library.enable_modules">
<code>enable_modules</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
Enables clang module support (via -fmodules).
Setting this to 1 will allow you to @import system headers and other targets:
@import UIKit;
@import path_to_package_target;
</td>
</tr>
<tr>
<td id="objc_library.includes">
<code>includes</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
List of <code>#include/#import</code> search paths to add to this target
and all depending targets.
This is to support third party and open-sourced libraries that do not
specify the entire workspace path in their
<code>#import/#include</code> statements.
<p>
The paths are interpreted relative to the package directory, and the
genfiles and bin roots (e.g. <code>blaze-genfiles/pkg/includedir</code>
and <code>blaze-out/pkg/includedir</code>) are included in addition to the
actual client root.
<p>
Unlike <a href="/versions/6.2.0/reference/be/objective-c.html#objc_library.copts">COPTS</a>, these flags are added for this rule
and every rule that depends on it. (Note: not the rules it depends upon!) Be
very careful, since this may have far-reaching effects. When in doubt, add
"-iquote" flags to <a href="/versions/6.2.0/reference/be/objective-c.html#objc_library.copts">COPTS</a> instead.
</td>
</tr>
<tr>
<td id="objc_library.linkopts">
<code>linkopts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Extra flags to pass to the linker.
</td>
</tr>
<tr>
<td id="objc_library.module_map">
<code>module_map</code>
</td>
<td>
<p><code><a href="/versions/6.2.0/concepts/labels">Label</a>; optional</code></p>
A custom Clang module map for this target. Use of a custom module map is discouraged. Most
users should use module maps generated by Bazel.
If specified, Bazel will not generate a module map for this target, but will pass the
provided module map to the compiler.
</td>
</tr>
<tr>
<td id="objc_library.module_name">
<code>module_name</code>
</td>
<td>
<p><code>String; optional</code></p>
Sets the module name for this target. By default the module name is the target path with
all special symbols replaced by _, e.g. //foo/baz:bar can be imported as foo_baz_bar.
</td>
</tr>
<tr>
<td id="objc_library.non_arc_srcs">
<code>non_arc_srcs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of Objective-C files that are processed to create the
library target that DO NOT use ARC.
The files in this attribute are treated very similar to those in the
srcs attribute, but are compiled without ARC enabled.
</td>
</tr>
<tr>
<td id="objc_library.pch">
<code>pch</code>
</td>
<td>
<p><code><a href="/versions/6.2.0/concepts/labels">Label</a>; optional</code></p>
Header file to prepend to every source file being compiled (both arc
and non-arc).
Use of pch files is actively discouraged in BUILD files, and this should be
considered deprecated. Since pch files are not actually precompiled this is not
a build-speed enhancement, and instead is just a global dependency. From a build
efficiency point of view you are actually better including what you need directly
in your sources where you need it.
</td>
</tr>
<tr>
<td id="objc_library.runtime_deps">
<code>runtime_deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of framework targets that are late loaded at runtime. They are included in the
app bundle but not linked against at build time.
</td>
</tr>
<tr>
<td id="objc_library.sdk_dylibs">
<code>sdk_dylibs</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Names of SDK .dylib libraries to link with. For instance, "libz" or
"libarchive".
"libc++" is included automatically if the binary has any C++ or
Objective-C++ sources in its dependency tree. When linking a binary,
all libraries named in that binary's transitive dependency graph are
used.
</td>
</tr>
<tr>
<td id="objc_library.sdk_frameworks">
<code>sdk_frameworks</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Names of SDK frameworks to link with (e.g. "AddressBook", "QuartzCore"). "UIKit" and
"Foundation" are always included when building for the iOS, tvOS and watchOS platforms.
For macOS, only "Foundation" is always included.
<p> When linking a top level Apple binary, all SDK frameworks listed in that binary's
transitive dependency graph are linked.
</td>
</tr>
<tr>
<td id="objc_library.sdk_includes">
<code>sdk_includes</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
List of <code>#include/#import</code> search paths to add to this target
and all depending targets, where each path is relative to
<code>$(SDKROOT)/usr/include</code>.
</td>
</tr>
<tr>
<td id="objc_library.textual_hdrs">
<code>textual_hdrs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional</code></p>
The list of C, C++, Objective-C, and Objective-C++ files that are
included as headers by source files in this rule or by users of this
library. Unlike hdrs, these will not be compiled separately from the
sources.
</td>
</tr>
<tr>
<td id="objc_library.weak_sdk_frameworks">
<code>weak_sdk_frameworks</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Names of SDK frameworks to weakly link with. For instance,
"MediaAccessibility".
In difference to regularly linked SDK frameworks, symbols
from weakly linked frameworks do not cause an error if they
are not present at runtime.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="available_xcodes.default">
<code>default</code>
</td>
<td>
<p><code><a href="/versions/6.2.0/concepts/labels">Label</a>; required; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The default xcode version for this platform.
</td>
</tr>
<tr>
<td id="available_xcodes.versions">
<code>versions</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The xcode versions that are available on this platform.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="xcode_config.default">
<code>default</code>
</td>
<td>
<p><code><a href="/versions/6.2.0/concepts/labels">Label</a>; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The default official version of xcode to use.
The version specified by the provided <code>xcode_version</code> target is to be used if
no <code>xcode_version</code> build flag is specified. This is required if any
<code>versions</code> are set. This may not be set if <code>remote_versions</code> or
<code>local_versions</code> is set.
</td>
</tr>
<tr>
<td id="xcode_config.local_versions">
<code>local_versions</code>
</td>
<td>
<p><code><a href="/versions/6.2.0/concepts/labels">Label</a>; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The <code>xcode_version<code> targets that are available locally.
These are used along with <code>local_versions</code> to select a mutually available
version. This may not be set if <code>versions</code> is set.
</td>
</tr>
<tr>
<td id="xcode_config.remote_versions">
<code>remote_versions</code>
</td>
<td>
<p><code><a href="/versions/6.2.0/concepts/labels">Label</a>; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The <code>xcode_version<code> targets that are available remotely.
These are used along with <code>remote_versions</code> to select a mutually available
version. This may not be set if <code>versions</code> is set.
</td>
</tr>
<tr>
<td id="xcode_config.versions">
<code>versions</code>
</td>
<td>
<p><code>List of <a href="/versions/6.2.0/concepts/labels">labels</a>; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
Accepted <code>xcode_version<code> targets that may be used.
If the value of the <code>xcode_version</code> build flag matches one of the aliases
or version number of any of the given <code>xcode_version</code> targets, the matching
target will be used. This may not be set if <code>remote_versions</code> or
<code>local_versions</code> is set.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="xcode_version.default_ios_sdk_version">
<code>default_ios_sdk_version</code>
</td>
<td>
<p><code>String; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The ios sdk version that is used by default when this version of xcode is being used.
The <code>ios_sdk_version</code> build flag will override the value specified here.
</td>
</tr>
<tr>
<td id="xcode_version.default_macos_sdk_version">
<code>default_macos_sdk_version</code>
</td>
<td>
<p><code>String; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The macosx sdk version that is used by default when this version of xcode is being used.
The <code>macos_sdk_version</code> build flag will override the value specified here.
</td>
</tr>
<tr>
<td id="xcode_version.default_tvos_sdk_version">
<code>default_tvos_sdk_version</code>
</td>
<td>
<p><code>String; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The tvos sdk version that is used by default when this version of xcode is being used.
The <code>tvos_sdk_version</code> build flag will override the value specified here.
</td>
</tr>
<tr>
<td id="xcode_version.default_watchos_sdk_version">
<code>default_watchos_sdk_version</code>
</td>
<td>
<p><code>String; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The watchos sdk version that is used by default when this version of xcode is being used.
The <code>watchos_sdk_version</code> build flag will override the value specified here.
</td>
</tr>
<tr>
<td id="xcode_version.version">
<code>version</code>
</td>
<td>
<p><code>String; required; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
The official version number of a version of Xcode.
</td>
</tr>
</tbody>