wickwirew / Runtime

A Swift Runtime library for viewing type info, and the dynamic getting and setting of properties.
MIT License
1.08k stars 94 forks source link

Fix swift 5.4 linux compatibility #93

Closed Supereg closed 3 years ago

Supereg commented 3 years ago

As described in https://github.com/wickwirew/Runtime/issues/92, swift 5.4 change the ClassMetadataLayout for platforms that do not support Objective-C interoperability. This resulted in Runtime crashing when running on those platforms with the newest swift releases.

This PR fixes this issue by adjusting the ClassMetadataLayout on those platforms. I'm using the #if !swift(>=5.4) || canImport(Darwin). Not entirely sure if canImport(Darwin) is the proper check for availability of Objective-C interoperability (works though). Happy for any feedback.

I have another PR ready which adds some CI integration with GitHub to test the framework on all the available linux distortions. This PR passes all tests on all platforms: Actions Run. I chose to do the CI PR separately so this fix can get merged faster.

helje5 commented 3 years ago

canImport(ObjectiveC) maybe?

Supereg commented 3 years ago

With canImport(ObjectiveC) tests pass as well (see https://github.com/Supereg/Runtime/actions/runs/987505669).

The docs read like that package is only available if the objective-c runtime is available. So that is probably then the way to go.

helje5 commented 3 years ago

There are about 5 or 6 ObjC runtimes supported by clang, but I think only the Apple one is supported by Swift (and coming w/ a modmap). So I'm not entirely sure which one is better :-)

Supereg commented 3 years ago

If I may ping you @wickwirew, would love to get a review on this to get the fix upstream (as well as my other PRs).