Skip to content

Commit 7a6466b

Browse files
authored
Updates to module aliasing doc (#5583)
1 parent c954ea4 commit 7a6466b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Documentation/ModuleAliasing.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Package manifest `swift-game`
2323
{
2424
name: "swift-game",
2525
products: [
26-
.library(name: "UtilsProduct", targets: ["Utils"]),
26+
.library(name: "Utils", targets: ["Utils"]),
2727
],
2828
targets: [
2929
.target(name: "Utils", dependencies: [])
@@ -40,7 +40,7 @@ Both `swift-draw` and `swift-game` vend modules with the same name `Utils`, thus
4040
dependencies: [
4141
.product(name: "Utils",
4242
package: "swift-draw"),
43-
.product(name: "UtilsProduct",
43+
.product(name: "Utils",
4444
package: "swift-game",
4545
moduleAliases: ["Utils": "GameUtils"]),
4646
])
@@ -51,8 +51,6 @@ The value for the `moduleAliases` parameter is a dictionary where the key is the
5151

5252
To use the aliased module, `App` needs to reference the the new name, i.e. `import GameUtils`. Its existing `import Utils` statement will continue to reference the `Utils` module from package `swift-draw`, as expected.
5353

54-
Note that the names being disambiguated here are the conflicting module names, not the product names, thus the product names of each package are still required to be unique. If the vended product name of `swift-game` is `Utils` instead of `UtilsProduct` in the example above, it will throw a `multiple products named "Utils"' error as it does today.
55-
5654
### Example 2
5755

5856
`App` imports a module `Utils` from a package `swift-draw`. It wants to add another package dependency `swift-game` and imports a module `Game` vended from the package. The `Game` module imports `Utils` from the same package.
@@ -153,4 +151,3 @@ The alias `SwiftUtils` defined in `swift-game` will be overridden by the value `
153151
* A module being aliased cannot be a prebuilt binary due to the impact on mangling and serialization, i.e. source-based only.
154152
* A module being aliased should not be passed to a runtime call such as `NSClassFromString(...)` that converts (directly or indirectly) String to a type in a module since such call will fail.
155153
* If a target mapped to a module being aliased contains resources, they should be asset catalogs, localized strings, or resources that do not require explicit module names.
156-
* Module aliasing disambiguates conflicting module names which affect the corresponding target names, thus the product names of each package are still required to be unique.

0 commit comments

Comments
 (0)