Fix crash due to IKTAddSuperImplementationToClass being stripped
This fixes https://github.com/steipete/InterposeKit/issues/29 for me. I think without the used attribute, the compiler optimizes the function away as it appears to be unused.
This doesn't fix the issue completely, unfortunately. While the crash is gone when build & running from Xcode (even Release configuration), it is still present with a build through TestFlight.
I've pushed a fix that actually works when archiving the app too. It seems that the compiler (or linker?) is eager to strip away IKTAddSuperImplementationToClass as it seems unused. No amount of attributes could convince the compiler to keep it. So that's why I updated the implementation to directly call SuperBuilder.addSuperInstanceMethod. It seems to work, but there must be a good reason why you went with dlopen/dlsym so I guess I'm missing something.
The failed CI tasks answer my question, I think. SuperBuilder has to be a separate target for SPM because it's Objective-C. You don't want it to be a separate target for CocoaPods, so there SuperBuilder is part of the main target. So you can't use import SuperBuilder but instead load the class dynamically.
My fix makes it work for SPM, but breaks it for the Xcode project and CocoaPods. I'm not yet sure how to proceed.
Thanks for this! I'll look into this this week.
Any change of merging this pr in repo? We rely on the fix suggested by @Thomvis but we had to use a fork in order to fix crash in our app)
@steipete any news? this is still occurring as of Swift 5.10
Same here, I went the fork route with the patch from @Thomvis for now, but having this upstream would be great.