rules_xcodeproj
rules_xcodeproj copied to clipboard
Feature Request: Support `rules_ios` static framework bundling
Summary
Currently rules_ios
support is limited. There are some assumptions both rules_xcodeproj
and rules_ios
make.
At the moment I'm attempting to generate a project with a single static framework target. This currently fails due to the way rules_ios
builds the AppleBundleInfo
provider: see here.
From the brief look I've had it looks like rules_ios
needs to provide:
- [ ]
executable_name
: https://github.com/bazel-ios/rules_ios/pull/513 - [ ]
minimum_deployment_os_version
: https://github.com/bazel-ios/rules_ios/pull/514 - [ ]
archive
- [ ]
archive_root
I'm opening a feature request in this repository in case we don't need to require these fields for project generation which would make it easier to support other rules. If we do require the fields, we can work to add them to rules_ios
and close this request once we have supported static frameworks from rules_ios
.
I'll work on creating a reproducible example (without proprietary code) and follow up in this issue.
After fixing executable_name
a new errors surfaces:
ERROR: /Users/lpadron/Development/cash-ios-bazel/Pods/StringTemplate/BUILD.bazel:11:15: in @com_github_buildbuddy_io_rules_xcodeproj//xcodeproj/internal:default_automatic_target_processing_aspect.bzl%default_automatic_target_processing_aspect,@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj/internal:xcodeproj_aspect.bzl%xcodeproj_aspect aspect on apple_framework_packaging rule //Pods/StringTemplate:StringTemplate:
Traceback (most recent call last):
File "/private/var/tmp/_bazel_lpadron/fb0c661113a61963d843063c755533c2/external/com_github_buildbuddy_io_rules_xcodeproj/xcodeproj/internal/xcodeproj_aspect.bzl", line 48, column 33, in _xcodeproj_aspect_impl
create_xcodeprojinfo(
File "/private/var/tmp/_bazel_lpadron/fb0c661113a61963d843063c755533c2/external/com_github_buildbuddy_io_rules_xcodeproj/xcodeproj/internal/xcodeprojinfo.bzl", line 365, column 44, in create_xcodeprojinfo
info_fields = _create_xcodeprojinfo(
File "/private/var/tmp/_bazel_lpadron/fb0c661113a61963d843063c755533c2/external/com_github_buildbuddy_io_rules_xcodeproj/xcodeproj/internal/xcodeprojinfo.bzl", line 237, column 52, in _create_xcodeprojinfo
processed_target = process_top_level_target(
File "/private/var/tmp/_bazel_lpadron/fb0c661113a61963d843063c755533c2/external/com_github_buildbuddy_io_rules_xcodeproj/xcodeproj/internal/top_level_targets.bzl", line 266, column 41, in process_top_level_target
props = process_top_level_properties(
File "/private/var/tmp/_bazel_lpadron/fb0c661113a61963d843063c755533c2/external/com_github_buildbuddy_io_rules_xcodeproj/xcodeproj/internal/top_level_targets.bzl", line 90, column 49, in process_top_level_properties
minimum_deployment_version = bundle_info.minimum_deployment_os_version
Error: 'AppleBundleInfo' value has no field or method 'minimum_deployment_os_version'
Available attributes: archive, archive_root, binary, bundle_extension, bundle_id, bundle_name, entitlements, executable_name, infoplist, minimum_os_version, platform_type, product_type, uses_swift
Adding this field as another required property to the list above.
We can for sure not require executable_name
(as long as the executable name matches the bundle name). I'm not sure we can work without archive
/archive_root
.
I think we can work around minimum_deployment_os_version
missing, by defaulting to minimum_os_version
.
Those defaults make sense, I think though rules_ios
should probably provide these if it's as trivial as the PRs I've put up for executable_name
and minimum_deployment_os_version
.
I might need some help understanding archive
and archive_root
however 😅
archive
is the File.path
to the framework. At least for rules_apple, when --define=apple.experimental.tree_artifact_outputs=1
it's the .framework
, otherwise it's a .zip
containing it (if it's always one or the other for rules_ios we can adjust our check).
We use archive_root
to create a fake path when --define=apple.experimental.tree_artifact_outputs=0
:
The file system path (relative to the workspace root) where the signed bundle was constructed (before archiving). Other rules should not depend on this field; it is intended to support IDEs that want to read that path from the provider to avoid unzipping the output archive.
Thanks for the context, thats super helpful!
I'm noticing this field is provided in rules_ios when bundling dynamic frameworks (see here) but not for static frameworks.
I tried to quickly copy the dynamic framework logic but then I get stuff like:
ERROR: /Users/lpadron/Development/cash-ios-bazel/Pods/SwiftGen/BUILD.bazel:11:15: in apple_framework_packaging rule //Pods/SwiftGen:SwiftGen:
/private/var/tmp/_bazel_lpadron/fb0c661113a61963d843063c755533c2/external/build_bazel_rules_ios/rules/framework.bzl:836:5: The following files have no generating action:
Pods/SwiftGen/SwiftGen.framework.zip
Pods/SwiftGen/SwiftGenframework
In my case I've got define=apple.experimental.tree_artifact_outputs=1
but we should support the other case as well in theory
#781 resolved the need for executable_name
to be set.
#1206 resolved the need for archive
/archive_root
to be set.
The only remaining issue is handling the VFS overlay. I'm thinking about how to tackle that. BwX support is currently getting in the way.
Looking like a duplicate of #715.
I believe this is now addressed in main
, at least for BwB mode (we have a error at generation in BwX mode for VFS overlays, since we can't support them). Let me know if that's not the case!