rules_xcodeproj
rules_xcodeproj copied to clipboard
Bug:
Description
I have iOSPro as the main project, and test targets for UI and unit tests as follows: iOSProUITests, iOSProUnitTests. I have this as the BUILD.bazel
load(
"@build_bazel_rules_apple//apple:ios.bzl",
"ios_application",
"ios_ui_test", # Use ios_ui_test for XCUITests
)
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load(
"@rules_xcodeproj//xcodeproj:defs.bzl",
"top_level_target",
"xcodeproj",
)
xcodeproj(
name = "xcodeproj",
project_name = "iOSPro",
tags = ["manual"],
top_level_targets = [
top_level_target(":iOSPro", target_environments = ["simulator"]),
":Tests",
],
)
ios_application(
name = "iOSPro",
bundle_id = "io.christdoes.nl",
families = ["iphone", "ipad"],
infoplists = [":Info.plist"], # Specify the path to the Info.plist file
minimum_os_version = "13.0",
visibility = ["//visibility:public"],
# deps = [":Lib"],
)
ios_ui_test(
name = "iOSProUITests",
bundle_id = "io.christdoes.nl.xctest",
minimum_os_version = "16.4",
test_host = ":iOSPro",
visibility = ["//visibility:public"],
deps = [
":TestLib", ],
)
swift_library(
name = "TestLib",
srcs = ["iOSProUI.swift"], # Replace with the actual source file(s) path
)
The error response
[5 / 21] [Prepa] BazelWorkspaceStatusAction stable-status.txt ... (3 actions, 0 running)
ERROR: /Users/kadeoya/Documents/project/Bench/MultiLangTestFramework/iOSPro/BUILD.bazel:23:16: Linking iOSPro/iOSPro_bin failed: (Exit 1): wrapped_clang failed: error executing command (from target //iOSPro:iOSPro) external/local_config_cc/wrapped_clang @bazel-out/ios-sim_arm64-min13.0-applebin_ios-ios_sim_arm64-fastbuild-ST-d2635e34fccd/bin/iOSPro/iOSPro_bin-2.params
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error in child process '/usr/bin/xcrun'. 1
Target //iOSPro:iOSProUITests failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.211s, Critical Path: 0.73s
INFO: 22 processes: 20 internal, 2 darwin-sandbox.
FAILED: Build did NOT complete successfully
//iOSPro:iOSProUITests FAILED TO BUILD
Executed 0 out of 1 test: 1 fails to build.
FAILED: Build did NOT complete successfully
INFO: Build Event Protocol files produced successfully.
Build failed. No tests were run.
Reproduction steps
- Setup the project with bazel
Expected behavior
It should build the test
rules_xcodeproj version
1.10.0
Xcode version
Version 14.3.1 (14E300c)
Bazel version
6.3.2
rules_apple version
No response
rules_swift version
No response
Additional information
No response
The error seems to be unrelated to rules_xcodeproj. It seems like your error message is coming from running bazel build
or bazel test
, so nothing related to the xcodeproj
rule you have defined.
implicit entry/start for main executable
happens when you don't specify an entry point to your app (read more here). I suggest adding a library to deps
your ios_application
which contains a main entry point and that should fix your issue.
I'm still very new to Bazel, and it's very promising it'll really be helpful in moving forward our complex build and test projects. all I did was to copy and paste the specified rules recommendations on this repo, and expecting it to work out of the box. My project is POC, very simple, and nothing complex. To Bazel professionals here, looking at the project, could you kindly make edits to the BUILD.bazel rules I shared above.
the project structure is not complex, it is simple ios project that has target of XCTest and XCUITest. I attached the screenshot of the structure.
This is the main file // Licensed under the Applitools SDK License, which can be found here: https://www.applitools.com/eula/sdk
import XCTest
import EyesXCUI
class iOSProUITest: XCTestCase {
let application = XCUIApplication()
let eyes = Eyes()
let validationHelper = UIValidationHelper.shared
override func setUp() {
super.setUp()
continueAfterFailure = false
application.launch()
// Initialize configuration
let config = Configuration()
config.apiKey = "R8Ab101J6kTcLav20sMJUjk3XvnYZW7BCOR100do7xXJI7U110"
config.statusBarExists = true
// Initialize the eyes SDK and set up with configuration.
eyes.configuration = config
}
func testExamples() {
let application: XCUIApplication = XCUIApplication()
application.launch()
EarlGrey.selectElement(with: grey_keyWindow()).perform(grey_tap())
}
func testClickObject(){
let radioButtonMatcher = grey_accessibilityID(Configurations.randumNumber)
validationHelper.validateElementExists(radioButtonMatcher)
validationHelper.validateElementClickable(radioButtonMatcher)
EarlGrey.selectElement(with: radioButtonMatcher).performTapAction()
validationHelper.validateRadioButtonSelected(radioButtonMatcher)
let simulateDiffMatcher = grey_accessibilityID(Configurations.simulateDiff)
validationHelper.validateElementExists(simulateDiffMatcher)
validationHelper.validateElementClickable(simulateDiffMatcher)
EarlGrey.selectElement(with: simulateDiffMatcher).performTapAction()
validationHelper.validateRadioButtonSelected(simulateDiffMatcher)
let clickMeMatcher = grey_accessibilityID(Configurations.clickMe)
validationHelper.validateElementExists(clickMeMatcher)
validationHelper.validateElementClickable(clickMeMatcher)
EarlGrey.selectElement(with: clickMeMatcher).performTapAction()
}
func testApplitoolEyes() throws {
// Start the test.
eyes.open(withApplicationName: "Hello World!", testName: "My first test using EyesXCUI SDK!")
// Visual checkpoint #1.
eyes.check(withTag: "Hello", andSettings: Target.window().timeout(inSeconds: 5))
let radioButtonMatcher = grey_accessibilityID(Configurations.clickMe)
validationHelper.validateElementExists(radioButtonMatcher)
validationHelper.validateElementClickable(radioButtonMatcher)
EarlGrey.selectElement(with: radioButtonMatcher).performTapAction()
validationHelper.validateRadioButtonSelected(radioButtonMatcher)
// Visual checkpoint #2.
eyes.check(withTag: "Click!", andSettings: Target.window())
let thumbUpOrBugImageView = application.images["ThumbUpOrBugImageView"]
// Visual checkpoint #3
eyes.check(withTag: "Thumb up", andSettings: Target.element(thumbUpOrBugImageView))
let clickRandumNumber = EarlGrey.selectElement(with: grey_accessibilityID("randumNumber"))
clickRandumNumber.assert(grey_not(grey_selected()))
clickRandumNumber.perform(grey_tap())
let clickSimpleDiff = EarlGrey.selectElement(with: grey_accessibilityID("simulateDiff"))
clickSimpleDiff.assert(grey_not(grey_selected()))
clickSimpleDiff.perform(grey_tap())
// Tap on the "Simulate diffs" checkbox.
// application.buttons["SimulateDiffsCheckbox"].tap()
// Visual checkpoint #4.
eyes.check(withTag: "Simulate Differences!", andSettings: Target.window())
// Click the "Click me!" button.
EarlGrey.selectElement(with: radioButtonMatcher).performTapAction()
// Visual checkpoint #5.
eyes.check(withTag: "Bug has been found!", andSettings: Target.window())
// Visual checkpoint #6
eyes.check(withTag: "Bug", andSettings: Target.element(thumbUpOrBugImageView))
// End the test.
try eyes.close()
}
}
As seen, I installed 2 packages from EarlGrey and Applitool Eyes. Please, someone help. All I want to do is to run the XCUITest and XCTest from Bazel. I can succssfully run it from XCode