You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/faq.md
+4-71
Original file line number
Diff line number
Diff line change
@@ -3,55 +3,15 @@
3
3
## Table of Contents
4
4
5
5
<!-- MARKDOWN TOC: BEGIN -->
6
-
*[Why use Gazelle and Go?](#why-use-gazelle-and-go)
7
-
*[Why split the implementation between Go and Starlark?](#why-split-the-implementation-between-go-and-starlark)
8
-
*[How does the Gazelle plugin for Go handle this?](#how-does-the-gazelle-plugin-for-go-handle-this)
9
-
*[Is the same build file generation logic used for the Go/Gazelle and Starlark implementations?](#is-the-same-build-file-generation-logic-used-for-the-gogazelle-and-starlark-implementations)
10
-
*[Does this replace rules_spm?](#does-this-replace-rules_spm)
11
-
*[Can I migrate from rules_spm to `rules_swift_package_manager`?](#can-i-migrate-from-rules_spm-to-rules_swift_package_manager)
12
-
*[Can I just manage my external Swift packages and not generate Bazel build files for my project?](#can-i-just-manage-my-external-swift-packages-and-not-generate-bazel-build-files-for-my-project)
6
+
*[Does this replace [rules_spm]?](#does-this-replace-rules_spm)
7
+
*[Where is the Swift gazelle plugin?](#where-is-the-swift-gazelle-plugin)
13
8
*[After running `//:swift_update_pkgs`, I see a `.build` directory. What is it? Do I need it?](#after-running-swift_update_pkgs-i-see-a-build-directory-what-is-it-do-i-need-it)
14
-
*[Does the Gazelle plugin run Swift package manager with every execution?](#does-the-gazelle-plugin-run-swift-package-manager-with-every-execution)
15
9
*[Can I store the Swift dependency files in a sub-package (i.e., not in the root of the workspace)?](#can-i-store-the-swift-dependency-files-in-a-sub-package-ie-not-in-the-root-of-the-workspace)
16
-
*[Why does this happen?](#why-does-this-happen)
17
10
*[How do I handle the error `Unable to resolve byName reference XXX in @swiftpkg_yyy.`?](#how-do-i-handle-the-error-unable-to-resolve-byname-reference-xxx-in-swiftpkg_yyy)
18
11
*[How do I fix this issue?](#how-do-i-fix-this-issue)
19
12
*[What is the cause of the error? Why can't `rules_swift_package_manager` handle this situation?](#what-is-the-cause-of-the-error-why-cant-rules_swift_package_manager-handle-this-situation)
20
13
<!-- MARKDOWN TOC: END -->
21
14
22
-
## Why use Gazelle and Go?
23
-
24
-
The [Gazelle framework] provides lots of great features for generating Bazel build and Starlark
25
-
files. Right now, the best way to leverage the framework is to write the plugin in Go.
26
-
27
-
In addition, adoption of the Gazelle ecosystem has started to take off. There are [lots of useful
28
-
plugins for other languages](https://github.com/bazelbuild/bazel-gazelle#supported-languages).
29
-
Letting Gazelle generate and maintain Bazel build files is a real game changer for developer
30
-
productivity.
31
-
32
-
## Why split the implementation between Go and Starlark?
33
-
34
-
As mentioned previously, the easiest way to implement a Gazelle plugin is to write it in Go. This
35
-
works great for generating build files in the primary workspace. However, there is a chicken-and-egg
36
-
problem when it comes time to generate build files in a repository rule. The repository rule needs
37
-
to generate files during the [loading phase]. The Go toolchain and the Gazelle framework defined in
38
-
the workspace are not available to the repository rule during this phase. So, one needs to either
39
-
perform some gymnastics to build the Gazelle plugin (see below) or use a language/runtime that is
40
-
guaranteed to be available during the loading phase. Since Starlark is available during the loading
41
-
phase, the build file generation logic for the repository rules is implemented in Starlark.
42
-
43
-
### How does the Gazelle plugin for Go handle this?
44
-
45
-
In short, they assume that if you are using the Gazelle plugin for Go, then you must have a Go
46
-
toolchain installed on the host system. In essence, they shell out and run Go from the system.
47
-
48
-
## Is the same build file generation logic used for the Go/Gazelle and Starlark implementations?
49
-
50
-
No. The Gazelle plugin inspects the Swift source files and the directory structure to determine the
51
-
placement and content of the Bazel build files. The repository rules leverage information about the
52
-
Swift packages (e.g., dump and describe JSON). However, both implementations use the
53
-
`module_index.json` to resolve module references to Bazel targets for the external dependencies.
54
-
55
15
## Does this replace [rules_spm]?
56
16
57
17
Yes. There are some [limitations with the rules_spm
@@ -63,14 +23,9 @@ features and improvements:
63
23
- Build the external dependencies with [rules_swift].
64
24
- Pin the exact versions for the direct and transitive dependencies.
65
25
66
-
## Can I migrate from [rules_spm] to `rules_swift_package_manager`?
67
-
68
-
Absolutely. A [migration guide from rules_spm](https://github.com/cgrindel/rules_swift_package_manager/issues/99) is
69
-
on the roadmap.
26
+
## Where is the Swift gazelle plugin?
70
27
71
-
## Can I just manage my external Swift packages and not generate Bazel build files for my project?
72
-
73
-
Yes. Just omit the `//:update_build_files` target that is mentioned in the [quickstart].
28
+
It has moved to https://github.com/cgrindel/swift_gazelle_plugin.
74
29
75
30
## After running `//:swift_update_pkgs`, I see a `.build` directory. What is it? Do I need it?
76
31
@@ -80,28 +35,11 @@ commands. These commands result in a `.build` directory being created. The direc
80
35
effect of running the Swift package manager commands. It can be ignored and should not be checked
81
36
into source control. It is not used by the Gazelle plugin or the Starlark repository rules.
82
37
83
-
## Does the Gazelle plugin run Swift package manager with every execution?
84
-
85
-
No. The Gazelle plugin only executes the Swift package manager when run in `update-repos` mode. This
86
-
mode only needs to be run when modifying your external dependencies (e.g., add/remove a dependency,
87
-
update the version selection for a dependency). The `update` mode for the Gazelle plugin generates
88
-
Bazel build files for your project. It uses information written to the `swift_deps_index.json` and
89
-
the source files that exist in your project to generate the Bazel build files.
90
-
91
38
## Can I store the Swift dependency files in a sub-package (i.e., not in the root of the workspace)?
92
39
93
40
Yes. The [vapor example] demonstrates storing the Swift dependency files in a sub-package called
94
41
`swift`.
95
42
96
-
### Why does this happen?
97
-
98
-
This can happen with some Swift packages (e.g. `firebase-ios-sdk`). [rules_xcodeproj removes the
0 commit comments