-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Target merging fails when using swift_library
dependency directly in rules_ios
framework target
#3094
Comments
As a workaround (and potentially helps narrow down the issue): manually changing the target in the scheme from |
If I remove use of transitive_deps from the merging logic then target merging works as expected and the build also passes. However, indexing seems to fail when making changes:
|
As a workaround we have this rules_ios specific patch right now, working on generalizing it so we can upstream: diff --git xcodeproj/internal/processed_targets/mergeable_infos.bzl xcodeproj/internal/processed_targets/mergeable_infos.bzl
index f04ccb0c..e98c8b55 100644
--- xcodeproj/internal/processed_targets/mergeable_infos.bzl
+++ xcodeproj/internal/processed_targets/mergeable_infos.bzl
@@ -112,6 +112,32 @@ def _calculate_mergeable_info(
swift = swift,
)
+ if len(mergeable_infos) > 2:
+ rules_ios_swift_library_info = [info for info in mergeable_infos if info.id and info.id.split(" ")[0].endswith("_swift")]
+ rules_ios_objc_library_info = [info for info in mergeable_infos if info.id and info.id.split(" ")[0].endswith("_objc")]
+ swift = None
+ cc = None
+ if len(rules_ios_swift_library_info) == 1:
+ swift = rules_ios_swift_library_info[0]
+ if len(rules_ios_objc_library_info) == 1:
+ cc = rules_ios_objc_library_info[0]
+
+ if cc and swift:
+ return _handle_mixed_language_mergeable_infos(
+ cc = cc,
+ dynamic_frameworks = dynamic_frameworks,
+ product_type = product_type,
+ swift = swift,
+ )
+ elif cc:
+ return _cc_mergeable_info(mergeable_info = cc)
+ elif swift:
+ return _swift_mergeable_info(
+ dynamic_frameworks = dynamic_frameworks,
+ mergeable_info = swift,
+ product_type = product_type,
+ )
+
# Unmergeable source target count
return None |
Description
Given the following BUILD file:
With the following rules_xcodeproj scheme:
When generating the project the
LibTwo_Scheme
'sLibTwo
target does not merge and we end up with a scheme that looks like:With LibTwo making up two targets:
LibTwo (Static Framework)
andLibTwo (Library)
. I would expect these to be merged into a singleLibTwo
target in Xcode as is the case when usingapple_framework
as deps.I tested both
2.7.0
and2.5.2
and both seem to have the same issue.I added a reproducing example in: #3093
Reproduction steps
Checkout Add rules_ios example depending on
swift_library
#3093cd examples/rules_ios
bazel run //:xcodeproj-incremental
xed rules_ios.xcodeproj
Select the LibTwo_Scheme target
Attempt to build the target
Observe the failure:
Expected behavior
The
LibTwo
target is merged into a single target so that building it succeeds.rules_xcodeproj version
2.7.0
Xcode version
15.4
Bazel version
7.2.0
rules_apple version
3.9.2
rules_swift version
2.1.1
Additional information
No response
The text was updated successfully, but these errors were encountered: