johnno1962 / InjectionIII

Re-write of Injection for Xcode in (mostly) Swift
MIT License
4.01k stars 319 forks source link

Question: is @Observable supported? #473

Closed lechuckcaptain closed 8 months ago

lechuckcaptain commented 8 months ago

First of all, let me take the chance to thank you for the fantastic project!

I've recently doing some experiments with the new Observation framework, converting some code from Combine's ObservableObject to the new @Observable macro.

It seems that after the conversion, the changes are not correctly applied by InjectionIII, even if I don't see any particular error on Xcode console.

I'm probably doing something wrong 😅 , but I was wondering if the new Observation framework has been already tested and is supported or it's still a work in progress.

I prepared a sample repo to showcase the issue.

I'm using Xcode 15.0.1 (15A507), and I can reproduce the issue on both Mac and iOS simulator.

Thank you in advance!

johnno1962 commented 8 months ago

Hi, you had me worried there as using the new @Observable macro should't affect injection's "old school" mechanism for redisplay. Thanks very much for posting the example though where I can see there is a minor problem in how it is set up. For "Other Linker Flags" you have "-Xlinker -interposable" instead of -Xlinker then -inteprosable on separate lines. This is due to a usability regression with Xcode 15+ where if you paste in -Xlinker -interposable, Xcode puts in the double quotes for you which prevents the option from working whereas it used to paste the options on separate lines. There is a low key warning about an unused option in the sidebar as your project builds which might have helped diagnosing the problem. If you fix this up your project should work as expected. You're not the first person to encounter this problem however and I'll make the REAME even more explicit as the -interposbale option is critical for SwiftUI to be able to inject.

lechuckcaptain commented 8 months ago

Sorry for the rookie mistake, you are totally right. For future reference I added a new fixed branch to the sample repository.