When attempting to build my .Net 8.0 MAUI application for debugging an iOS 18 simulator on my Mac using VSCode I get the following errors:
Platforms/Android/google-services.json : error : The path '../../../../../../../../../Users/user/MyMauiApp/Platforms/Android/google-services.json' would result in a file outside of the app bundle and cannot be used. [/Users/user/MyMauiApp/MyMauiApp.csproj::TargetFramework=net8.0-ios]
Platforms/Android/google-services.json : error : [/Users/user/MyMauiApp/MyMauiApp.csproj::TargetFramework=net8.0-ios]
I have the file referenced in my .csproj under the android build condition:
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.12.0.4" />
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.0.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.0.1" />
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.8.2.1" />
<GoogleServicesJson Include="Platforms\Android\google-services.json" />
</ItemGroup>
and nowhere else. I've tried excluding it from the iOS build with:
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
<PackageReference Include="Xamarin.Firebase.iOS.Core" Version="8.10.0.3" />
<BundleResource Include="Platforms\iOS\GoogleService-Info.plist" Link="GoogleService-Info.plist" />
<None Remove="Platforms/Android/google-services.json" />
</ItemGroup>
and still get the error. The rest of my team is getting the same error and can't find a way past it. The error does not occur when we build for android using Visual Studio 2022 on a Windows device. I'm not sure what to try next.
Adding the wildcard
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
<Content Remove="**\google-services.json" />
</ItemGroup>
Got past this error for me. It does not work with a forward slash, must use back slash to match windows pathing.