Creating a brand new macOS Command Line Tool project in Xcode Version 13.3 (13E113), and replacing the contents of main.swift
with the following code:
import Foundation
enum StructA {
// case case1(value: StructB)
case case2(expr: StructB)
}
indirect enum StructB {
case case3
case case4(expr: StructB)
}
Results in the following compile-time error:
<unknown>:0: error: circular reference
/Users/alextj/projects/TestProject/main.swift:8:15: note: through reference here
indirect enum StructB {
^
<unknown>:0: note: through reference here
However , if you uncomment the case1
line, then the circular reference error goes away!
So the following code compiles without errors:
import Foundation
enum StructA {
case case1(value: StructB)
case case2(expr: StructB)
}
indirect enum StructB {
case case3
case case4(expr: StructB)
}
Why?
Why does commenting out case1
cause a circular reference?
I did the following steps which is helps me resolve the circular reference after updated to Xcode 13.3.1
:
1- Clean project.
2- Clean derived data.
3- Change project Build Setting SWIFT_COMPILATION_MODE
from Incremental to the Whole Module.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.