bazel-ios / rules_ios

Bazel rules for building iOS applications and frameworks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[xcodeproj] Local breakpoints do not work when sandbox is enabled

amberdixon opened this issue · comments

See #98 (comment) for context.

"In order for the example applications and tests in the rules_ios repo to be debuggable from Xcode, you must:

Disable sandboxing in .bazelrc.
Update the flag in the tools/xcodeproj_shims/build-wrapper.sh to refer to --//rules:local_debug_options_enabled rather than --@build_bazel_rules_ios//rules:local_debug_options_enabled"

Hey, I am trying to get breakpoints working on Xcode while using the xcodeproj rule. What I did:

  • I pulled rules_ios to the most updated commit, containing #119
  • I added the following to my bazel.rc file:
build --genrule_strategy=standalone
build --spawn_strategy=standalone
build --compilation_mode=dbg

But I cant get it to work. Are there any other steps required? 🤔

EDIT:
I tried also with the examples of this repo:

  • Cloned the latest commit from this repo
  • Removed the comments for the following lines in the .bazelrc file:
build --genrule_strategy=standalone
build --spawn_strategy=standalone
  • Opened tests/ios/xcodeproj/TestWithHostApp.xcodeproj
  • Added a breakpoint in line 5 of EmptySwiftTests.swift
  • Run the tests: do CMD+U in the ExplicitHosted scheme of the project

Result: breakpoint did not stop the execution

Will take a look, thank you

@amberdixon We tried the same setup steps as @acecilia and also reproduced the same result: we did not hit a local breakpoint when set in Xcode 11. Were you able to reproduce @acecilia's issue?

We would be happy to help investigate / fix if possible, but don't want to duplicate any investigative work that you have already done on this issue.

@amberdixon could you give an update on this? 🙏
What is the status of breakpoints? Are they supposed to work and I have some faulty configuration, or are they not working?

Hi all! This is working for me, if I do the following:

  1. bazelisk run tests/ios/xcodeproj:Test-With-Host-App --@build_bazel_rules_ios//rules:local_debug_options_enabled
  2. open tests/ios/xcodeproj/TestWithHostApp.xcodeproj
  3. Set a break point on line 5 of empty.swift where the EmptySwiftTests class is defined.
  4. Select the ExplicitHosted scheme
  5. Run Cmd+U.
    My breakpoint gets hit.

Note that I do not need to disable sandbox mode anymore. I think there have been some changes to this repo since October that may have fixed the issue. I'm using Xcode 11.6 on BigSur (Mac OS v11.0.1).

I'm also able to hit breakpoints in main.m when I run the iOS-9.3-AppHost scheme. Perhaps #127 made a difference here? In any case, this issue is not happening anymore.

@amberdixon I just followed your steps but on Xcode 12.3 and 12.2 and can't make breakpoints work. Then I was wondering is it anywhere stated here that these rules only work with Xcode 11.x ? cc @segiddins

They should work equally well on 11 and 12

@segiddins I was following exactly the steps as above and I can't seem to get breakpoints working. Do you have any advice how to debug this? I would be happy to investigate it.

Same here, cant get the breakpoint to work 😢 . Followed these steps:

  1. rm -rf tests/ios/xcodeproj/TestWithHostApp.xcodeproj
  2. bazelisk run tests/ios/xcodeproj:Test-With-Host-App --@build_bazel_rules_ios//rules:local_debug_options_enabled
  3. Check that git is clean: it is
  4. open tests/ios/xcodeproj/TestWithHostApp.xcodeproj
  5. Set a break point on line 5 of empty.swift where the EmptySwiftTests class is defined
  6. Select the ExplicitHosted scheme
  7. Run Cmd+U

The breakpoint does not stop execution of the test.

Running on:

  • Catalina 10.15.7
  • Xcode Version 12.3 (12C33)
  • Latest commit from this repository: 20d809d07f3c9db4887049efedd6a47a749400dd
  • Simulator: iPhone 8 iOS 14.3

I also run on code 11.6 with same results. I am bit puzzled at this point, only difference I see with @amberdixon is Catalina VS bigSur

Hi all. It looks like there is an issue with sandboxing is not enabled. Thanks for reporting the issue, apologies for closing it too early.

Furthermore, when you change the sandbox flag (i.e. turn it on or off), you must then close Xcode, run bazelisk clean && bazelisk run tests/ios/xcodeproj:Test-With-Host-App and then reopen the project again. So it seems like there is some lingering state!

In order to get breakpoints to work, you should:

  1. Close Xcode
  2. Comment out these lines in .bazelrc:
# build --genrule_strategy=standalone
# build --spawn_strategy=standalone
  1. Call bazelisk clean
  2. Call bazelisk run tests/ios/xcodeproj:Test-With-Host-App
  3. Reopen xcode.
  4. Set a break point on line 5 of empty.swift where the EmptySwiftTests class is defined
  5. Select the ExplicitHosted scheme
  6. Run Cmd+U