Finally, I have found the solution. You can refer to here: https://stackoverflow.com/questions/78018090/maui-clang-error-no-such-file-or-directory-when-build-ios-project.
MAUI clang: error: no such file or directory when build iOS Project
I Create a MaUI project, and edit Project Properties -> Build -> Additional arguments
-cxx -gcc_flags "-L${ProjectDir}/lib -lopencv_world490, -force_load ${ProjectDir}/lib/libopencv_world490.a"
When build, it occurs error as follows:
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.7132/targets/Xamarin.Shared.Sdk.targets(3,3): Error: clang++ exited with code 1:> clang: error: no such file or directory: '${ProjectDir}/lib/libopencv_world490.a'
I also put the lib folder inside three places inside project, it can not work.
2 answers
Sort by: Most helpful
-
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,416 Reputation points Microsoft External Staff
2024-02-22T04:44:13.9+00:00 Hello,
There is a duplicated thread on SO - xamarin.forms - MAUI clang: error: no such file or directory when build iOS Project - Stack Overflow, and you raised an issue at GitHub- using C/C++ library for iOS in maui project · Issue #20136 · xamarin/xamarin-macios · GitHub
Please follow the rolfbjarne 's comment and use
$(MSBuildProjectDirectory)
instead of${ProjectDir}
. For the further questions, you could continue to follow the progress at GitHub.
Update
Solution from Junior Jiang
I have found a solution to build successfully, however there will be new problem to use the method from .a library.
https://github.com/xamarin/xamarin-macios/issues/20136
Finally, we have found the cause that the .a can not be used. No matter what, replace {PrjectDir}/lib with (MSBuildProjectDirectory)/Platforms/iOS/lib works for me.
This solution based on the lib folder inside Platforms/iOS.
And if the .a related to other resource files, you will need to add these files(such as: .bundle) inside Resources/raw.
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.