Skip to content

Commit

Permalink
docs: clarify when to enable declare_swift_deps_info (#1185)
Browse files Browse the repository at this point in the history
Clarify when the `declare_swift_deps_info` attribute should be enabled
for workspaces that use `rules_swift_package_manager`.

Closes #1176.
  • Loading branch information
cgrindel authored Jul 30, 2024
1 parent c27daf6 commit 34b0098
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ development inside a Bazel workspace.
* [Quickstart](#quickstart)
* [1. Enable bzlmod](#1-enable-bzlmod)
* [2. Configure your `MODULE.bazel` to use rules_swift_package_manager.](#2-configure-your-modulebazel-to-use-rules_swift_package_manager)
* [(Optional) Enable `swift_deps_info` generation for the Gazelle plugin](#optional-enable-swift_deps_info-generation-for-the-gazelle-plugin)
* [3. Create a minimal `Package.swift` file.](#3-create-a-minimal-packageswift-file)
* [4. Run `swift package update`](#4-run-swift-package-update)
* [5. Run `bazel mod tidy`.](#5-run-bazel-mod-tidy)
Expand Down Expand Up @@ -116,16 +117,27 @@ use_repo(
)
```

You will also need to add a dependency on Gazelle and `rules_swift`. Follow
the links below to get the latest bzlmod snippets to insert into your `MODULE.bazel`.

- [gazelle](https://registry.bazel.build/modules/gazelle)
- [rules_swift](https://registry.bazel.build/modules/rules_swift)
You will also need to add a dependency on [rules_swift].

NOTE: Some Swift package manager features (e.g., resources) use rules from [rules_apple]. It is a
dependency for `rules_swift_package_manager`. However, you do not need to declare it unless you use
any of the rules in your project.

#### (Optional) Enable `swift_deps_info` generation for the Gazelle plugin

If you will be using the Gazelle plugin for Swift, you will need to enable the generation of
the `swift_deps_info` repository by enabling `declare_swift_deps_info`.

```bazel
swift_deps.from_package(
declare_swift_deps_info = True, # <=== Enable swift_deps_info generation for the Gazelle plugin
resolved = "//:Package.resolved",
swift = "//:Package.swift",
)
```

You will also need to add a dependency on [Gazelle](https://registry.bazel.build/modules/gazelle).

### 3. Create a minimal `Package.swift` file.

Create a minimal `Package.swift` file that only contains the external dependencies that are directly
Expand Down

0 comments on commit 34b0098

Please sign in to comment.