rules_xcodeproj icon indicating copy to clipboard operation
rules_xcodeproj copied to clipboard

Bug: `ENABLE_TESTING_SEARCH_PATHS` build setting not set when `testonly = True`

Open erikkerber opened this issue 2 years ago • 12 comments

Xcode provides ENABLE_TESTING_SEARCH_PATHS which will include Developer/Library/Frameworks to the builds search paths, so developers can use XCTest libraries in non-test targets.

Currently rules_swift sets that for everything, while Xcode makes it disabled-by-default.

erikkerber avatar Apr 06 '22 16:04 erikkerber

Looks like it is only set when testonly is set: https://github.com/bazelbuild/rules_swift/commit/768bfe3fe885f92fbaea75488268e2612ab9ef9c#diff-b66f80b469020168d63d1079602ed95b2dd607240c182a4a1098b34eb865020eR267

brentleyjones avatar Apr 06 '22 16:04 brentleyjones

So we have code to do this, and it's working for test targets. I wonder where it's failing for other targets? Do you have more details @erikkerber?

https://github.com/buildbuddy-io/rules_xcodeproj/blob/0e2b21635c7b2752940261d37c34b22e7a68348a/xcodeproj/internal/target.bzl#L734-L738

brentleyjones avatar Apr 07 '22 17:04 brentleyjones

We did not have testonly applied to these targets before today, and I'll re-test.

They are testing helper targets that utilize XCTest, but not test targets themselves.

erikkerber avatar Apr 07 '22 19:04 erikkerber

Given https://github.com/bazelbuild/rules_swift/commit/768bfe3fe885f92fbaea75488268e2612ab9ef9c#diff-b66f80b469020168d63d1079602ed95b2dd607240c182a4a1098b34eb865020eR267, how did they link correctly with Bazel?

brentleyjones avatar Apr 07 '22 19:04 brentleyjones

I tested this and it does work if targets are applied with testonly = True

Closing 👍🏼

erikkerber avatar Apr 12 '22 14:04 erikkerber

I tested this and it does work if targets are applied with testonly = True

But bazel build works without testonly = True? If so, is there a bug with rules_swift? Ideally rules_xcodeproj would work without any workspace changes, even if it doesn't make sense.

brentleyjones avatar Apr 12 '22 15:04 brentleyjones

Yes. My read in rules_swift, and I could be wrong, is that Developer/Library/Frameworks is added unconditionally.

erikkerber avatar May 05 '22 02:05 erikkerber

That seems like a bug to me. Someone should fix it 😉.

brentleyjones avatar May 05 '22 02:05 brentleyjones

Re-opening, as we need to change to mimic rules_swift, or (ideally) rules_swift needs to adjust to only add the framework search paths for test_only = True.

brentleyjones avatar Jun 08 '22 21:06 brentleyjones

https://github.com/bazelbuild/rules_swift/pull/840 should address this from the rules_swift side.

brentleyjones avatar Jun 22 '22 13:06 brentleyjones

@brentleyjones Can we close this issue now?

maxwellE avatar Jun 24 '22 17:06 maxwellE

After we update to a released version with the fix.

brentleyjones avatar Jun 24 '22 17:06 brentleyjones