Skip to content

Conversation

@roeyskoe
Copy link
Contributor

@roeyskoe roeyskoe commented Apr 19, 2022

Currently ImGui.NET places native mac dylib to runtimes/osx-universal, which is not a valid location for DllImport to load it.
Imgui.NET 1.87.3 does not work with MacOs, without manually moving the libcimgui.dylib to a correct location.

This pr renamesosx-universal to osx, which works with both Intel and Arm platforms.

See also accepted names for runtimes folders: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json

@miwarnec
Copy link

this currently blocks usage of IMGUI on apple silicon.
fix would be greatly appreciated :)

@roeyskoe roeyskoe changed the title Rename osx-universal to osx Fix native dylib location on Mac Apr 19, 2022
@frenzibyte
Copy link

So far, the osx RID has worked well on both Intel and Apple Silicon platforms, and can confirm that in the approach I noted at veldrid/veldrid-spirv#24. Gonna try testing this and see if it's working on osx as well.

@frenzibyte
Copy link

After testing in a similar manner to veldrid/veldrid-spirv#24, the osx RID also works here on M1, and osx-arm64 is not required.

@roeyskoe
Copy link
Contributor Author

Yes osx should work according to the runtime.json I linked, but it didn't on my machine (M1, Monterey 12.3.1, .NET 6.0.201).

Please tell if just the first commit of this PR works on your machine, it was made with an Intel Mac.

@roeyskoe
Copy link
Contributor Author

Good timing :P

But this raises a question, why did it not work when I tested?

@frenzibyte
Copy link

I would be curious about your way of testing it, can you fill in the steps? for me I just created a local nuget package and referenced it on a fresh project, and the osx RID is working there.

@roeyskoe
Copy link
Contributor Author

That is exactly what I did.
When it didn't work, I just copied the libcimgui.dylib to osx-arm64 in the output directory and then it ran properly.

@frenzibyte
Copy link

As a sanity check, on a fresh console app project, can you reference this package and test with this code:

// See https://aka.ms/new-console-template for more information

using Veldrid.SPIRV;

Veldrid.SPIRV.SpirvCompilation.CompileVertexFragment(Array.Empty<byte>(), Array.Empty<byte>(), CrossCompileTarget.MSL, new CrossCompileOptions());

and see if it finds the native library or not?

@roeyskoe
Copy link
Contributor Author

It does.

But I figured out why osx did not work when I tested.

In the output folder there is projectName.deps.json. In my test project it had a reference to runtimes/osx-universal/native/libcimgui.dylib. Because of that, osx or osx-universal does not work, but osx-arm64 does work.

This does not really make sense in my mind...

@frenzibyte
Copy link

frenzibyte commented Apr 21, 2022

Well, I'm surprised as well, but at least it's discovered now. I think the latest changes can be reverted now and only keep the first two, yeah?

@roeyskoe
Copy link
Contributor Author

Reverted and tested with fully clean project that it works. Its is possible that this may cause small issues with some users when updating, but I think that we can ignore that since clean output directory fixes this.

Thanks @frenzibyte :D

@mellinoe mellinoe merged commit 01da984 into ImGuiNET:master May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants