@@ -16,7 +16,6 @@ more concise and more powerful.
16
16
* [ Nested enum reducers] ( #Nested-enum-reducers )
17
17
* [ Gotchas] ( #Gotchas )
18
18
* [ Autocomplete] ( #Autocomplete )
19
- * [ Circular reference errors] ( #Circular-reference-errors )
20
19
* [ #Preview and enum reducers] ( #Preview-and-enum-reducers )
21
20
* [ CI build failures] ( #CI-build-failures )
22
21
@@ -390,38 +389,29 @@ is a way to get access to the state in the store without any observation taking
390
389
#### Synthesizing protocol conformances on State and Action
391
390
392
391
Since the ` State ` and ` Action ` types are generated automatically for you when using ` @Reducer ` on an
393
- enum, it's not possible to directly synthesize conformances of ` Equatable ` , ` Hashable ` ,
394
- _ etc._ , on those types. And further, due to a bug in the Swift compiler you cannot currently do
395
- this:
392
+ enum, you must extend these types yourself to synthesize conformances of ` Equatable ` , ` Hashable ` ,
393
+ _ etc._ :
396
394
397
395
``` swift
398
396
@Reducer
399
397
enum Destination {
400
398
// ...
401
399
}
402
- extension Destination .State: Equatable {} // ❌
400
+ extension Destination .State: Equatable {}
403
401
```
404
402
405
- See < doc:Reducer#Circular-reference-errors > below for more info on this error.
406
-
407
- So, to work around this compiler bug the ` @Reducer ` macro takes two
408
- `` ComposableArchitecture/_SynthesizedConformance `` arguments that allow you to describe which
409
- protocols you want to attach to the ` State ` or ` Action ` types:
410
-
411
- ``` swift
412
- @Reducer (state: .equatable , .sendable , action: .sendable )
413
- enum Destination {
414
- // ...
415
- }
416
- ```
417
-
418
- You can provide any combination of
419
- `` ComposableArchitecture/_SynthesizedConformance/codable `` ,
420
- `` ComposableArchitecture/_SynthesizedConformance/decodable `` ,
421
- `` ComposableArchitecture/_SynthesizedConformance/encodable `` ,
422
- `` ComposableArchitecture/_SynthesizedConformance/equatable `` ,
423
- `` ComposableArchitecture/_SynthesizedConformance/hashable `` , or
424
- `` ComposableArchitecture/_SynthesizedConformance/sendable `` .
403
+ > Note: In Swift <6 the above extension causes a compiler error due to a bug in Swift.
404
+ >
405
+ > To work around this compiler bug, the library provides a version of the ` @Reducer ` macro that
406
+ > takes two `` ComposableArchitecture/_SynthesizedConformance `` arguments, which allow you to
407
+ > describe the protocols you want to attach to the ` State ` or ` Action ` types:
408
+ >
409
+ > ``` swift
410
+ > @Reducer (state: .equatable , .sendable , action: .sendable )
411
+ > enum Destination {
412
+ > // ...
413
+ > }
414
+ > ```
425
415
426
416
#### Nested enum reducers
427
417
@@ -464,30 +454,6 @@ providing additional type hints to the compiler:
464
454
+ Reduce<State, Action> { state, action in
465
455
```
466
456
467
- # ### Circular reference errors
468
-
469
- There is currently a bug in the Swift compiler and macros that prevents you from extending types
470
- that are inside other types with macros applied in the same file. For example, if you wanted to
471
- extend a reducer's `State` with some extra functionality:
472
-
473
- ```swift
474
- @Reducer
475
- struct Feature {
476
- @ObservableState
477
- struct State { /* ... */ }
478
- // ...
479
- }
480
-
481
- extension Feature.State { // 🛑 Circular reference
482
- // ...
483
- }
484
- ```
485
-
486
- This unfortunately does not work. It is a
487
- [ known issue] ( https://github.com/apple/swift/issues/66450 ) , and the only workaround is to either
488
- move the extension to a separate file, or move the code from the extension to be directly inside the
489
- ` State ` type.
490
-
491
457
# ### #Preview and enum reducers
492
458
493
459
The `#Preview` macro is not capable of seeing the expansion of any macros since it is a macro
@@ -551,6 +517,22 @@ struct Feature_Previews: PreviewProvider {
551
517
}
552
518
```
553
519
520
+ #### Error: External macro implementation … could not be found
521
+
522
+ When integrating with the Composable Architecture, one may encounter the following error:
523
+
524
+ > Error: External macro implementation type 'ComposableArchitectureMacros.ReducerMacro' could not be
525
+ > found for macro 'Reducer()'
526
+
527
+ This error can show up when the macro has not yet been enabled, which is a separate error that
528
+ should be visible from Xcode's Issue navigator.
529
+
530
+ Sometimes, however, this error will still emit due to an Xcode bug in which a custom build
531
+ configuration name is being used in the project. In general, using a build configuration other than
532
+ "Debug" or "Release" can trigger upstream build issues with Swift packages, and we recommend only
533
+ using the default "Debug" and "Release" build configuration names to avoid the above issue and
534
+ others.
535
+
554
536
#### CI build failures
555
537
556
538
When testing your code on an external CI server you may run into errors such as the following:
0 commit comments