Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET 8 iOS app build error when using Xamarin.Firebase.iOS.Core NuGet: bitcode_strip: missing argument(s) #19946

Closed
awalker-dsg opened this issue Jan 17, 2024 · 3 comments
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending t/bug Something isn't working

Comments

@awalker-dsg
Copy link

awalker-dsg commented Jan 17, 2024

Description

After updating our app (which targets Android and iOS) from net7.0 to net8.0, we started getting the following error when building for iOS:

Xamarin.Firebase.iOS.Core.targets(216,5): error : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip: missing argument(s) to: -o option
:
Xamarin.Firebase.iOS.Core.targets(216,5): error MSB3073: The command ""$(xcrun -find bitcode_strip)"  -r -o " exited with code 1.

(The full text of the error message can be found at the end of this ticket)

This error was reported as a Xamarin GoogleApisForiOSComponents issue on 29 Oct 2023. However, it was closed in Jan 2024 by the issue's author with the explanation that this sample repo helped solve the issue. However, we tried changes suggested there and it did not fix the issue for us.

Steps to Reproduce

The MAUI test project found at the sample repo link below was created using the VS wizard. It was modified so it only targets iOS, and a reference to Xamarin.Firebase.iOS.Core v8.10.0.3 was added.

Using that sample code, here are the steps to reproduce the issue.

  1. Get the repro project from the link below.
  2. Open the .sln in Visual Studio on a PC
  3. Pair to a Mac so the app can be built for iOS. (The steps to do that are WAY beyond the scope of this write-up.)
  4. Set the build target to Release
  5. Right click on the project and select Properties > iOS > "Bundle Signing" and set the provisioning profile. (Again, that's beyond the scope of this write-up.)
  6. Click on Build > Rebuild Solution
  7. If the problem exists, the build will fail with the error in the description. If fixed, the app builds successfully.

Link to public reproduction project repository

https://github.com/awalker_dsg/MauiApp_StripBitcodeIssue

Version with bug

8.0.3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

This is a iOS app build error, so it's not related to a specific version of iOS.

Did you find any workaround?

Ultimately the error seems to be caused by changes made to address MAUI issue 12863. The error can be traced to this block of code in the Xamarin.Firebase.iOS.Core v8.10.0.3 NuGet's \buildTransitive\Xamarin.Firebase.iOS.Core.targets file:

<Target Name="_FirebaseStripBitcodeFromFrameworksOnWindows"
        Condition="'$(IsMacEnabled)'=='true'">
    <!-- Get the frameworks to strip bitcode -->
    <FindInList 
    CaseSensitive="false"
    List="@(_FrameworkNativeReference)"
    ItemSpecToFind="%(_FrameworkNamesToStripBitcode.Identity)"
    MatchFileNameOnly="True">
    <Output TaskParameter="ItemFound" ItemName="_FrameworksToStripBitcode"/>
    </FindInList>

    <!-- Strip the bitcode from frameworks -->
    <Exec SessionId="$(BuildSessionId)"
        Command="&quot;%24(xcrun -find bitcode_strip)&quot; %(_FrameworksToStripBitcode.Identity) -r -o %(_FrameworksToStripBitcode.Identity)" />

    <CopyFileFromBuildServer 
    SessionId="$(BuildSessionId)" 
    File="%(_FrameworksToStripBitcode.Identity)" 
    TargetFile="%(_FrameworksToStripBitcode.Identity)" /> 
</Target>

We were able to work-around the issue by modifying the Target statement as shown below to skip this target when the target framework is net8:

<Target Name="_FirebaseStripBitcodeFromFrameworksOnWindows"
      Condition="'$(IsMacEnabled)'=='true' AND !$(TargetFramework.Contains('net8'))">

After this change is made, the app builds successfully.

Of course, making local changes to NuGets is less than ideal, so this change (or something similar) needs to be made in the public Xamarin.Firebase.iOS.Core NuGet.

Relevant log output

C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8490\targets\Xamarin.Shared.Sdk.targets(743,3): warning MT7091: The framework C:/Users/xxxx/.nuget/packages/xamarin.firebase.ios.core/8.10.0.3/lib/net6.0-ios15.4/Firebase.Core.resources/GoogleUtilitiesComponents.xcframework/ios-arm64/GoogleUtilitiesComponents.framework is a framework of static libraries, and will not be copied to the app.
"$(xcrun -find bitcode_strip)"  -r -o
C:\Users\xxxx\.nuget\packages\xamarin.firebase.ios.core\8.10.0.3\buildTransitive\Xamarin.Firebase.iOS.Core.targets(216,5): error : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip: missing argument(s) to: -o option
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip input [-r | -m | -l] [-keep_cs] -o output
C:\Users\xxxx\.nuget\packages\xamarin.firebase.ios.core\8.10.0.3\buildTransitive\Xamarin.Firebase.iOS.Core.targets(216,5): error MSB3073: The command ""$(xcrun -find bitcode_strip)"  -r -o " exited with code 1.
@awalker-dsg awalker-dsg added the t/bug Something isn't working label Jan 17, 2024
@drasticactions
Copy link
Contributor

@rolfbjarne What do you think about this? I'm not sure there's any MAUI UI tooling that would influence this.

@rolfbjarne
Copy link
Member

This seems to be an issue for https://github.com/xamarin/GoogleApisForiOSComponents.

You might be able to work around it by redefining the _FirebaseStripBitcodeFromFrameworksOnWindows target in your csproj to do nothing:

<Target Name="_FirebaseStripBitcodeFromFrameworksOnWindows" />

@samhouts samhouts added potential-regression This issue described a possible regression on a currently supported version., verification pending area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer labels Jan 22, 2024
@PureWeen
Copy link
Member

This issue was moved to xamarin/GoogleApisForiOSComponents#646

@dotnet dotnet locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants