xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.49k stars 515 forks source link

Regression: error : strip exited with code 139 #19157

Open dotMorten opened 1 year ago

dotMorten commented 1 year ago

Please file a feedback ticket with Apple if you run into this issue

See this comment for more information: https://github.com/xamarin/xamarin-macios/issues/19157#issuecomment-2363300980


Steps to Reproduce

  1. Create a new .NET MAUI App (net8 rc2)
  2. Add package Esri.ArcGISRuntime v200.2.0 <PackageReference Include="Esri.ArcGISRuntime" Version="200.2.0" />
  3. Build and deploy to a physical device with XCode 15 installed (This didn't happen with xcode 14)
  4. Observe build error:
    1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.8968-net8-rc2\tools\msbuild\iOS\Xamarin.Shared.targets(2750,3): error : strip exited with code 139

    Note that if you skip step 2, there is no issue. Something about this library causes the stripper to crash.

    Workaround

    Add

    <PropertyGroup >
        <MtouchNoSymbolStrip Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">True</MtouchNoSymbolStrip>
    </PropertyGroup>

This is quite a showstopper for us, as this prevents any of our users from using our nuget packages. We are fairly certain the issue is connected to the XCode 15 upgrade.

Expected Behavior

App builds and deploys.

Actual Behavior

Crash in the stripper

Environment

VS Preview 17.8 p3+remote macos host, or just .NET 8 RC2 commandline on macos with XCode. We have reproduced on multiple machines, Windows and Mac.

Build Logs

1>/usr/bin/ditto /Users/mort5161/Library/Caches/Xamarin/mtbs/builds/MauiApp10/45615ce3ae59fa5d7b49616b08a491ce70088b1a274c6bd0fc1cb4b5a8be76d0/C:/Users/mort5161/.nuget/packages/esri.arcgisruntime.runtimes.ios/200.2.0/framework/ios-arm64/native/ArcGIS-arm64.framework/ /Users/mort5161/Library/Caches/Xamarin/mtbs/builds/MauiApp10/45615ce3ae59fa5d7b49616b08a491ce70088b1a274c6bd0fc1cb4b5a8be76d0/bin/Debug/net8.0-ios/ios-arm64/device-builds/iphone11.6-16.7/MauiApp10.app/Frameworks/ArcGIS-arm64.framework --arch arm64 1>/usr/bin/ditto /Users/mort5161/Library/Caches/Xamarin/mtbs/builds/MauiApp10/45615ce3ae59fa5d7b49616b08a491ce70088b1a274c6bd0fc1cb4b5a8be76d0/C:/Users/mort5161/.nuget/packages/esri.arcgisruntime.runtimes.ios/200.2.0/framework/ios-arm64/native/Runtimecore.framework/ /Users/mort5161/Library/Caches/Xamarin/mtbs/builds/MauiApp10/45615ce3ae59fa5d7b49616b08a491ce70088b1a274c6bd0fc1cb4b5a8be76d0/bin/Debug/net8.0-ios/ios-arm64/device-builds/iphone11.6-16.7/MauiApp10.app/Frameworks/Runtimecore.framework --arch arm64 1>Tool xcrun execution finished (exit code = 139). 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.8968-net8-rc2\tools\msbuild\iOS\Xamarin.Shared.targets(2750,3): error : strip exited with code 139 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.8968-net8-rc2\tools\msbuild\iOS\Xamarin.Shared.targets(2750,3): error :

Example Project (If Possible)

Repro project. Just try and deploy to an iPhone device: MauiArcGISApp1.zip

carljohansen commented 1 month ago

I have created a duplicate Apple feedback ticket (every little helps). But I have to say: surely a behemoth like Microsoft has great high-level contacts at Apple? I bet that an email from one senior manager to another would accomplish more than we lowly developers can.

MichelePannacciTerex commented 3 weeks ago

Well, with Xcode 16.1 I no longer have the problem. strip works as expected.

Jeanjean commented 3 weeks ago

Well, with Xcode 16.1 I no longer have the problem. strip works as expected.

Hmm, I've updated my build pipeline to:

But when running dotnet publish I'm still getting

Optimizing assemblies for size. This process might take a while.
  Tool xcrun execution finished (exit code = 139).

/Users/builder/clone/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/tools/msbuild/iOS/Xamarin.Shared.targets(2848,3): error : strip exited with code 139 [/Users/builder/clone/xxx/xxx.csproj::TargetFramework=net8.0-ios]
/Users/builder/clone/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/tools/msbuild/iOS/Xamarin.Shared.targets(2848,3): error :          [/Users/builder/clone/xxx/xxx.csproj::TargetFramework=net8.0-ios]

What am I missing?

MichelePannacciTerex commented 3 weeks ago

Well, with Xcode 16.1 I no longer have the problem. strip works as expected.

Hmm, I've updated my build pipeline to:

  • Xcode 16.1,
  • .Net SDK 8.0.403 and
  • maui-android & maui-ios workloads version 8.0.403

But when running dotnet publish I'm still getting

Optimizing assemblies for size. This process might take a while.
  Tool xcrun execution finished (exit code = 139).

/Users/builder/clone/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/tools/msbuild/iOS/Xamarin.Shared.targets(2848,3): error : strip exited with code 139 [/Users/builder/clone/xxx/xxx.csproj::TargetFramework=net8.0-ios]
/Users/builder/clone/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/tools/msbuild/iOS/Xamarin.Shared.targets(2848,3): error :          [/Users/builder/clone/xxx/xxx.csproj::TargetFramework=net8.0-ios]

What am I missing?

I'm on .net 9 RC2 and never had this problem building against .net 8.

MichaelAzzer commented 3 weeks ago

Well, with Xcode 16.1 I no longer have the problem. strip works as expected.

Yes it works for me also with .net 9rc2 but it need to restart mac after installing xcode16.1 and set it as default Thank you 😊

dotMorten commented 2 weeks ago

I'm still seeing it with 16.1

activa commented 2 weeks ago

So what's the short term official solution here? A lot of people haven't been able to build production apps on iOS for a month but there's not a single mention of this issue on the MAUI documentation pages.

SaqibS commented 2 weeks ago

Likewise - our app was building fine on .NET 8, but after updating to .NET 9 RC2, with either Xcode 16 or 16.1, we start to see this error.

rolfbjarne commented 2 weeks ago

Here's a repository that can hopefully be used to compile your own strip tool: https://github.com/rolfbjarne/RolfKvinge.StripReplacement.

I might release this on NuGet, but that won't be for a little while at least (until we've released support for Xcode 16.1, which will bring a necessary fix).

alexander-efremov commented 2 weeks ago

@rolfbjarne could you share an instruction to build and use the tool?

@all: does anyone tried to use XCode 16.2 Beta 2?

rolfbjarne commented 2 weeks ago

@rolfbjarne could you share an instruction to build and use the tool?

There are instructions in the README: https://github.com/rolfbjarne/RolfKvinge.StripReplacement#to-build

bwinklesky commented 1 week ago

Giving this issue a bump. Upgraded to XCode 16 and running into this issue.

MichelePannacciTerex commented 1 week ago

Giving this issue a bump. Upgraded to XCode 16 and running into this issue.

Hi, the solution is right above your post. Unfortunately the issue comes from Apple but it is Microsoft here...

ahmad-crossplatform commented 1 week ago

If you have sentry in your project , then removing it will probably fix the issue .

bwinklesky commented 1 week ago

Giving this issue a bump. Upgraded to XCode 16 and running into this issue.

Hi, the solution is right above your post. Unfortunately the issue comes from Apple but it is Microsoft here...

That's not a solution.

activa commented 1 week ago

Hi, the solution is right above your post. Unfortunately the issue comes from Apple but it is Microsoft here...

That's not a solution.

Correct, blaming it on Apple and throwing your hands up in the air is not a solution. It may be an issue in a tool provided by Apple but it doesn't affect Apple so they don't care, nor should they. So it's up to Microsoft to provide a workaround

MichaelAzzer commented 1 week ago

Microsoft is busy in 2024 conference and showing us what's new in Maui with .net 9 but unfortunately only hello world project that works in maui .net 9 😆


From: Philippe Leybaert @.> Sent: Thursday, November 14, 2024 4:23:54 PM To: xamarin/xamarin-macios @.> Cc: Michael Azer @.>; Manual @.> Subject: Re: [xamarin/xamarin-macios] Regression: error : strip exited with code 139 (Issue #19157)

Hi, the solution is right above your post. Unfortunately the issue comes from Apple but it is Microsoft here...

That's not a solution.

Correct, blaming it on Apple and throwing your hands up in the air is not a solution. It may be an issue in a tool provided by Apple but it doesn't affect Apple so they don't care, nor should they. So it's up to Microsoft to provide a workaround

— Reply to this email directly, view it on GitHubhttps://github.com/xamarin/xamarin-macios/issues/19157#issuecomment-2476483878, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADRJJRTLXM6BJOESQB4GSXL2ASW7VAVCNFSM6AAAAABORVD7LSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZWGQ4DGOBXHA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

cleardemon commented 1 week ago

If anyone is building their MAUI iOS app with GitHub Actions, using Microsoft hosted runners, and running into this problem, I have a workaround.

  1. Use @rolfbjarne's build instructions to compile a new version of strip with his fix in (thanks Rolf!)
  2. Copy that output of strip (from external/cctools/build/Release/strip) to your Git repo for your project (e.g., I used a folder macOS-StripHack in the root of the repo).
  3. Amend your workflow to include the following steps (adapt as necessary to your project):
      - name: Setup Xcode
        uses: maxim-lobanov/setup-xcode@v1
        with:
          xcode-version: '16.0'
      - name: Install strip hack (remove if not needed)
        run: |
          cp "$(xcrun -f strip)" "$(xcrun -f strip)"-old
          cp ./macOS-StripHack/strip "$(xcrun -f strip)"
          chmod +x "$(xcrun -f strip)"
      - name: Setup .NET
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: 8.0.403
      - name: Install MAUI
        run: dotnet workload install maui --version 8.0.403
  1. Somewhere near the end of your workflow, add the following (to tidy up):
      - name: Remove strip hack (remove if not needed)
        if: ${{ always() }}
        run: |
          mv -f "$(xcrun -f strip)"-old "$(xcrun -f strip)"

Then run the workflow, and that should be problem solved.

Observations

A major contributor to this failure happening seems to be including Sentry.io in the project, but removing that from production is not viable. That's not to say Sentry itself as it fault, I just don't understand the details enough.

I have not tried using Xcode 16.1, but it seems .NET 8 is not ready for Xcode 16.1 at the time of writing.

This assumes you are building strip on Apple Silicon (since the hosted runners all use M-series chips, too).

I previously made this post with an error in a script, which is noticed after posting and deleted it. This version does work! 😄

codercampos commented 1 week ago

Run into this today. This might be the case for Azure Devops agents too. I'm giving it a try right now.

rolfbjarne commented 1 week ago

Apple might have fixed this for Xcode 16.2, my feedback ticket just got an update:

Please verify this issue with Xcode 16.2 Beta 2 and update your bug report with your results by logging into https://feedbackassistant.apple.com/ or by using the Feedback Assistant app.

Xcode 16.2 Beta 2 (16C5013f)
https://developer.apple.com/download/

If resolved, you can close your feedback by choosing the Close Feedback menu item in the Actions pop-up in Feedback Assistant.

Note: I haven't verified this myself yet, so I can't confirm if it's fixed or not.

codercampos commented 1 week ago

I ran a pipeline in Azure DevOps that implements @rolfbjarne solution. Everything went good.

Here is a sample of the task:

- task: CmdLine@2
  inputs:
    script: |
      git clone --recurse-submodules https://github.com/rolfbjarne/RolfKvinge.StripReplacement
      cd RolfKvinge.StripReplacement
      make
      echo "Will overwrite this file: $(xcrun -f strip)"
      cp external/cctools/build/Release/strip "$(xcrun -f strip)"

Everything went good.

Apple might have fixed this for Xcode 16.2, my feedback ticket just got an update:

Please verify this issue with Xcode 16.2 Beta 2 and update your bug report with your results by logging into https://feedbackassistant.apple.com/ or by using the Feedback Assistant app.

Xcode 16.2 Beta 2 (16C5013f)
https://developer.apple.com/download/

If resolved, you can close your feedback by choosing the Close Feedback menu item in the Actions pop-up in Feedback Assistant.

Note: I haven't verified this myself yet, so I can't confirm if it's fixed or not.

I can test this but I think .NET 8 and 9 are not ready for that Xcode version. We are stuck until then.

EDIT:

Is not available yet in macOS agents. I might download it later though.

carljohansen commented 1 week ago

Apple might have fixed this for Xcode 16.2, my feedback ticket just got an update:

I just built my .NET 9 project with XCode 16.2 Beta 2 and VS 17.12.0. I didn't get the strip error! I was getting it with XCode 16.1.

postalservice14 commented 1 week ago

Is not available yet in macOS agents. I might download it later though.

Azure devops macos-15 vmImage now has XCode 16.2 Beta 2! The docs don't reflect it yet, but you don't need to replace strip any longer when using the following task:

  - script: |
        sudo xcode-select -s /Applications/Xcode_16.2_beta_2.app/Contents/Developer
    displayName: 'Select Xcode 16.2 Beta 2 Release Candidate'
bwinklesky commented 1 week ago
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

MichelePannacciTerex commented 1 week ago
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

error code 139 is a SIGSEV (call for termination) but strip has nothing to in this case.

bwinklesky commented 1 week ago
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

error code 139 is a SIGSEV (call for termination) but strip has nothing to in this case.

What is this error then? It's the same code compiling against version 9 SDK. AOT seems like it would theoretically use strip.

MichelePannacciTerex commented 1 week ago
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

error code 139 is a SIGSEV (call for termination) but strip has nothing to in this case.

What is this error then? It's the same code compiling against version 9 SDK. AOT seems like it would theoretically use strip.

But it's not strip that failing here. Had same exact problem once yesterday. I've deleted the bin and the obj folders then it worked.

rolfbjarne commented 1 week ago
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
11:09:12     Optimizing assemblies for size. This process might take a while.
11:09:36     IL stripping assemblies
11:09:55     Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Xcode 16.2 Beta 2 produces this for me. I assume it's related

error code 139 is a SIGSEV (call for termination) but strip has nothing to in this case.

What is this error then? It's the same code compiling against version 9 SDK. AOT seems like it would theoretically use strip.

I can confirm this has nothing to do with strip, it's an unrelated problem that just looks similar. If you can still reproduce with a clean build as another commenter suggested, please file a new issue and we'll have a look.

IliyanPopov commented 6 days ago
sudo xcode-select -s /Applications/Xcode_16.2_beta_2.app/Contents/Developer

This is simply not the case. I have listed the content of the /applications folder on macos-15. Here are the Xcodes: image

sgreifeneder commented 5 days ago

I ran a pipeline in Azure DevOps that implements @rolfbjarne solution. Everything went good.

Here is a sample of the task:

- task: CmdLine@2
  inputs:
    script: |
      git clone --recurse-submodules https://github.com/rolfbjarne/RolfKvinge.StripReplacement
      cd RolfKvinge.StripReplacement
      make
      echo "Will overwrite this file: $(xcrun -f strip)"
      cp external/cctools/build/Release/strip "$(xcrun -f strip)"

Everything went good.

Apple might have fixed this for Xcode 16.2, my feedback ticket just got an update:

Please verify this issue with Xcode 16.2 Beta 2 and update your bug report with your results by logging into https://feedbackassistant.apple.com/ or by using the Feedback Assistant app.

Xcode 16.2 Beta 2 (16C5013f)
https://developer.apple.com/download/

If resolved, you can close your feedback by choosing the Close Feedback menu item in the Actions pop-up in Feedback Assistant.

Note: I haven't verified this myself yet, so I can't confirm if it's fixed or not.

I can test this but I think .NET 8 and 9 are not ready for that Xcode version. We are stuck until then.

EDIT:

Is not available yet in macOS agents. I might download it later though.

I'm using the quoted Azure DevOps task as a step in a GitHub action (using Xcode 16.1), but I can confirm it's working as well, thanks. I'm not pinning the workload version to 8.0.402 anymore, which has been the previous workaround.

rolfbjarne commented 5 days ago

Apple might have fixed this for Xcode 16.2, my feedback ticket just got an update:

Please verify this issue with Xcode 16.2 Beta 2 and update your bug report with your results by logging into https://feedbackassistant.apple.com/ or by using the Feedback Assistant app.

Xcode 16.2 Beta 2 (16C5013f)
https://developer.apple.com/download/

If resolved, you can close your feedback by choosing the Close Feedback menu item in the Actions pop-up in Feedback Assistant.

Note: I haven't verified this myself yet, so I can't confirm if it's fixed or not.

The test case I used to file the feedback ticket works with Xcode 16.2 beta 2, so as far as I can tell Apple has fixed this, and hopefully it will be included in the final Xcode 16.2 release.

brunck commented 3 days ago

Using Xcode 16.2 beta 2 by setting sudo xcode-select -s /Applications/Xcode_16.2_beta_2.app/Contents/Developer in a Bash script task on Azure DevOps on the macos-15 host worked, and built my iOS app for me without this error.