Closed angelru closed 4 months ago
just edit the macOS Makefile to include the necessary flags for catalyst and you'll get a fat binary to use for the catalyst platform.
just edit the macOS Makefile to include the necessary flags for catalyst and you'll get a fat binary to use for the catalyst platform.
but in which line do I add this?
clang -target x86_64-apple-ios-macabi \
-arch arm64 -arch x86_64 \
-isysroot `xcrun --sdk macosx --show-sdk-path` \
-miphoneos-version-min=13.0 \
-fembed-bitcode \
main.c
try changing
CC= gcc
ARCH_FLAGS= -m32
to
CC= clang
ARCH_FLAGS= -target x86_64-apple-ios-macabi -arch arm64 -arch x86_64 -isysroot `xcrun --sdk macosx --show-sdk-path` -miphoneos-version-min=13.0 -fembed-bitcode
but you'll have to play around with it yourself a bit
@angelru could you please help me to understand the root cause of this issue by providing more high-level description of your problem? By high-level I mean:
@jariq Hello, the application compiles and works with Xamarin.macOS but when creating it with .NET MAUI I get this error:
ld: building for Mac Catalyst, but linking in dylib built for macOS, file 'obj/Debug/net6.0-maccatalyst/maccatalyst-x64/nativelibraries/libempty-pkcs11-x64.dylib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The app runs on windows desktop and mac.
try changing
CC= gcc ARCH_FLAGS= -m32
to
CC= clang ARCH_FLAGS= -target x86_64-apple-ios-macabi -arch arm64 -arch x86_64 -isysroot `xcrun --sdk macosx --show-sdk-path` -miphoneos-version-min=13.0 -fembed-bitcode
but you'll have to play around with it yourself a bit
Thanks, but this keeps generating the same file for me.
@mmoraga @jariq I can't get it to compile a .NET MAUI application, can you help me?
@angelru I was trying to replicate your issue in my environment over the weekend and ended up with MAUI app working on Windows and not building on macOS. Up until now I didn't have enough time to analyze why it's not building. I don't when I'll be able to continue.
@jariq Indeed, on windows it works fine, but on macOS this warning appears:
ld: building for Mac Catalyst, but linking in dylib built for macOS, file 'obj/Debug/net6.0-maccatalyst/maccatalyst-x64/nativelibraries/libempty-pkcs11-x64.dylib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It seems that libempty-pkcs11-x64.dylib
needs to be generated for Mac Catalyst
, but I haven't been able to.
I managed to get it to build by editing the Makefile ARCH flags to:
ARCH_FLAGS= -target x86_64-apple-ios14.8-macabi -arch arm64 -arch x86_64 -isysroot `xcrun --sdk macosx --show-sdk-path` -miphoneos-version-min=14.8 -fembed-bitcode
then building a minimal maccatalyst project succeeded:
% dotnet build
MSBuild version 17.3.0+92e077650 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
Detected signing identity:
Bundle Id: com.companyname.catalyst_pkcs
App Id: com.companyname.catalyst_pkcs
catalyst-pkcs -> /Users/manuel.moraga/Documents/catalyst-pkcs/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/catalyst-pkcs.dll
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:03.94
PR is here: https://github.com/Pkcs11Interop/empty-pkcs11/pull/3
I managed to get it to build by editing the Makefile ARCH flags to:
ARCH_FLAGS= -target x86_64-apple-ios14.8-macabi -arch arm64 -arch x86_64 -isysroot `xcrun --sdk macosx --show-sdk-path` -miphoneos-version-min=14.8 -fembed-bitcode
then building a minimal maccatalyst project succeeded:
% dotnet build MSBuild version 17.3.0+92e077650 for .NET Determining projects to restore... All projects are up-to-date for restore. Detected signing identity: Bundle Id: com.companyname.catalyst_pkcs App Id: com.companyname.catalyst_pkcs catalyst-pkcs -> /Users/manuel.moraga/Documents/catalyst-pkcs/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/catalyst-pkcs.dll Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink Build succeeded. 0 Warning(s) 0 Error(s) Time Elapsed 00:00:03.94
PR is here: #3
Can you show the csproj file?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-maccatalyst</TargetFramework>
<RuntimeIdentifier>maccatalyst-x64</RuntimeIdentifier>
<RootNamespace>catalyst_pkcs</RootNamespace>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<SupportedOSPlatformVersion>14.2</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<NativeReference Include="libempty-pkcs11-catalyst.dylib">
<Kind>Dynamic</Kind>
<IsCxx>False</IsCxx>
</NativeReference>
</ItemGroup>
</Project>
It works very well!
@mmoraga @jariq https://github.com/Pkcs11Interop/Pkcs11Interop/issues/215
It seems that with the new versions of .NET it does not connect with the token, did you get an error?
@mmoraga Compile compiles and before it worked but now it doesn't, does it work for you?
I don't actually use maccatalyst so I don't really know.
@mmoraga Would you mind trying? see if you see anything?
here I put the error:
@mmoraga @jariq I understand that there is no solution for now right?
is there news?
Nope. I am not currently working on anything MAUI or maccatalyst related.
Since 11586bed134d5034b6d75c7013948f33fc444c49 the macOS version of empty-pkcs11 library is built for both x86_64-apple-macos10.12
and arm64-apple-macos11
targets and then merged into a single Mach-O universal binary (empty-pkcs11.dylib
) usable on both Apple silicon and Intel-based Mac computers. This version is also working in a Catalyst app on macOS so I am closing this issue now.
Unresolved Pkcs11Interop related problems with Catalyst apps will be further discussed in https://github.com/Pkcs11Interop/Pkcs11Interop/issues/215
Hello,
I can't get your library to work for MacCatalyst
More info: https://github.com/dotnet/maui/issues/9808 https://github.com/xamarin/xamarin-macios/issues/15044