Skip to content
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

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

Open
amberdixon opened this issue Aug 26, 2020 · 10 comments
Open

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

amberdixon opened this issue Aug 26, 2020 · 10 comments
Assignees

Comments

@amberdixon
Copy link
Collaborator

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"

@acecilia
Copy link
Contributor

acecilia commented Sep 14, 2020

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

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

@amberdixon
Copy link
Collaborator Author

Will take a look, thank you

@wileykestner
Copy link
Contributor

@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.

@acecilia
Copy link
Contributor

@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?

@amberdixon
Copy link
Collaborator Author

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.

@FranzBusch
Copy link

@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

@segiddins
Copy link
Member

They should work equally well on 11 and 12

@FranzBusch
Copy link

@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.

@acecilia
Copy link
Contributor

acecilia commented Jan 8, 2021

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

@amberdixon
Copy link
Collaborator Author

amberdixon commented Jan 19, 2021

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

@amberdixon amberdixon reopened this Jan 19, 2021
ob added a commit that referenced this issue Jan 22, 2021
Link to the issue that describes the sandboxing problem (#108)
@jerrymarino jerrymarino changed the title Local breakpoints do not work when sandbox is enabled [xcodeproj] Local breakpoints do not work when sandbox is enabled Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants