GEN_BRIDGE_METADATA(1) | General Commands Manual | GEN_BRIDGE_METADATA(1) |
gen_bridge_metadata
—
Objective-C Bridges Metadata Generator
gen_bridge_metadata |
[options...] headers... |
gen_bridge_metadata
is a tool that
generates bridging metadata information for a given framework or set of
headers. The Objective-C bridges supported in Mac OS X, such as PyObjC
(Python), read this information at runtime.
As of Mac OS 10.7,
gen_bridge_metadata
uses an improved parser, based
on clang
. This means the generated files should be
more correct and complete, and the true parsing allows the automatic
extraction of metadata from existing
__attribute__
()
information supported by the compiler. File generation time should also be
faster.
Metadata files describe the parts of an Objective-C framework that
the bridges cannot automatically handle. These are primarily the ANSI C
elements of the framework -- functions, constants, enumerations, and so on
-- but also include special cases such as functions or methods that accept
pointer-like arguments. These special cases must be manually specified in
separate files called exceptions. The
gen_bridge_metadata
tool can then read in the
exceptions file when it generates the framework metadata.
The file extension used for x86_64 metadata files should be .bridgesupport. The extension for arm64e metadata files should be .arm64e.bridgesupport.
Certain elements, such as inline functions, cannot be described in the metadata files. It is therefore required to generate a dynamic library in order to make the bridges use them. The gen_bridge_metadata tool can take care of that for you.
The file extension for the dynamic libraries should be .dylib.
You should install metadata files in one of three filesystem locations. For example, for a framework named MyFramework that is installed as /Library/Frameworks/MyFramework.framework, you can install the MyFramework.bridgesupport and MyFramework.dylib files in one of the following possible locations, in order of priority:
The gen_bridge_metadata
tool accepts the
following command-line options:
-f
framework, --framework
framework-p
,
--private
-f
argument.
-F
format, --format
format-o
argument.-e
argument in order to generate the
final metadata.-e
file, --exception
file-F
exceptions-template to
the generator.
--arm64e
--arm64e
argument will add
an x86_64 slice.
--64-bit
--no-32-bit
--no-64-bit
-c
,
--cflags
flags-C
,
--cflags-64
flags-o
,
--output
file-h
,
--help
-d
,
--debug
-v
,
--version
This generates bridge support metadata for a custom framework:
mkdir -p
/Path/To/YourFramework.framework/Resources/BridgeSupport
gen_bridge_metadata -f
/Path/To/YourFramework.framework -o
/Path/To/YourFramework.framework/Resources/BridgeSupport/YourFramework.bridgesupport
If the custom framework has inline functions and you want to be able to call them, here is how you can generate a “dylib” file:
gen_bridge_metadata -f
/Path/To/YourFramework.framework -F dylib -o
/Path/To/YourFramework.framework/Resources/BridgeSupport/YourFramework.dylib
It is also possible to generate bridge support metadata for a standalone C library (here, libcurl):
gen_bridge_metadata -c '-lcurl
-I/usr/include/curl' /usr/include/curl/*.h >
/Library/BridgeSupport/curl.bridgesupport
BridgeSupport(5) /System/Library/DTDs/BridgeSupport.dtd ruby(1) python(1)
May 24, 2010 | Mac OS X 12 |