If you want to link with a pre-built framework (i.e. built by a separate tool before running ninja), then you have to
- define a config, say `custom_framework_config` to declare frameworks and framework_dir variables,
- add this config to all target the tries to use the framework, i.e. include `configs += [ ":custom_framework_config" ]
- add a bundle_data rule target listing the files from the framework to package in the app (if possible list all of them)
- add a dependency to the bundle_data target in your final ios_app_bundle target (could be indirectly).
So, say that you put the pre-build framework in $absolute_path_to_framework (note, you cannot use environment variables in gn, so you have to substitute the real path in the fragment I put below), then you would do the following:
config("custom_framework_config") {
frameworks = [ "CustomFramework.framework" ]
framework_dirs = [ "$absolute_path_to_framework" ]
}
bundle_data("custom_framework_bundle_data") {
sources = [
"$absolute_path_to_framework/CustomFramework.framework/CustomFramework",
"$absolute_path_to_framework/CustomFramework.framework/Info.plist",
# List all the other files, if the framework contains directories, you'll
# needs to use multiple bundle_data targets, one per sub-directory.
]
outputs = [ "{{bundle_resources_dir}}/Frameworks/CustomFramework.framework/{{source_file_part}}" ]
}
source_set("some_code_that_uses_the_framework") {
sources = [ ... ]
configs += [ ":custom_framework_config" ]
deps = [ ":custom_framework_bundle_data" ]
}
ios_app_bundle("my_app") {
deps = [ ":some_code_that_uses_the_framework" ]
...
}
If you want to build the framework as part of building Chromium, then you would have to define rules to build the framework. You can look at how this is done for lottie for example in //ios/third_party/lottie/BUILD.gn.