Closed Jurashikku closed 8 months ago
The type of error is in pathes.
KernLua dll import
LuaLibraryName = "@rpath/liblua54.framework/liblua54"
[DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
internal static extern void luaL_openlibs(lua_State luaState);
But when MAUI build it try load
"@rpath/liblua54.framework/Versions/A/liblua54"
From where this "Versions/A" added?
Workaround (by it's not good, and need understanding where is error in maui linker or in KernLua)
Only one way to fix this by adding trigger to project.
<Target Name="PostBuildMaccatalyst" AfterTargets="PostBuildEvent" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'"> <Copy SourceFiles="$(TargetDir)$(TargetName).app\Contents\Frameworks\liblua54.framework\liblua54" DestinationFolder="$(TargetDir)$(TargetName).app\Contents\Frameworks\liblua54.framework\Versions\A\" /> </Target>
This action after build application copy framework to correct directory.
This is unrelated to the MAUI UI project and tooling. If you build a .NET Mac Catalyst app that doesn't use the MAUI UI toolkit you can replicate that crash. That makes sense because, as you point out, the path points to the wrong library. Extracting the KernLua framework from its library, and the embedded framework file does not have the versions/a path (which also makes sense) so I'm also not sure where that value is coming from, but I don't think it's anything that can be fixed in this project.
It is either most likely going to be within NLua, or xamarin-macios. @rolfbjarne What do you think?
This is unrelated to the MAUI UI project and tooling. If you build a .NET Mac Catalyst app that doesn't use the MAUI UI toolkit you can replicate that crash. That makes sense because, as you point out, the path points to the wrong library. Extracting the KernLua framework from its library, and the embedded framework file does not have the versions/a path (which also makes sense) so I'm also not sure where that value is coming from, but I don't think it's anything that can be fixed in this project.
It is either most likely going to be within NLua, or xamarin-macios. @rolfbjarne What do you think?
I write ticket on NLua/KernLua too. And write all try and analizes of source (CMake and ETC) There was cmakecode
maccatalyst: ./maccatalyst/liblua54.framework/liblua54 ./maccatalyst/liblua54.framework/liblua54: xcodebuild -configuration Release -destination "platform=macOS,variant=Mac Catalyst" -project lua.maccatalyst.xcodeproj -scheme liblua54 SYMROOT=build_maccatalyst/ ditto ./build_maccatalyst/Release-maccatalyst/liblua54.framework/Versions/A/ ./maccatalyst/liblua54.framework/
Witch copy from "Versions/A" to "liblua54.framework" on xcodebuild
All in all, i don't understand where to dig, why ios and macos app try to load Version/A not simple framework folder.
ConsoleApp .net7 work correct and perfect ( in mac and windows)
Lib add by nuget package and where to fine how and why it become native is big question.
mb real question in KernLua shen try link native libe create wrong include path. I will try create something like NativeReference to avoid this error.
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">
<NativeReference Include="$(ProjectDir)libs\macos\liblua54.framework">
<Kind>Framework</Kind>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>
it's crutch but i'll try.
So, i create forks for all products after modding Makefile with adding
ditto ./build_maccatalyst/Release-maccatalyst/liblua54.framework/Versions/A/ ./maccatalyst/liblua54.framework/Versions/A/
it's work correctly.
Now, the real problem (as i understand) that old standart of macos(or xamarin-macos) used common '/name.framework/name' path, but on new maccatalyst(or maui) it try to call '/name.framework/Versions/A/name' .
So where making linking? In Xcode or in MSBuild?
If XCode - so bab, couse all old library stop founding, couse this error. (Some libs dont need update with new os version if they selffull) But all other need wait update Makefile for buildup on prebuild action. (Like some cross platform libs from nuget (KeraLua, for example).
If MsBuild make links, mb simple add somethink like supporting old libs. (Copy '/name.framework/name' to '/name.framework/Versions/A/name' ) - that may works by hand if i copy files to 'appName.app/Frameworks/name.framework/Versions/A/name' app work correct, but drop hash of project and it's not be enable to install on local device (iphone 11, iphone 12 pro max - tests) but can debug in simulator and on mac (MacBook)
Can you zip up and attach liblua54.framework
so I can have a look at it?
Can you zip up and attach
liblua54.framework
so I can have a look at it?
Source or builded lib?
This from /obj/linker_cache/ liblua54.framework.zip
So the problem is that the library gives this location for itself (@rpath/liblua54.framework/Versions/A/liblua54
):
$ otool -l -arch arm64 liblua54.framework/liblua54 | grep LC_ID_DYLIB -A 2
cmd LC_ID_DYLIB
cmdsize 72
name @rpath/liblua54.framework/Versions/A/liblua54 (offset 24)
When we ask the native linker to link in the liblua54 framework, the native linker will look at the LC_ID_DYLIB value in the framework, and then store that in the executable as the location to look for the actual library at runtime.
However, the library isn't located in Versions/A/liblua54
(of the framework), it's in the root directory of the framework (liblua54
).
There are two fixes:
liblua54
library to be where it says it is inside the .framework (in Versions/A/liblua54
).@rpath/liblua54.framework/liblua54
).Looks like option 2. can be accomplished by setting LD_DYLIB_INSTALL_NAME in your Xcode project file: https://developer.apple.com/documentation/xcode/build-settings-reference#Dynamic-Library-Install-Name
In any case, this isn't an issue with MAUI, it's an issue with the LUA framework, so I'm going to close this.
Description
After create clear maui app .net 7 add Lua lib to project ( NLua 1.6.3 ) Run on windows success, but when try run on MacOs run project crash with error Library not loaded: @rpath/liblua54.framework/Versions/A/liblua54
When go to /ClearMauiLuaApp.app/Contents/Frameworks/liblua54.framework/liblua54 - exist but the request path /Versions/A/ - not created so dll not found.
Steps to Reproduce
MacOs (13.6.3) VisualStudio for Mac (17.6.8 (build 400))
var lua = new Lua();
Link to public reproduction project repository
No response
Version with bug
7.0.101
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
macOS
Affected platform versions
MacOs 13.6.3
Did you find any workaround?
Not yet.
Relevant log output