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
Warnings that indicate the compiler cannot resolve an `#if canImport(<ModuleName>, _version: <version>)` directive because the module found was not built with a `-user-module-version` flag.
4
+
5
+
6
+
## Overview
7
+
8
+
Developers may conditionalize which code is active in a source file based on the module version number of an imported dependency module, like this:
9
+
10
+
```swift
11
+
importDependency
12
+
13
+
#if canImport(Dependency, _version: 1.2)
14
+
// Use declarations introduced in version 1.2 of Dependency
15
+
#else
16
+
// ...
17
+
#endif
18
+
```
19
+
20
+
A dependency's module version must be established by passing the `-user-module-version` flag when compiling the sources of the dependency the module. If no `-user-module-version` flag was specified when the dependency module was built, then the compiler will warn that it cannot resolve the `#if canImport` directive:
21
+
22
+
```
23
+
warning: cannot find user version number for module 'Dependency'; version number ignored [#ModuleVersionMissing]
24
+
```
25
+
26
+
If this diagnostic is emitted, then the `#if canImport` directive implicitly evaluates true.
0 commit comments