Objective-C Rules
apple_binary
apple_binary(name, deps, data, binary_type, compatible_with, deprecation, distribs, dylibs, exec_compatible_with, exec_properties, extension_safe, features, licenses, linkopts, minimum_os_version, platform_type, restricted_to, sdk_dylibs, sdk_frameworks, tags, testonly, visibility, weak_sdk_frameworks)
This rule produces single- or multi-architecture ("fat") Objective-C libraries and/or binaries, typically used in creating apple bundles, such as frameworks, extensions, or applications.
The lipo
tool is used to combine files of multiple architectures. One of several
flags may control which architectures are included in the output, depending on the value of
the "platform_type" attribute.
Implicit output targets
name_lipobin
: the 'lipo'ed potentially multi-architecture binary. All transitive dependencies andsrcs
are linked.
Arguments
Attributes | |
---|---|
name |
A unique name for this target. |
deps
|
|
binary_type
|
|
dylibs
|
A list of dynamic library targets to be linked against in this rule and included
in the final binary. Libraries which are transitive dependencies of any such dylibs will
not be statically linked in this target (even if they are otherwise
transitively depended on via the |
extension_safe
|
linkopts attribute.
|
linkopts
|
|
minimum_os_version
|
|
platform_type
|
ios
is selected, then the output binaries/libraries will be created combining all
architectures specified in --ios_multi_cpus .
Options are:
|
sdk_dylibs
|
|
sdk_frameworks
|
When linking a top level binary (e.g. apple_binary), all SDK frameworks listed in that binary's transitive dependency graph are linked. |
weak_sdk_frameworks
|
|
apple_static_library
apple_static_library(name, deps, data, avoid_deps, compatible_with, deprecation, distribs, exec_compatible_with, exec_properties, features, licenses, linkopts, minimum_os_version, platform_type, restricted_to, sdk_dylibs, sdk_frameworks, tags, testonly, visibility, weak_sdk_frameworks)
This rule produces single- or multi-architecture ("fat") Objective-C statically-linked libraries, typically used in creating static Apple Frameworks for distribution and re-use in multiple extensions or applications.
The lipo
tool is used to combine files of multiple architectures; a build flag
controls which architectures are targeted. The build flag examined depends on the
platform_type
attribute for this rule (and is described in its documentation).
Implicit output targets
name_lipo.a
: a 'lipo'ed archive file. All transitive dependencies andsrcs
are linked, minus all transitive dependencies specified inavoid_deps
.
Arguments
Attributes | |
---|---|
name |
A unique name for this target. |
deps
|
|
avoid_deps
|
A list of targets which should not be included (nor their transitive dependencies
included) in the outputs of this rule -- even if they are otherwise transitively depended
on via the This attribute effectively serves to remove portions of the dependency tree from a static library, and is useful most commonly in scenarios where static libraries depend on each other. That is, suppose static libraries X and C are typically distributed to consumers
separately. C is a very-common base library, and X contains less-common functionality; X
depends on C, such that applications seeking to import library X must also import library
C. The target describing X would set C's target in |
linkopts
|
|
minimum_os_version
|
|
platform_type
|
ios
is selected, then the output binaries/libraries will be created combining all
architectures specified in --ios_multi_cpus .
Options are:
|
sdk_dylibs
|
|
sdk_frameworks
|
When linking a top level binary (e.g. apple_binary), all SDK frameworks listed in that binary's transitive dependency graph are linked. |
weak_sdk_frameworks
|
|
j2objc_library
j2objc_library(name, deps, compatible_with, deprecation, distribs, entry_classes, features, jre_deps, licenses, restricted_to, tags, testonly, visibility)
This rule uses J2ObjC to translate Java source files to Objective-C, which then can be used used as dependencies of objc_library and objc_binary rules. Detailed information about J2ObjC itself can be found at the J2ObjC site
Custom J2ObjC transpilation flags can be specified using the build flag
--j2objc_translation_flags
in the command line.
Please note that the translated files included in a j2objc_library target will be compiled using the default compilation configuration, same configuration as for the sources of an objc_library rule with no compilation options specified in attributes.
Plus, generated code is de-duplicated at target level, not source level. If you have two different Java targets that include the same Java source files, you may see a duplicate symbol error at link time. The correct way to resolve this issue is to move the shared Java source files into a separate common target that can be depended upon.
Arguments
Attributes | |
---|---|
name |
A unique name for this target. |
deps
|
j2objc_library , java_library ,
java_import and java_proto_library targets that contain
Java files to be transpiled to Objective-C.
All 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
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,
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
|
entry_classes
|
--j2objc_dead_code_removal
is on. The Java classes should be specified in their canonical names as defined by
the Java
Language Specification.
When flag --j2objc_dead_code_removal 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.
|
jre_deps
|
j2objc_library rule. Only core JRE functionality is linked by default.
|
objc_import
objc_import(name, hdrs, alwayslink, archives, compatible_with, deprecation, distribs, features, includes, licenses, restricted_to, sdk_dylibs, sdk_frameworks, sdk_includes, tags, testonly, textual_hdrs, visibility, weak_sdk_frameworks)
This rule encapsulates an already-compiled static library in the form of an
.a
file. It also allows exporting headers and resources using the same
attributes supported by objc_library
.
Arguments
Attributes | |
---|---|
name |
A unique name for this target. |
hdrs
|
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. These will be compiled separately from the source if modules are enabled. |
alwayslink
|
srcs and non_arc_srcs , 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.
|
archives
|
.a files provided to Objective-C targets that
depend on this target.
|
includes
|
#include/#import 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
#import/#include statements.
The paths are interpreted relative to the package directory, and the
genfiles and bin roots (e.g. Unlike COPTS, 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 COPTS instead. |
sdk_dylibs
|
|
sdk_frameworks
|
When linking a top level binary (e.g. apple_binary), all SDK frameworks listed in that binary's transitive dependency graph are linked. |
sdk_includes
|
#include/#import search paths to add to this target
and all depending targets, where each path is relative to
$(SDKROOT)/usr/include .
|
textual_hdrs
|
|
weak_sdk_frameworks
|
|
objc_library
objc_library(name, deps, srcs, data, hdrs, alwayslink, compatible_with, copts, defines, deprecation, distribs, enable_modules, exec_compatible_with, exec_properties, features, includes, licenses, module_map, module_name, non_arc_srcs, pch, restricted_to, runtime_deps, sdk_dylibs, sdk_frameworks, sdk_includes, tags, testonly, textual_hdrs, toolchains, visibility, weak_sdk_frameworks)
This rule produces a static library from the given Objective-C source files.
Implicit output targets
name_fully_linked.a
: A fully linked static library that contains the full transitive closure of library dependencies.
Arguments
Attributes | |
---|---|
name |
A unique name for this target. |
deps
|
|
srcs
|
|
hdrs
|
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. These will be compiled separately from the source if modules are enabled. |
alwayslink
|
srcs and non_arc_srcs , 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.
|
copts
|
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. |
defines
|
-D flags to pass to the compiler. They should be in
the form KEY=VALUE or simply KEY and are
passed not only to the compiler for this target (as copts
are) but also to all objc_ dependers of this target.
Subject to "Make variable" substitution and
Bourne shell tokenization.
|
enable_modules
|
|
includes
|
#include/#import 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
#import/#include statements.
The paths are interpreted relative to the package directory, and the
genfiles and bin roots (e.g. Unlike COPTS, 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 COPTS instead. |
module_map
|
|
module_name
|
|
non_arc_srcs
|
|
pch
|
|
runtime_deps
|
|
sdk_dylibs
|
|
sdk_frameworks
|
When linking a top level binary (e.g. apple_binary), all SDK frameworks listed in that binary's transitive dependency graph are linked. |
sdk_includes
|
#include/#import search paths to add to this target
and all depending targets, where each path is relative to
$(SDKROOT)/usr/include .
|
textual_hdrs
|
|
weak_sdk_frameworks
|
|