Closed lemonmojo closed 1 year ago
Just verified on an actual iPhone; fails as well.
Here's a list of all the APIs I've found to SIGSEGV up until now:
System.Type.GetType
System.String.IndexOf
System.DateTime.Now
System.Globalization.CultureInfo ctor
System.Version ctor
System.Version.TryParse
System.Convert.ToInt32
System.Reflection.Assembly.GetName
System.Decimal.TryParse
Setting InvariantGlobalization
in the csproj to true
works around the crashes but makes tests using a specific culture fail.
Can also be fixed by having <RuntimeHostConfigurationOption Include="ICU_DAT_FILE_PATH" Value="icudt.dat" />
in the csproj and including a copy of icudt.dat
in the bundle.
The file can be found in the NuGet cache (ie. ~/.nuget/packages/microsoft.netcore.app.runtime.nativeaot.ios-arm64/8.0.0-preview.6.23329.7/runtimes/ios-arm64/native/icudt.dat
)
Unfortunately that doesn't work in a XCTest bundle because the runtime locates the file by using -[NSBundle mainBundle]. See https://github.com/dotnet/runtime/issues/88835 and https://github.com/xamarin/xamarin-macios/issues/18471#issuecomment-1634287195
Might be able to work around this by calling AppContext.SetData("ICU_DAT_FILE_PATH", "<path>")
early on in startup.
Using System.AppContext
to set the icudt.dat file path at runtime does indeed work.
See https://github.com/royalapplications/beyondnet/commit/f2d4f2b6d51641ac43412eb70bae9c19d4b11ab8.
Some unit tests succeed when targeting macOS but fail when targeting the iOS simulator. They are marked with
// TODO: Test fails on iOS
.