chkn / Xamarin.SwiftUI

.NET bindings for SwiftUI
MIT License
98 stars 7 forks source link

Looks like it was the SharedProject's namespace name length which was… #28

Closed CartBlanche closed 4 years ago

CartBlanche commented 4 years ago

causing the crash. Still very odd, but it builds and runs on both iOS and Mac now.

Changed to an odd numbered name length, as a temporary workaround.

Fixes - https://github.com/chkn/Xamarin.SwiftUI/issues/4

CartBlanche commented 4 years ago

@chkn This "Fixes" the shared project crash, by using a namespace from one of the existing exes. Using a unique share-library namespace breaks things. Any ideas or is this a sufficient workaround for now?

chkn commented 4 years ago

Wow good catch! It looks like it crashes if the length of the namespace is even, but not if it's odd. Which is odd :p

It seems we're doing something wrong when constructing the module metadata with the namespace name here: https://github.com/chkn/Xamarin.SwiftUI/blob/master/src/SwiftUI/Swift/Interop/ManagedSwiftType.cs#L274

CartBlanche commented 4 years ago

@chkn could it be the Regex.Replace call failing us here: https://github.com/chkn/Xamarin.SwiftUI/blob/master/src/SwiftUI/Swift/Interop/ManagedSwiftType.cs#L265

I'll try to have a look during the week.

chkn commented 4 years ago

I think it's more likely that the expected format of the string is some 2 byte encoding like UTF-16

Never mind- I forgot that the tests verify names of types, so we are properly decoding them from the metadata already.

CartBlanche commented 4 years ago

@chkn Been a tad busy, so not looked at this yet. Hoping to do so this weekend. Have a good long weekend!

CartBlanche commented 4 years ago

@chkn I've changed the length of the namespace to an odd length, as a temporary hacky work around for this PR. I'll now try to track down why it the even length namespace causes the crash.

CartBlanche commented 4 years ago

@chkn So it isn't just a namespace issue. Even named Classes also crash :/

chkn commented 4 years ago

Definitely sounds like something weird is going on. I’ll dust off my Swift source check out and try to catch the crash in the debugger