-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add local debug options as a dependency, but only if local_debug_options_enabled #98
Conversation
tests/macos/xcodeproj/build.sh
Outdated
xcodebuild -project Test-Target-With-Test-Host-Project.xcodeproj -quiet | ||
# TODO: use strings to test that absolute paths and debug-prefix-map are present in the LocalDebug.swiftmodule. Not sure if this is the right palce to do it. We could also grep out the build event text file maybe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: spelling of place
rules/app.bzl
Outdated
@@ -56,7 +56,7 @@ def ios_application(name, apple_library = apple_library, **kwargs): | |||
""" | |||
infoplists = write_info_plists_if_needed(name = name, plists = kwargs.pop("infoplists", [])) | |||
application_kwargs = {arg: kwargs.pop(arg) for arg in _IOS_APPLICATION_KWARGS if arg in kwargs} | |||
library = apple_library(name = name, namespace_is_module_name = False, platforms = {"ios": application_kwargs.get("minimum_os_version")}, **kwargs) | |||
library = apple_library(name = name, namespace_is_module_name = False, platforms = {"ios": application_kwargs.get("minimum_os_version")}, add_swift_local_debug_options = True, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also be passed for tests as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could only add in the select to the deps
passed to rules_apple_ios_application
, and make it conditional on whether there were actually any swift files? That way, the swiftmodule that represents the app needn't be invalidated by switching the flag either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as of Xcode 11.5, we don't need/use this workaround for apps, only tests.
…options_enabled is specified at command line. Make xcode specify this config
bcca942
to
e230690
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Does of of the test projects in this repo demonstrate the fix?
rules/BUILD.bazel
Outdated
"-serialize-debugging-options", | ||
], | ||
module_name = "_LocalDebugOptions", | ||
tags = ["no-remote"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we also tag as manual?
tests/macos/xcodeproj/build.sh
Outdated
xcodebuild -project Test-Target-With-Test-Host-Project.xcodeproj -quiet | ||
# TODO: use strings to test that absolute paths and debug-prefix-map are present in the LocalDebug.swiftmodule. Not sure if this is the right palce to do it. We could also grep out the build event text file maybe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: spelling of place
I am still seeing issues with test bundles locally. I get errors like this. This happens for tests written in swift both with and without an app host:
That said, I think the changes in this PR are still correct, but perhaps we need to do a few more things in terms of setting additional lldb settings. Going to open this up for review and then continue working on these issues I'm seeing with tests locally. |
We might need to add in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -1,4 +1,4 @@ | |||
#!/bin/bash | |||
set -euxo pipefail | |||
|
|||
$BAZEL_PATH build --experimental_execution_log_file=$BAZEL_BUILD_EXECUTION_LOG_FILENAME --build_event_text_file=$BAZEL_BUILD_EVENT_TEXT_FILENAME --build_event_publish_all_actions $1 2>&1 | $BAZEL_OUTPUT_PROCESSOR | |||
$BAZEL_PATH build --experimental_execution_log_file=$BAZEL_BUILD_EXECUTION_LOG_FILENAME --build_event_text_file=$BAZEL_BUILD_EVENT_TEXT_FILENAME --build_event_publish_all_actions $1 --@build_bazel_rules_ios//rules:local_debug_options_enabled 2>&1 | $BAZEL_OUTPUT_PROCESSOR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run the following to get test fixtures updated:
bazelisk query 'kind(xcodeproj, tests/ios/xcodeproj/...)' | xargs -n 1 bazelisk run
bazelisk query 'kind(xcodeproj, tests/macos/xcodeproj/...)' | xargs -n 1 bazelisk run
bazelisk query 'attr(executable, 1, kind(genrule, tests/macos/xcodeproj/...))' | xargs -n 1 bazelisk run
bazelisk query 'attr(executable, 1, kind(genrule, tests/ios/xcodeproj/...))' | xargs -n 1 bazelisk run
find . -type f \( -name 'WORKSPACE' -o -name '*.bzl' -o -name '*.bazel' \) | xargs buildifier -lint=fix
rules/app.bzl
Outdated
@@ -61,9 +61,16 @@ def ios_application(name, apple_library = apple_library, **kwargs): | |||
application_kwargs["launch_storyboard"] = application_kwargs.pop("launch_storyboard", library.launch_screen_storyboard_name) | |||
application_kwargs["families"] = application_kwargs.pop("families", ["iphone", "ipad"]) | |||
|
|||
local_debug_options_for_swift = [] | |||
if library.has_swift_sources: | |||
local_debug_options_for_swift += ["@build_bazel_rules_ios//rules:_LocalDebugOptions"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we update some documentation / readme to reflect this important flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comments in the BUILD.bazel where the _LocalDebugOptions target is defined. I will also reference this README: https://github.com/ios-bazel-users/ios-bazel-users/blob/master/DebuggableRemoteSwift.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding separate docs shouldn't be necessary, since the xcodeproj rule automatically enables the flag when necessary
.bazelrc
Outdated
# Enable these features to test local and CI builds | ||
# when swiftmodule caching is enabled. | ||
build --features=swift.cacheable_swiftmodules | ||
build --features=swift.use_global_module_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: trailing newline
tests/macos/xcodeproj/build.sh
Outdated
xcodebuild -project Test-Target-With-Test-Host-Project.xcodeproj -quiet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: trailing newline
Only do this if local_debug_options_enabled is specified at command line. Make xcode specify this config.
The changes in this PR are taken from the suggested changes in https://github.com/ios-bazel-users/ios-bazel-users/blob/master/DebuggableRemoteSwift.md to get debugging working.
Note that in order for the example applications and tests in the rules_ios repo to be debuggable from Xcode, you must:
--//rules:local_debug_options_enabled
rather than--@build_bazel_rules_ios//rules:local_debug_options_enabled
There are still known issues with evaluating variables from the debugger for swift tests.