realm / jazzy

Soulful docs for Swift & Objective-C
https://realm.io
MIT License
7.35k stars 413 forks source link

Could not cast value of type 'Swift.String' (0x7ff8556a6848) to 'Swift.Dictionary<Swift.String, SourceKittenFramework.SourceKitRepresentable>' (0x7ff855e42708). #1399

Closed david-hm-morgan closed 1 month ago

david-hm-morgan commented 2 months ago
Could not cast value of type 'Swift.String' (0x7ff8556a6848) to 'Swift.Dictionary<Swift.String, SourceKittenFramework.SourceKitRepresentable>' (0x7ff855e42708).

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

    from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/sourcekitten.rb:229:in `run_sourcekitten'
    from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:83:in `block (2 levels) in build'
    from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:81:in `chdir'
    from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:81:in `block in build'
    from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:71:in `map'
    from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:71:in `build'
    from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/bin/jazzy:16:in `<top (required)>'
    from /Users/jenkins/.rbenv/versions/3.2.2/bin/jazzy:25:in `load'
    from /Users/jenkins/.rbenv/versions/3.2.2/bin/jazzy:25:in `<main>'

Using:

johnfairh commented 2 months ago

Please provide some source code that triggers this.

Something in the code is causing SourceKit to return a string for a field that sourcekitten is expecting to be a map.

It's probably a new / unusual construct -- all of our regular test projects run cleanly on Xcode 16 RC1.

david-hm-morgan commented 2 months ago

Hi @johnfairh thanks for responding... strangely (AFAIK) there is nothing new here just rebuilding with latest Xcode, so I am not able to pinpoint which part of the code is triggering this complaint. I'll probably need to narrow down the scope of the doc generation incrementally. Can jazzy provide more logs as to its progress to get any clues as to where it is when it falls over?

johnfairh commented 2 months ago

This is the sourcekitten phase crashing. If there's really no per-sourcefile output that you've elided (kind of thing like Parsing SwiftTopLevelClass.swift (1/1)) then that is curious, it looks to me as though it does that printf before starting each file.

david-hm-morgan commented 2 months ago

a more complete log... 95 files handled apparently correctly, then this error.

...
Parsing OTVAVPlayer.swift (91/95)

Parsing OTVAVPlayerItem+InsightExt.swift (92/95)

Parsing OTVAVPlayerItem.swift (93/95)

Parsing OTVAVURLAsset.swift (94/95)

Parsing OTVSDK.swift (95/95)

Could not cast value of type 'Swift.String' (0x7ff8556a6848) to 'Swift.Dictionary<Swift.String, SourceKittenFramework.SourceKitRepresentable>' (0x7ff855e42708).
johnfairh commented 2 months ago

Aha ok. So if we're lucky the problem is in OTVSDK.swift. If unlucky (bit suspicious it's the last file...) then it might be in some kind of end-module processing that will need narrowing.

david-hm-morgan commented 2 months ago

The most recent run of this (a few weeks ago) logged some warnings after the 95th file was processed, could the issue now be in this wrap up activity?

...
Parsing OTVSDK.swift (95/95)
WARNING: No documented top-level declarations match name "OTVSSPTokenCallback" specified in categories file
WARNING: No documented top-level declarations match name "AVURLAsset" specified in categories file
WARNING: No documented top-level declarations match name "OTVWatermarkDelegate" specified in categories file
WARNING: No documented top-level declarations match name "OTVWatermarkError" specified in categories file
building site
johnfairh commented 2 months ago

Nope - those WARNINGs are from Jazzy (the ruby layer) after sourcekitten (the swift layer that is now crashing for you) has finished.

johnfairh commented 1 month ago

Fixed by pulling in a version of sourcekitten that includes the update to parse the new Swift-6 output format.