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.44k stars 508 forks source link

Is it possible to embed DSYM (folder) in my IPA through Devops build? #17807

Open wouterst79 opened 1 year ago

wouterst79 commented 1 year ago

Introduction

App Store Connect reports crashes in my production app that aren't reported through AppCenter. I see the crashes through XCode => Organizer, but the crashes aren't symbolicated.

I suspect the crashes are related to resource constraints, but I would prefer to see the stack trace before I do a lot of work on a hunch :)

Is it possible to include DSYM in the IPA that is produced through Azure Devops?

Steps to Reproduce

  1. Create an IPA for a Xamarin.iOS app:
- task: XamariniOS@2
  inputs:
    solutionFile: '**/*iOS.sln'
    configuration: '$(BuildConfiguration)'
    buildForSimulator: false
    _packageApp: true_
    runNugetRestore: true

- task: CopyFiles@2
  inputs:
    Contents: '**/*.dSYM/**'
    TargetFolder: '$(Build.ArtifactStagingDirectory)/$(BuildConfiguration)'
    flattenFolders: false

- task: CopyFiles@2
  inputs:
    Contents: '**/*.ipa'
    TargetFolder: '$(Build.ArtifactStagingDirectory)/$(BuildConfiguration)'
    flattenFolders: false

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(BuildConfiguration)'
    ArtifactName: $(BuildConfiguration)
    publishLocation: 'Container'

- task: AppStoreRelease@1
  inputs:
    serviceEndpoint: 'app store'
    appIdentifier: 'xxx'
    appType: 'iOS'
    releaseTrack: 'TestFlight'
    shouldSkipWaitingForProcessing: true
    appSpecificId: 'XXX'
  1. I'm able to then download the DSYM through Build Artifacts: Run => Job => image

I suspect I will be able to symbolicate my crashes through some hoop jumping, but it would be nice if that was done for me by xcode / app store connect instead.

  1. App Store connect reports there are not Symbols in the .ipa (and I have confirmed there is no DSym in the ipa): image

Question

Is it possible to configure this build (through Additional Build Arguments?, or some other step) to include DSYM in my ipa?

rolfbjarne commented 1 year ago

Thanks for the report!

This is rather complicated, because Xcode doesn't actually include the dSYM directory in the .ipa, Xcode writes .symbols files:

Symbols/049B1D6E-B91E-31DF-B6A6-F5FCC5F3CE9B.symbols

and this is a non-documented format that only Xcode knows how to create.

In order to include symbols in the .ipa, we'd have to reverse engineer this file format.

There's a workaround: you can symbolicate crash reports yourself if you have the correct dSYMs on your disk. A quick google found a walkthrough: https://www.skoumal.com/en/how-to-manually-symbolicate-crash-on-apple-platforms/ (I haven't tested this, so I don't know if it's correct, but there are many other guides available).

wouterst79 commented 1 year ago

Thanks for the link - it looks like a much better set of instructions compared to the various articles I had found :)

I had also come across this: https://github.com/xamarin/xamarin-macios/issues/7495#issuecomment-560478166 - perhaps that's a way to turn dsym into .symbols without reverse engineering the file format?

rolfbjarne commented 1 year ago

I had also come across this: #7495 (comment) - perhaps that's a way to turn dsym into .symbols without reverse engineering the file format?

Hm yeah, it seems something like this could work (I haven't tested this):

$ xcrun symbols -noTextInSOD -noDaemon -arch all -symbolsPackageDir path/to/ipa/Symbols path/to/app.dSYM/Contents/Resources/DWARF/app

An .ipa file is just a zip file, so it might be possible to add the symbols to the ipa we create by doing something like this (also untested):

mkdir Symbols
for dsym in path/to/*.dSYM/Contents/Resources/DWARF/*; do
    xcrun symbols -noTextInSOD -noDaemon -arch all -symbolsPackageDir ./Symbols $dsym
done
zip -9r path/to/app.ipa Symbols

References:

wouterst79 commented 1 year ago

That's pretty awesome - thanks!