Skip to content

Commit

Permalink
Merge pull request #133 from bazel-ios/amber/remove-force-swiftdebug-…
Browse files Browse the repository at this point in the history
…transition

Do not apply force_swift_local_debug_options transition.
  • Loading branch information
amberdixon authored Oct 7, 2020
2 parents ba2af7a + ced10b8 commit e58a64f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
15 changes: 0 additions & 15 deletions rules/transition_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
8 changes: 1 addition & 7 deletions rules/xcodeproj.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down Expand Up @@ -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),
Expand All @@ -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,
)
8 changes: 4 additions & 4 deletions tests/ios/xcodeproj/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions tests/macos/xcodeproj/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit e58a64f

Please sign in to comment.