sillsdev / icu-dotnet

C# wrapper for ICU4C
MIT License
62 stars 32 forks source link

Support OSX #187

Open ermshiperete opened 1 year ago

ermshiperete commented 1 year ago

macOS uses dylib files instead of so and the file pattern is libicuuc.[version].dylib instead of libicuuc.so.[version], so our current approach for loading unmanaged ICU doesn't work.

The relevant code is in source/icu.net/NativeMethods/NativeMethods.cs.

See discussion on Slack.

ermshiperete commented 1 year ago

See also #141

rmunn commented 1 year ago

Since the Slack discussion may not be accessible to everyone (e.g., any open-source contributors who might find this), here's the important parts from the discussion:

Relevant code from source/icu.net/NativeMethods/NativeMethods.cs:

https://github.com/sillsdev/icu-dotnet/blob/ec6f567218158553ee14356b5fe60b9d17007ef5/source/icu.net/NativeMethods/NativeMethods.cs#L336

Relevant comment from Slack discussion:

It looks like we always assume non-Windows OSes name their libraries with .so. However, macOS (at least Catalina) uses dylib files, not so files. Also, while we assume the icuuc library would be libicuuc.so.[version], on macOS it looks like the file pattern is libicuuc.[version].dylib. On top of that, I only see icu4c available on macOS if you install Homebrew or build it yourself. (libicuuc is part of the icu4c package)

It looks like #142 was an attempt to fix this issue, but didn't completely solve it.

https://github.com/sillsdev/TheCombine/issues/927 is probably caused by this as well.

imnasnainaec commented 6 months ago

@rmunn I was hoping to try out a fix on my mac: https://github.com/sillsdev/icu-dotnet/compare/master...imnasnainaec:icu-dotnet:mac

...but I'm not sure how to build on/for macOSX to test it out.

(Attempting: https://github.com/sillsdev/icu-dotnet/pull/188)

chrisvire commented 4 months ago

@ermshiperete What is the state of this issue?

imnasnainaec commented 4 months ago

At least for its use in The Combine, the current hurdle is getting icu-dotnet to find my libicuuc. I'm not sure yet whether there's more required from the icu-dotnet side of things or if it's a matter of local setup.

rmunn commented 4 weeks ago

One issue I've discovered is that depending on how you installed icu4c, the installed .dylib files might not be on the standard library search path. Yesterday we tried running brew install icu4c and it installed libicuuc.74.2.dylib (and a libicuuc.74.dylib symlink) into /opt/homebrew/Cellar/icu4c/lib (I think, I'll have to go back and check).

One thing that might help is https://github.com/sickcodes/Docker-OSX which builds off the work done by https://github.com/kholia/OSX-KVM. Running Mac OS in a Docker container might allow automated testing, so we can make sure icu.net can find the libraries in all common install scenarios.

lyonsil commented 3 weeks ago

For Platform.Bible we bundle in the icu4c libraries along with our application builds so we don't have to worry about this. Since OSX doesn't provide them we assume we can't rely on them being anywhere in the path.

imnasnainaec commented 3 weeks ago

For reference, prs #194, #198, #200 were toward resolving this issue.