expo / eas-cli

Fastest way to build, submit, and update iOS and Android apps
https://docs.expo.dev/eas/
MIT License
774 stars 81 forks source link

Set Debug Information Format to DWARF with dSYM File during EAS Build for Managed App #968

Closed adamwlev closed 2 years ago

adamwlev commented 2 years ago

Do you understand that any feature requests opened in this repository will be closed?

Yes

adamwlev commented 2 years ago

Hello, I am using EAS Build to build my managed app and I am using a config plugin for @react-native-firebase/crashlytics (https://github.com/invertase/react-native-firebase/tree/main/packages/crashlytics). When I have a crash, firebase asks me to do the following (from here https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=ios&authuser=2):

  1. Open your project in Xcode and select the project file in the Xcode Navigator.
  2. Select your main build target.
  3. Open the target's Build Settings tab, then click All.
  4. Search for "debug information format".
  5. Set Debug Information Format to DWARF with dSYM File for all your build types.
  6. Rebuild your app.

Wondering if this is possible in EAS without ejecting or if anyone has any other suggestions.

kbrandwijk commented 2 years ago

This is possible, as this setting is stored in the xcodeproj file for your project, which can be manipulated through a config plugin. The diff looks something like this:

Screen Shot 2022-02-11 at 06 45 26

For more information on config plugins please have a look at the docs here. The plugin that you can use for this is withXCodeProject, which will give you a nice, object oriented, way to change things in your xcodeproj file.

As this is not a bug with eas-cli, I am going to close this issue. If you have additional questions, feel free to post on the forums or join the Expo Discord (https://docs.expo.dev/next-steps/community/).

adamwlev commented 2 years ago

thanks @kbrandwijk !

adamwlev commented 2 years ago

for those encountering this issue - I ended up just switching to Sentry since it seems easier.

Charles-Johnson commented 2 years ago

It took me a while to work out the required expo config changes from @kbrandwijk's comment (thanks for the insight) so I'll share my solution to save others some time:

Rename app.json -> app.config.js Install @expo/config-plugins e.g. npm install @expo/config-plugins

import { withXcodeProject } from "@expo/config-plugins";

const config = {
  // contents of `expo` object from `app.json`
}
export default withXcodeProject(config, async (nativeConfig) => {
  const xcodeProject = nativeConfig.modResults;
  xcodeProject.debugInformationFormat = "dwarf-with-dsym";
  return nativeConfig;
});
kbrandwijk commented 2 years ago

@Charles-Johnson If you're interested in contributing upstream, maybe you can submit a PR to add it to https://github.com/invertase/react-native-firebase/tree/main/packages/crashlytics/plugin/src, with a parameter to enable/disable this. I'm sure that would be much appreciated seeing that rnfb is quite popular.

Charles-Johnson commented 2 years ago

Good suggestion @kbrandwijk :smile:. I will try forking react-native-firebase and use that parameter next time I need to release.

marcfrankel commented 2 years ago

Hey all, I'm trying to follow along on this thread so I can get the DSYM symbols uploaded to our Firebase crashanalytics. If we implement the config plugin suggested I'm confused about where we would download/access the dsym file after using EAS. Are they just baked into the .ipa file? Or am I completely misunderstanding something.

kbrandwijk commented 2 years ago

I think you can download them from Connect: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=ios&authuser=2#expandable-1

marcfrankel commented 2 years ago

Thanks for the reply @kbrandwijk. I saw that guide on Firebase, but I'm specifically talking about an .ipa build (like not tied to metro) produced through EAS and downloaded onto an iPhone that has been provisioned for it. Do you know of any way to get the dsym files in that scenario?

kbrandwijk commented 2 years ago

I haven't tried this, but isn't there an .xcarchive file when you extract the ipa? Afaik, you can open those on a Mac ('show package contents') and that should give you the dsym files.

marcfrankel commented 2 years ago

Hmmm I don't think that's possible for an .ipa file vs a .app file. See this StackOverflow: https://stackoverflow.com/questions/32379312/can-a-xcarchive-file-be-created-from-a-ipa-file

The reason why I even bring this up is because if I understand what the dsym files are they are generated at build time and tied to a specific build. So to my knowledge, they are generated when using EAS build but then lost when the worker is torn down. Unless I'm missing something or totally misunderstanding, which is more than possible. This stuff is above my pay grade.

kbrandwijk commented 2 years ago

I was reading this question earlier: https://developer.apple.com/forums/thread/42314, about someone asking about internal distribution and if there's any other way to get the dsym files than through Connect, that's where my suggestion came from.

marcfrankel commented 2 years ago

Ah yes, I've come across that thread. I think the main issue is the whole "debug" version of the app. If I make a version of the app meant for simulators that produces a .app version of the iOS app, but building more for release (ie with the EAS ios simulator set to false and developmentClient set to false as well). I have a couple of things to try, but if you have any bright ideas please let me know!

redpandatronicsuk commented 2 years ago

There is a script included with Crahlytics that uploads the dSYMs automatically: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?authuser=3&hl=en&platform=ios#upload-dsyms

It can be run either as a Build Phase in Xcode or as a CLI script after the build has finished. Is it possible to configure EAS to run that script somehow?

kbrandwijk commented 2 years ago

Alright, so here's the missing piece of the puzzle: if you add the following to your eas.json build profile, after making the change described in the config plugin here https://github.com/expo/eas-cli/issues/968#issuecomment-1162881861, then both the dsym files and the .ipa are made available as build artifacts:

"ios": {
  "artifactPath": "ios/build/*"
}

Better yet, it seems that the manual change through the config plugin is not needed. With a clean initialized project, and the specified artifactPath, this already works out of the box!

redpandatronicsuk commented 2 years ago

@kbrandwijk Thanks for your help, I've made the changes to my project, but can't find where to download the dSYMs.

eas.json

{
  "cli": {
    "version": ">= 0.53.1"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "android": {
        "gradleCommand": ":app:assembleDebug"
      },
      "ios": {
        "buildConfiguration": "Debug",
        "artifactPath": "ios/build/*"
      }
    },
    …
}
// app.config.js

import { withXcodeProject } from '@expo/config-plugins';

const config = {
  …
};

export default withXcodeProject(config, async (nativeConfig) => {
  const xcodeProject = nativeConfig.modResults;
  xcodeProject.debugInformationFormat = 'dwarf-with-dsym';
  return nativeConfig;
});

On the EAS build details page, in the logs section Run fastlane, the last few lines are:

$ cd '/Users/expo/Library/Developer/Xcode/Archives/2022-07-04/tsumu 2022-07-04 04.40.27.xcarchive/dSYMs' && zip -r '/Users/expo/workingdir/build/ios/build/tsumu.app.dSYM.zip' *.dSYM
▸   adding: 0423AD18-E594-3ADD-AA43-65BA4063E0C2.dSYM/ (stored 0%)
…
▸   adding: tsumu.app.dSYM/Contents/Info.plist (deflated 52%)
Successfully exported and compressed dSYM file
Successfully exported and signed the ipa file:
/Users/expo/workingdir/build/ios/build/tsumu.ipa

In the Upload artifacts section it says:

Build artifacts: /Users/expo/workingdir/build/ios/build/tsumu.ipa
Archiving artifacts
Uploading build artifact

and nothing about uploading a dSYM file.

On the build details page the Options button only gives me the options Download build and Delete build.

redpandatronicsuk commented 2 years ago

Turns out I had the configuration for the wrong build profile in eas.json, everything works fine now.

Charles-Johnson commented 1 year ago

@redpandatronicsuk I couldn't see artifactsPath documented as a eas.json option. Perhaps it's been deprecated in favour of buildArtifactPaths?

Silthus commented 1 year ago

@redpandatronicsuk I couldn't see artifactsPath documented as a eas.json option. Perhaps it's been deprecated in favour of buildArtifactPaths?

It exists in the source code and seems to be undocumented.