Skip to content

narlei/bazel_sample

Repository files navigation

This is a rules_xcodeproj Sample

To run the project just checkout the main branch and run

make create_project

Or manually:

bazel run //:xcodeproj
open BazelSample.xcodeproj

Currently, we found a bug in the incremental project generation:

Bug description

When focusing on an ios_application and a target that is a dependency of that ios_application, the rules_xcodeproj don't find the target on the graph. Showing the error:

ERROR: Internal precondition failure:
tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift:461: Run build target "@//:MySampleSource ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c" not found in:
[@//:MySampleApp ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryA:LibraryACore ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryA:LibraryAInterface ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryB:LibraryB ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryC:LibraryC ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryD:LibraryD ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c]

Reproducing:

We're creating an ios_application with a dependency:

bazel_sample/BUILD

Lines 37 to 52 in 17ffe72

ios_application(
name = "MySampleApp",
bundle_id = "com.narlei.sample",
families = [
"iphone",
"ipad",
],
infoplists = ["App/Info.plist"],
deps = [
":MySampleSource",
],
minimum_os_version = "16.0",
visibility = ["//visibility:public"],
resources = [":PerformanceTestAppAssets"],
version = ":BazelSampleVersion",
)

The MySampleSource contains the app dependencies:

bazel_sample/BUILD

Lines 15 to 28 in 17ffe72

swift_library(
name = "MySampleSource",
tags = ["manual"],
module_name = "MySampleSource",
srcs = glob(["App/**/*.swift"]),
visibility = ["//visibility:public"],
deps = [
"//Libraries/LibraryA:LibraryACore",
"//Libraries/LibraryA:LibraryAInterface",
"//Libraries/LibraryB:LibraryB",
"//Libraries/LibraryC:LibraryC",
"//Libraries/LibraryD:LibraryD",
]
)

The bug is when I'm trying to focus on the MySampleSource and on MySampleApp:

bazel_sample/BUILD

Lines 65 to 73 in 17ffe72

XCODEPROJ_FOCUSED_TARGETS = [
"//:MySampleApp", # Comment this line to simulate working without the app on focus targets
"//Libraries/LibraryA:LibraryACore",
"//Libraries/LibraryA:LibraryAInterface",
"//Libraries/LibraryB:LibraryB",
"//Libraries/LibraryC:LibraryC",
"//Libraries/LibraryD:LibraryD",
"//:MySampleSource",
]

ERROR: Internal precondition failure:
tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift:461: Run build target "@//:MySampleSource ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c" not found in:
[@//:MySampleApp ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryA:LibraryACore ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryA:LibraryAInterface ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryB:LibraryB ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryC:LibraryC ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c, @//Libraries/LibraryD:LibraryD ios-sim_arm64-min16.0-applebin_ios-ios_sim_arm64-dbg-ST-21282182d87c]

The rules_xcodeproj isn't finding the MySampleSource on the target lists. This is a target of a xcscheme:

bazel_sample/BUILD

Lines 82 to 112 in 17ffe72

SCHEMES = [
xcschemes.scheme(
name = "ProjectSample",
profile = None,
run = xcschemes.run(
build_targets = [
xcschemes.top_level_anchor_target(
label = "//:MySampleApp",
library_targets = [
xcschemes.library_target("//Libraries/LibraryA:LibraryACore",
post_actions = [
xcschemes.pre_post_actions.build_script(title = "This is a post_action", script_text = "echo 'Bye'")
],
pre_actions = [
xcschemes.pre_post_actions.build_script(title = "This is a pre_action", script_text = "echo 'Hi'")
]
),
"//:MySampleSource",
"//Libraries/LibraryA:LibraryAInterface",
"//Libraries/LibraryB:LibraryB",
"//Libraries/LibraryC:LibraryC",
"//Libraries/LibraryD:LibraryD",
],
)
],
# Comment the launch_target to simulate working without the app on focus targets
launch_target = xcschemes.launch_target(
"//:MySampleApp"
),
),
),

Removing the MySampleApp from the focus list (and from the launch_target) works without errors, finding the MySampleSource, but it creates a xscheme without the launch app.

bazel_sample/BUILD

Lines 107 to 110 in 17ffe72

# Comment the launch_target to simulate working without the app on focus targets
launch_target = xcschemes.launch_target(
"//:MySampleApp"
),

bazel_sample/BUILD

Lines 65 to 66 in 17ffe72

XCODEPROJ_FOCUSED_TARGETS = [
"//:MySampleApp", # Comment this line to simulate working without the app on focus targets

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published