diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 61fad3980..c830f8bd4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,7 +49,7 @@ jobs: set -euo pipefail rm -rf tests/macos/xcodeproj/*.xcodeproj bazelisk clean - bazelisk query 'kind(xcodeproj, tests/macos/xcodeproj/...)' | xargs -n 1 bazelisk run + bazelisk query 'kind(xcodeproj, tests/macos/xcodeproj/...)' | xargs -n 1 bazelisk run --@build_bazel_rules_ios//rules:local_debug_options_enabled bazelisk query 'attr(executable, 1, kind(genrule, tests/macos/xcodeproj/...))' | xargs -n 1 bazelisk run git diff --exit-code tests/macos/xcodeproj - name: Run Xcode builds @@ -68,7 +68,7 @@ jobs: set -euo pipefail rm -rf tests/ios/xcodeproj/*.xcodeproj bazelisk clean - bazelisk query 'kind(xcodeproj, tests/ios/xcodeproj/...)' | xargs -n 1 bazelisk run + bazelisk query 'kind(xcodeproj, tests/ios/xcodeproj/...)' | xargs -n 1 bazelisk run --@build_bazel_rules_ios//rules:local_debug_options_enabled bazelisk query 'attr(executable, 1, kind(genrule, tests/ios/xcodeproj/...))' | xargs -n 1 bazelisk run git diff --exit-code tests/ios/xcodeproj - name: Run pre build checks diff --git a/README.md b/README.md index 09df607b4..b10f3008c 100644 --- a/README.md +++ b/README.md @@ -93,5 +93,7 @@ ios_application( See the [tests](https://github.com/bazel-ios/rules_ios/tree/master/tests) directory for sample applications. -## Special note about debugging +## Special notes about debugging xcode projects +Note that when generating Xcode projects, it is necessary to supply the `--@build_bazel_rules_ios//rules:local_debug_options_enabled` so that debugging of swift files will work. + Debugging does not work in sandbox mode, due to issue #108. The workaround for now is to disable sandboxing in the .bazelrc file. diff --git a/rules/transition_support.bzl b/rules/transition_support.bzl index fb5c1bde5..1d7f847da 100644 --- a/rules/transition_support.bzl +++ b/rules/transition_support.bzl @@ -118,22 +118,7 @@ _apple_rule_transition = transition( ], ) -def _force_swift_local_debug_options_transition_impl(settings, attr): - _ignore = (settings, attr) - return [ - {"@build_bazel_rules_ios//rules:local_debug_options_enabled": True}, - ] - -_force_swift_local_debug_options_transition = transition( - implementation = _force_swift_local_debug_options_transition_impl, - inputs = [], - outputs = [ - "@build_bazel_rules_ios//rules:local_debug_options_enabled", - ], -) - transition_support = struct( apple_rule_transition = _apple_rule_transition, current_apple_platform = _current_apple_platform, - force_swift_local_debug_options_transition = _force_swift_local_debug_options_transition, ) diff --git a/rules/xcodeproj.bzl b/rules/xcodeproj.bzl index c744f7815..16dd1458c 100644 --- a/rules/xcodeproj.bzl +++ b/rules/xcodeproj.bzl @@ -2,7 +2,6 @@ load("@build_bazel_rules_apple//apple:providers.bzl", "AppleBundleInfo") load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo") load("@bazel_skylib//lib:paths.bzl", "paths") load("//rules:hmap.bzl", "HeaderMapInfo") -load("//rules:transition_support.bzl", "transition_support") def _get_attr_values_for_name(deps, provider, field): return [ @@ -674,11 +673,10 @@ def _xcodeproj_impl(ctx): xcodeproj = rule( implementation = _xcodeproj_impl, doc = """\ -Generates a Xcode project file (.xcodeproj) with a reasonable set of defaults +Generates a Xcode project file (.xcodeproj) with a reasonable set of defaults. Specify the --@build_bazel_rules_ios//rules:local_debug_options_enabled when generating the project to ensure debugging of swiftmodules works. Tags for configuration: xcodeproj-ignore-as-target: Add this to a rule declaration so that this rule will not generates a scheme for this target """, - cfg = transition_support.force_swift_local_debug_options_transition, attrs = { "deps": attr.label_list(mandatory = True, allow_empty = False, providers = [], aspects = [_xcodeproj_aspect]), "include_transitive_targets": attr.bool(default = False, mandatory = False), @@ -705,10 +703,6 @@ https://www.rubydoc.info/github/CocoaPods/Xcodeproj/Xcodeproj/Constants "installer": attr.label(executable = True, default = Label("//tools/xcodeproj_shims:installer"), cfg = "host"), "build_wrapper": attr.label(executable = True, default = Label("//tools/xcodeproj_shims:build-wrapper"), cfg = "host"), "additional_files": attr.label_list(allow_files = True, allow_empty = True, default = [], mandatory = False), - "_allowlist_function_transition": attr.label( - default = "@bazel_tools//tools/allowlists/function_transition_allowlist", - doc = "Needed to allow this rule to have an incoming edge configuration transition.", - ), }, executable = True, ) diff --git a/tests/ios/xcodeproj/BUILD.bazel b/tests/ios/xcodeproj/BUILD.bazel index 6f23a65b6..3591683f2 100644 --- a/tests/ios/xcodeproj/BUILD.bazel +++ b/tests/ios/xcodeproj/BUILD.bazel @@ -54,8 +54,8 @@ cat <<'EOS' > $@ #!/bin/sh set -euxo pipefail rm -fr {package_name}/{target_name}.xcodeproj -bazelisk run {package_name}:{target_name} -bazelisk run {package_name}:{target_name} +bazelisk run {package_name}:{target_name} --@build_bazel_rules_ios//rules:local_debug_options_enabled +bazelisk run {package_name}:{target_name} --@build_bazel_rules_ios//rules:local_debug_options_enabled EOS """.format( package_name = package_name(), @@ -74,8 +74,8 @@ cat <<'EOS' > $@ #!/bin/sh set -euxo pipefail rm -fr {package_name}/{target_name}.xcodeproj -bazelisk run {package_name}:{target_name} -bazelisk run {package_name}:{target_name} +bazelisk run {package_name}:{target_name} --@build_bazel_rules_ios//rules:local_debug_options_enabled +bazelisk run {package_name}:{target_name} --@build_bazel_rules_ios//rules:local_debug_options_enabled EOS """.format( package_name = package_name(), diff --git a/tests/macos/xcodeproj/BUILD.bazel b/tests/macos/xcodeproj/BUILD.bazel index 89a2e4370..1a03aa08e 100644 --- a/tests/macos/xcodeproj/BUILD.bazel +++ b/tests/macos/xcodeproj/BUILD.bazel @@ -104,8 +104,8 @@ cat <<'EOS' > $@ #!/bin/sh set -euxo pipefail rm -fr {package_name}/{target_name}.xcodeproj -bazelisk run {package_name}:{target_name} -bazelisk run {package_name}:{target_name} +bazelisk run {package_name}:{target_name} --@build_bazel_rules_ios//rules:local_debug_options_enabled +bazelisk run {package_name}:{target_name} --@build_bazel_rules_ios//rules:local_debug_options_enabled EOS """.format( package_name = package_name(),