gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.24k stars 264 forks source link

Circular Reference Compilation Error when Compiling with Xcode 6.0 Beta Tools #323

Closed mikelikespie closed 1 week ago

mikelikespie commented 2 weeks ago

Thank you for contributing to MarkdownUI!

Before you submit an issue, please complete the report with all the relevant details for your bug and go through every item in the checklist.

Describe the bug A clear and concise description of what the bug is.

Checklist

Steps to reproduce

  1. Using the new xcode 6 beta, try building the project or run swift build with new CLI tools selected

Expected behavior It to build

Screenshots

error: emit-module command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
/Users/ml/code/swift-markdown-ui/Sources/MarkdownUI/Parser/InlineNode.swift:3:7: note: through reference here
 1 | import Foundation
 2 | 
 3 |  enum InlineNode: Hashable {
   |       |- note: through reference here
   |       |- note: through reference here
   |       `- note: through reference here
 4 |   case text(String)
 5 |   case softBreak
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
/Users/ml/code/swift-markdown-ui/Sources/MarkdownUI/Parser/InlineNode.swift:3:7: note: through reference here
 1 | import Foundation
 2 | 
 3 |  enum InlineNode: Hashable {
   |       |- note: through reference here
   |       |- note: through reference here
   |       `- note: through reference here
 4 |   case text(String)
 5 |   case softBreak
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
/Users/ml/code/swift-markdown-ui/Sources/MarkdownUI/Parser/InlineNode.swift:3:7: note: through reference here
 1 | import Foundation
 2 | 
 3 |  enum InlineNode: Hashable {
   |       |- note: through reference here
   |       |- note: through reference here
   |       `- note: through reference here
 4 |   case text(String)
 5 |   case softBreak

Version information

Additional context Add any other context about the problem here.

electricsidecar-dev commented 2 weeks ago

I've submitted FB13830058 to Apple for this bug.

I've isolated the bug down to the following minimally reproducible sample:

indirect enum BlockNode: Hashable {
  case paragraph(content: [InlineNode])
}

indirect enum InlineNode: Hashable {
  case emphasis(children: [InlineNode])
}
electricsidecar-dev commented 2 weeks ago

Oddly, the following snippet builds:

indirect enum BlockNode {
  case paragraph(content: InlineNode)
}

indirect enum InlineNode {
  case foo
  case emphasis(children: [InlineNode])
}

but this one does not:

indirect enum BlockNode {
  case paragraph(content: [InlineNode])
}

indirect enum InlineNode {
  case foo
  case emphasis(children: [InlineNode])
}
electricsidecar-dev commented 2 weeks ago

More fun: the following builds

indirect enum BlockNode {
  case paragraph([InlineNode])
}

indirect enum InlineNode {
  case foo
  case emphasis(children: [InlineNode])
}

but this does not:

indirect enum BlockNode {
  case paragraph(content: [InlineNode])
}

indirect enum InlineNode {
  case foo
  case emphasis(children: [InlineNode])
}
electricsidecar-dev commented 2 weeks ago

I've got a buildable patch working locally. Will send up a PR.

JoshuaRileyDev commented 2 weeks ago

How can I reference that PR in Xcode? Or does it need to be approved

electricsidecar-dev commented 2 weeks ago

Something like this in your Package.swift should work until this PR is merged:

    dependencies: [
        .package(url: "https://github.com/electricsidecar-dev/swift-markdown-ui.git", .branch("recursive")),
    ],
gonzalezreal commented 1 week ago

@electricsidecar-dev Thank you for investigating this and coming up with a workaround. I hope they fix it in the upcoming Xcode 16 betas. Great work! ❤️

alexsllater commented 1 week ago

please push update

gonzalezreal commented 1 week ago

Fixed by #328