johnno1962 / InjectionNext

Fourth evolution of Code Injection for Xcode
MIT License
48 stars 1 forks source link

"Modern" JIT-based Preview not working (at all) with injection #6

Closed andrebraga closed 1 month ago

andrebraga commented 1 month ago

Canvas won't load and has this message:

image

The contents of the diagnostics are unspecific to the issue.

But with this workaround it works. Should this be documented?

image

Of note, https://developer.apple.com/documentation/xcode-release-notes/xcode-16-release-notes#Previews:

Known Issues Some large or complex projects may fail to build and run if they are scanning for specific Mach-O sections in their binaries. (123416939) Workaround: Try setting the build setting ENABLE_DEBUG_DYLIB=NO. This will disable the debug dylib that enables the new preview execution mode. Setting this to NO will still allow you to preview in Xcode 16 Seed 1 using the legacy execution mode, but support for this mode will be removed in a future build.

I would assume that "Use Legacy Previews Execution" has the same effect of setting ENABLE_DEBUG_DYLIB=NO, but trying to set it directly leads to:

image

in the canvas.

Xcode 16 beta 3.

johnno1962 commented 1 month ago

Thanks so much for this information! I hadn't realised InjectionLite was incompatible with their new previews implementation. Decoding their message it seems you can no longer call dlsym() inside static initialisers as it will deadlock and timeout. I've updated InjectionLite which provides the implementation for InjectionNext to be statically linked instead of making this sort of query and pushed a new version. If you "File/Packages/Reset Package Caches" it should pick up the new 2.0.4 version of InjectionLite and previews in Xcode 16 should be working now. In due course I'll have to find a solution for the original InjectionIII.app as well when things have settled down.

andrebraga commented 1 month ago

I can confirm it's working now! Fantastic!

johnno1962 commented 1 month ago

Excellent, Glad to hear it. I remember noticing previews were taking a long time. They must have put in a timeout now.

johnno1962 commented 1 month ago

The original app doesn't seem to display this particular problem with Xcode 16 previews. One less thing to fix!