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

Update to latest bazel, rules #189

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update to latest bazel, rules #189

wants to merge 1 commit into from

Conversation

alanzeino
Copy link
Collaborator

Attempting to update the repo so that the build.sh script that is run in the GitHub Action succeeds.

@alanzeino alanzeino requested a review from chiragramani June 29, 2023 21:41
@alanzeino
Copy link
Collaborator Author

$ bazelisk test //src/iOSSnapshotTestCaseTests:iOSSnapshotTestCaseTests --test_output=all

INFO: Analyzed target //src/iOSSnapshotTestCaseTests:iOSSnapshotTestCaseTests (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
ERROR: /Users/alanz/repositories/github/ios-snapshot-test-case/src/iOSSnapshotTestCaseTests/BUILD.bazel:3:13: Compiling src/iOSSnapshotTestCaseTests/FBSnapshotControllerTests.m failed: (Exit 1): wrapped_clang failed: error executing command (from target //src/iOSSnapshotTestCaseTests:iOSSnapshotTestCaseTestsLib) external/local_config_cc/wrapped_clang -target arm64-apple-ios11.0-simulator '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 ... (remaining 43 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
src/iOSSnapshotTestCaseTests/FBSnapshotControllerTests.m:12:9: fatal error: module 'iOSSnapshotTestCaseCore' not found
@import iOSSnapshotTestCaseCore;
 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1
Target //src/iOSSnapshotTestCaseTests:iOSSnapshotTestCaseTests failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.204s, Critical Path: 1.12s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
//src/iOSSnapshotTestCaseTests:iOSSnapshotTestCaseTests         FAILED TO BUILD

Executed 0 out of 1 test: 1 fails to build.

@chiragramani I've never used Bazel outside of our Uber context — do you know why this target can't use this import? It may have worked in the past with our old rules and bazel version. I also found this:

        # With the flip of `--incompatible_objc_framework_cleanup`, the
        # `objc_library` implementation in Bazel no longer passes module
        # maps as inputs to the compile actions, so that `@import`
        # statements for user-provided framework no longer work in a
        # sandbox. This trap door allows users to continue using `@import`
        # statements for imported framework by adding module map to
        # header_imports so that they are included in Obj-C compilation but
        # they aren't processed in any way.

@luispadron
Copy link

luispadron commented Jan 20, 2024

@alanzeino Thanks for putting up this PR, we'd love the new rules being supported as well where I work. I found that the following diff on the bazel branch is what you need to get CI passing (and it removes the need for #if BAZEL):

diff --git a/BUILD.bazel b/BUILD.bazel
index 4d276f7..da15ca6 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -11,6 +11,9 @@ objc_library(
     defines = [
         "SWIFT_PACKAGE"
     ],
+    includes = [
+        "src/iOSSnapshotTestCaseCore/Public"
+    ],
     copts = [
         "-Wno-deprecated-declarations"
     ],
@@ -25,5 +28,6 @@ swift_library(
     deps = [
         ":iOSSnapshotTestCaseCore"
     ],
+    testonly = True,
     visibility = ["//visibility:public"]
 )
diff --git a/src/iOSSnapshotTestCaseTests/BUILD.bazel b/src/iOSSnapshotTestCaseTests/BUILD.bazel
index 0c63a59..6b59b7b 100644
--- a/src/iOSSnapshotTestCaseTests/BUILD.bazel
+++ b/src/iOSSnapshotTestCaseTests/BUILD.bazel
@@ -7,9 +7,6 @@ objc_library(
     deps = [
         "//:iOSSnapshotTestCaseCore"
     ],
-    defines = [
-        "BAZEL"
-    ],
     data = glob(["Resources/*.png"], allow_empty = False),
     sdk_frameworks = [
         "CoreGraphics",
diff --git a/src/iOSSnapshotTestCaseTests/FBSnapshotControllerTests.m b/src/iOSSnapshotTestCaseTests/FBSnapshotControllerTests.m
index 9331038..999a23b 100644
--- a/src/iOSSnapshotTestCaseTests/FBSnapshotControllerTests.m
+++ b/src/iOSSnapshotTestCaseTests/FBSnapshotControllerTests.m
@@ -8,14 +8,8 @@
  */
 
 #import <XCTest/XCTest.h>
-#if BAZEL
-@import iOSSnapshotTestCaseCore;
-@import UIKit;
-@import CoreGraphics;
-@import QuartzCore;
-#else
+
 #import "FBSnapshotTestCase.h"
-#endif
 
 @interface FBSnapshotControllerTests : XCTestCase

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

Successfully merging this pull request may close these issues.

2 participants