Search code examples
visual-studio-codemauisqlite-net-pcl

Can't Build/Deploy .NET(8) MAUI app with sqlite-net-sqlcipher (1.9.172) using VS Code for Mac


I am unable to build or deploy my .NET 8 MAUI app using sqlite-net-sqlcipher (1.9.172) in Visual Studio Code for Mac. I am targeting the iOS Simulator, but the build fails with linker errors. Below are the details:

Steps to Reproduce:

  • Created a new .NET MAUI project.
  • Added the sqlite-net-sqlcipher NuGet package (version 1.9.172).
  • Tried building the project for the iOS Simulator.
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8316/targets/Xamarin.Shared.Sdk.targets(1648,3): error : clang++ exited with code 1: [/Users/user1/Desktop/MauiApp1/MauiApp1/MauiApp1.csproj::TargetFramework=net8.0-ios]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8316/targets/Xamarin.Shared.Sdk.targets(1648,3): error : ld: building for 'iOS-simulator', but linking in object file (/Users/user1/Desktop/MauiApp1/MauiApp1/obj/Debug/net8.0-ios/iossimulator-arm64/linker-cache/e_sqlcipher.a[arm64][2](sqlite3.o)) built for 'iOS' [/Users/user1/Desktop/MauiApp1/MauiApp1/MauiApp1.csproj::TargetFramework=net8.0-ios]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8316/targets/Xamarin.Shared.Sdk.targets(1648,3): error : clang++: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/user1/Desktop/MauiApp1/MauiApp1/MauiApp1.csproj::TargetFramework=net8.0-ios]

Environment .

  • NET SDK: 8.0.302

  • Xcode: Latest version.(16.1)

  • VS Code: Latest version(1.95.3)

  • .NET MAUI Extension : Latest Version(v1.5.34)

How can I properly configure my sqlite-net-sqlcipher integration to build and deploy the app to the iOS Simulator? Is there a workaround or additional step I need to follow?

Any help would be appreciated!


Solution

  • Seems related to this issue with VS code

    In your case adding this to your csproj should solve the issue

    <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
       <RuntimeIdentifier>iossimulator-arm64</RuntimeIdentifier> 
    </PropertyGroup>