File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -184,19 +184,23 @@ this will only work if the `Visibility` is set to `internal`.
184
184
185
185
##### Generation Option: ` UseAccessLevelOnImports ` - imports preceded by a visibility modifier (` public ` , ` package ` , ` internal ` )
186
186
187
- By default, the code generator does not precede any imports with a visibility modifier.
188
- You can change this with the ` UseAccessLevelOnImports ` option:
187
+ The default behavior depends on the Swift version the plugin is compiled with.
188
+ For Swift versions below 6.0 the default is ` false ` and the code generator does not precede any imports with a visibility modifier.
189
+ You can change this by explicitly setting the ` UseAccessLevelOnImports ` option:
189
190
190
191
```
191
192
$ protoc --swift_opt=UseAccessLevelOnImports=[value] --swift_out=. foo/bar/*.proto mumble/*.proto
192
193
```
193
194
194
195
The possible values for ` UseAccessLevelOnImports ` are:
195
196
196
- * ` false ` (default) : Generates plain import directives without a visibility modifier.
197
+ * ` false ` : Generates plain import directives without a visibility modifier.
197
198
* ` true ` : Imports of internal dependencies and any modules defined in the module
198
199
mappings will be preceded by a visibility modifier corresponding to the visibility of the generated types - see ` Visibility ` option.
199
200
201
+ ** Important:** It is strongly encouraged to use ` internal ` imports instead of ` @_implementationOnly ` imports.
202
+ Hence ` UseAccessLevelOnImports ` and ` ImplementationOnlyImports ` options exclude each other.
203
+
200
204
201
205
### Building your project
202
206
Original file line number Diff line number Diff line change @@ -190,19 +190,23 @@ this will only work if the `Visibility` is set to `internal`.
190
190
191
191
##### Generation Option: ` UseAccessLevelOnImports ` - imports preceded by a visibility modifier (` public ` , ` package ` , ` internal ` )
192
192
193
- By default, the code generator does not precede any imports with a visibility modifier.
194
- You can change this with the ` UseAccessLevelOnImports ` option:
193
+ The default behavior depends on the Swift version the plugin is compiled with.
194
+ For Swift versions below 6.0 the default is ` false ` and the code generator does not precede any imports with a visibility modifier.
195
+ You can change this by explicitly setting the ` UseAccessLevelOnImports ` option:
195
196
196
197
```
197
198
$ protoc --swift_opt=UseAccessLevelOnImports=[value] --swift_out=. foo/bar/*.proto mumble/*.proto
198
199
```
199
200
200
201
The possible values for ` UseAccessLevelOnImports ` are:
201
202
202
- * ` false ` (default) : Generates plain import directives without a visibility modifier.
203
+ * ` false ` : Generates plain import directives without a visibility modifier.
203
204
* ` true ` : Imports of internal dependencies and any modules defined in the module
204
205
mappings will be preceded by a visibility modifier corresponding to the visibility of the generated types - see ` Visibility ` option.
205
206
207
+ ** Important:** It is strongly encouraged to use ` internal ` imports instead of ` @_implementationOnly ` imports.
208
+ Hence ` UseAccessLevelOnImports ` and ` ImplementationOnlyImports ` options exclude each other.
209
+
206
210
207
211
### Building your project
208
212
Original file line number Diff line number Diff line change @@ -79,7 +79,11 @@ class GeneratorOptions {
79
79
var visibility : Visibility = . internal
80
80
var swiftProtobufModuleName : String ? = nil
81
81
var implementationOnlyImports : Bool = false
82
+ #if swift(>=6.0)
83
+ var useAccessLevelOnImports = true
84
+ #else
82
85
var useAccessLevelOnImports = false
86
+ #endif
83
87
var experimentalStripNonfunctionalCodegen : Bool = false
84
88
85
89
for pair in parameter. parsedPairs {
You can’t perform that action at this time.
0 commit comments