Skip to content

AppStore Distribution / Release app does not send crashes due to Exported Symbols File missing __mh_execute_header #5020

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

Closed
kondratk opened this issue Mar 4, 2020 · 41 comments

Comments

@kondratk
Copy link

kondratk commented Mar 4, 2020

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 11.3.1
  • Firebase SDK version: Firebase/Crashlytics (6.15.0):
  • Firebase Component: Crashlytics
  • Component version: 4.0.0-beta.4
  • Installation method: CocoaPods (select one)

[REQUIRED] Step 2: Describe the problem

We've identified, that after signing the app with AppStore certificate, Firebase Crashlytics stops working. The problem does not occur while signing the app with AdHoc certificate. We are using Apple Distribution Certificate.

The errors we've found in the console:
<Forced crash, re-ran the app>
[Firebase/Crashlytics] Version 4.0.0-beta.4
..
[Firebase/Crashlytics][I-CLS000000] An application must have a valid bundle identifier in its Info.plist
[Firebase/Crashlytics][I-CLS000000] Crash reporting could not be initialized
[Firebase/InstanceID][I-IID003014] Error while reading embedded mobileprovision Error Domain=NSCocoaErrorDomain Code=260 "The file “embedded.mobileprovision” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/private/var/containers/Bundle/Application/71738F66-30A3-4D4E-A60E-85F7FB3614AC/X.app/embedded.mobileprovision, NSUnderlyingError=0x282bc5b00 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

I've unzipped the ipa file and:

  • there is Info.plist, it contains bundle identifier
  • there is mobileprovision file, looks good.

The app would not even run without files above, so these errors seems like incorrect ones.

Steps to reproduce:

  1. Build the app with AdHoc profile, force a crash - works fine. Crashes are sent to Crashlytics.
  2. Build the app with AppStore profile, distribute via testflight.
  3. Install it from TestFlight, run, force a crash
  4. Re-open the app. Crash should be sent- it is not. Check out logs:
  5. Errors from Step 2 are visible.
@JayachandraA
Copy link

Crashlytics, I'm also experiencing same problem. This is sending me the crash report in debug mode, but when I use signing the build and push to TestFlight it is not sending me the report.

@yasirmturk
Copy link

Same here 👎

@SeeTheInvisible
Copy link

We also have the same problem

@terenceyan
Copy link

terenceyan commented Mar 10, 2020

Also, seeing the same issue with an app not using CocoaPods installation. Using Firebase/Crashlytics (6.16.0).

@yasirmturk
Copy link

I have tried with both pods and with static framework linking using 6.18.0

@samedson
Copy link
Contributor

samedson commented Mar 10, 2020

For others with the same issue, are you seeing the same log from Crashlytics and InstanceID? Eg:

[Firebase/Crashlytics][I-CLS000000] An application must have a valid bundle identifier in its Info.plist
...
[Firebase/InstanceID][I-IID003014] Error while reading embedded mobileprovision Error Domain=NSCocoaErrorDomain Code=260 "The file “embedded.mobileprovision” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/private/var/containers/Bundle/Application/71738F66-30A3-4D4E-A60E-85F7FB3614AC/X.app/embedded.mobileprovision, NSUnderlyingError=0x282bc5b00 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

Crashlytics gets the app's bundle identifier using [[NSBundle mainBundle] bundleIdentifier] - this seems to be returning empty.

@samedson samedson self-assigned this Mar 10, 2020
@samedson
Copy link
Contributor

If this is happening with both Firebase 6.15.0 and 6.18.0, it seems unlikely a code change caused this to happen, since many apps have successfully released to the App Store in that timeframe with Crashlytics. I'm trying to figure out what could have changed with Apple's signing that would cause this. It seems like files in general can't be opened from Crashlytics and InstanceID.

  • Are there other errors in the logs that indicate an issue with opening files?
  • Does anyone's app successfully read from the bundle identifier, but see Crashlytics fail to?

@kondratk
Copy link
Author

@samedson we are using [[NSBundle mainBundle] bundleIdentifier] in our app, and the method seems like working fine. Only Crashlytics has difficulties with accessing this identifier.

@kondratk
Copy link
Author

@samedson

  • Are there other errors in the logs that indicate an issue with opening files?

Haven't found any additional errors.

  • Does anyone's app successfully read from the bundle identifier, but see Crashlytics fail to?

We are reading other files like translations of third party SDK's, so access is working fine. Also getting [[NSBundle mainBundle] bundleIdentifier] works as expected.

@samedson
Copy link
Contributor

samedson commented Mar 11, 2020

Want to ask a few more questions. I still haven't determined the root cause of the issue - wondering if maybe something changed with the timing of calling [NSBundle mainBundle] in iOS.

  • How are you initializing Firebase? Is it with a call to [FIRApp configure] in the App Delegate?
  • Was there some point where Crashlytics stopped working in new versions of your app, or is this the first time you've tried to ship with Crashlytics?
  • What is your CocoaPods configuration?

@terenceyan
Copy link

terenceyan commented Mar 13, 2020

@samedson

How are you initializing Firebase? Is it with a call to [FIRApp configure] in the App Delegate?

Yes

Was there some point where Crashlytics stopped working in new versions of your app, or is this the first time you've tried to ship with Crashlytics?

A new app under development but on TestFlight.

What is your CocoaPods configuration?

Not using CocoaPods.

@kondratk
Copy link
Author

kondratk commented Mar 18, 2020

@samedson

  • How are you initializing Firebase? Is it with a call to [FIRApp configure] in the App Delegate?

FirebaseApp.configure() in App Delegate

  • Was there some point where Crashlytics stopped working in new versions of your app, or is this the first time you've tried to ship with Crashlytics?

We've just tried to migrate from Fabric SDK to Firebase SDK. There were no issues with Fabric SDK, so we've migrated back. Today I've received an email from Google that Fabric services will be held up and running until early May.

  • What is your CocoaPods configuration?
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Analytics'

@kondratk
Copy link
Author

Seems like that issue is connected to this one (also problems with bundle context):
#5092

@samedson
Copy link
Contributor

Apologies, but I'm unable to reproduce the issue. Could you provide a project that reproduces the issue (if I build it for App Store distribution)?

@samedson
Copy link
Contributor

samedson commented Mar 20, 2020

From #5092, can you try setting FirebaseAppDelegateProxyEnabled to NO in your Info.plist and manually implement the delegate methods, to see if that resolves the issue?

@Hans92
Copy link

Hans92 commented Apr 9, 2020

I'm getting exactly the same error:

6.21.0 - [Firebase/Crashlytics][I-CLS000000] An application must have a valid bundle identifier in its Info.plist
6.21.0 - [Firebase/Crashlytics][I-CLS000000] Crash reporting could not be initialized
6.21.0 - [Firebase/InstanceID][I-IID003014] Error while reading embedded mobileprovision Error Domain=NSCocoaErrorDomain Code=260 "The file “embedded.mobileprovision” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/private/var/containers/Bundle/Application/6AB4F02F-538A-4D3D-A29F-99FB98CE2532/XXX.app/embedded.mobileprovision, NSUnderlyingError=0x281964090 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

@samedson
Copy link
Contributor

samedson commented Apr 9, 2020

@Hans92 from #5092, have you tried setting FirebaseAppDelegateProxyEnabled to NO in your Info.plist and manually implement the delegate methods, to see if that resolves the issue?

@Hans92
Copy link

Hans92 commented Apr 10, 2020

FirebaseAppDelegateProxyEnabled is set to NO. I thought that it could be caused by different Info.plistfilename, but nope, it's not that.

How can I debug this and help you find the cause?

@pmfon
Copy link

pmfon commented Apr 13, 2020

Seeing the same issue with Firebase/Crashlytics 6.22.0. In fact, we’re seeing this with enterprise builds too. This seems to happen with any build with a Release configuration.

@samedson
Copy link
Contributor

samedson commented Apr 13, 2020

Some ways folks can help cc @Hans92:

  • Posting an Xcode project that reproduces the issue. You can also reach out to support and send via that channel.
  • Before and after Firebase Initialization, printing the bundlepath in a project that reproduces the issue
  • Trying out other configurations or code setups to see if the issue can be resolved

Questions still remaining:

  • @pmfon (and others) when you build in Release, but don't ship to TestFlight / App Store / Enterprise, do you see the same logs, An application must have a valid bundle identifier in its Info.plist? You can do this by going to "Edit Scheme" and updating the Run "Build Configuration" to "Release" or "App Store"?
  • Do folks here have an AppDelegate (or other shared app code) that gets pulled in via a framework by chance? This issue seemed to indicate there were problems with that: [FIRApp configure] changes context of AppDelegate bundle #5092

Notes thus far:

  • I've tried reproducing this with an app using Cocoapods and Xcode 11.3.1, but did not reproduce the issue.
  • Firebase versions affected: 6.15.0, 6.18.0, 6.22.0
  • Seems that this is an issue regardless of whether Cocoapods or the manually-installed frameworks are used
  • This code has been in Crashlytics for years (even the Fabric version pre 4.0.0-beta.1 release). At this time I don't believe a change in Crashlytics caused this issue, but it's possible there is code in FirebaseCore or another dependency that is causing this. I don't believe removing the check for bundle ID will resolve this as Crashlytics uses the bundle ID for many other things.

Digging into the code, here's where this check is:

@paulb777
Copy link
Member

One solution to "The file “embedded.mobileprovision” couldn’t be opened because there is no such file at https://stackoverflow.com/a/43473088/556617

@pmfon
Copy link

pmfon commented Apr 15, 2020

@samedson
I think it fails at an earlier point. The FIRCLSApplicationIdentifierModel initialiser might return nil. That would cause the An application must have a valid bundle identifier in its Info.plist message.

We were able to reproduce this in the simulator with a release configuration.

@pmfon
Copy link

pmfon commented Apr 15, 2020

A bit more detail, the dlsym call here is returning NULL

executableSymbol = dlsym(RTLD_MAIN_ONLY, MH_EXECUTE_SYM);

@samedson
Copy link
Contributor

Great find @pmfon - now to figure out why this will fail in App Store signed apps. Going to do some research

@pmfon
Copy link

pmfon commented Apr 16, 2020

Great find @pmfon - now to figure out why this will fail in App Store signed apps. Going to do some research

Here’s what we found so far

  • the difference seems to be between debug and release versions (not necessarily signed, since it can be reproduced in the simulator)
  • disabled striping in the release build and the symbol still can’t be found though it’s in the binary if you check with ‘nm’
  • only changed the main project settings, the Pods configs were not touched
  • calling dlsym from the AppDelegate has the same effect
  • the legacy SDK (integrated with CocoaPods), with the same project configuration, works

@samedson
Copy link
Contributor

Huh I still can't get it to happen on my end - I'm running in "Release" configuration in my Scheme, and have stripping on, but it doesn't reproduce the issue. Hoping to narrow it down to a few settings.

Would you be able to export the build settings that reproduce this (removing any PII - I see bundle IDs and paths in there)?

cd <your-project-directory>
xcodebuild -scheme "<your-app-scheme>" -showBuildSettings

@Hans92
Copy link

Hans92 commented Apr 17, 2020

What about the configuration name? I don't use default Debug and Release names but Debug, Release-AppStore and Release-AdHoc.

@samedson
Copy link
Contributor

Right now the main thing that will help me debug this is an xcode project that reproduces the issue.

I don't feel confident in shipping a fix without being able to reproduce the issue because that dlsym call that's returning NULL is important for the Crashlytics SDK to function - skipping the call or some other workaround will cause other negative side effects.

I did try out duplicating the Release configuration with a new name, but did not reproduce the issue.

@pmfon
Copy link

pmfon commented Apr 18, 2020

@samedson
Found it. The project sets Exported Symbols File in Release builds. This file is empty.

@samedson
Copy link
Contributor

samedson commented Apr 20, 2020

That seems to be the problem @pmfon. Reproduced it locally!

Can you try adding __mh_execute_header as a new line to your Exported Symbols File? That fixes the issue in the quickstart.

Going to work on logging help customers address this issue.

@samedson samedson changed the title AppStore Distribution signed app does not send crashes AppStore Distribution / Release app does not send crashes due to Exported Symbols File missing __mh_execute_header Apr 20, 2020
@samedson
Copy link
Contributor

Gonna close this for now - but feel free to reopen if the following fix doesn't work for you. I've added logging in the SDK to give a clearer error message when this happens.

Fix

For those running into this issue, the fix is:

  • Find the "Exported Symbols File" setting in your Xcode Build Settings
  • Open the file that's set for that
  • Add __mh_execute_header as a newline to that file

@Hans92
Copy link

Hans92 commented Apr 23, 2020

@samedson what if I don't have anything in Exported Symbols File and this field is blank?

@morganchen12
Copy link
Contributor

@Hans92 from what I understand that means your build process is not exporting a symbols file. You should set a filepath in the field in Xcode, and Xcode will generate an exported symbols file there when you build your app.

@Hans92
Copy link

Hans92 commented Apr 24, 2020

A newly created project with Xcode 11.3.1 has nothing in Exported Symbols File. Should I create this file somewhere?

@terenceyan
Copy link

This doesn't make any sense.

I have several projects that uses Firebase. Only two are affected by this problem, but none of the projects use an Exported Symbols File.

I've created a new project that's effectively an empty app with Firebase SDK integrated, with no Exported Symbols File set and it's reporting crashes just fine.

@samedson
Copy link
Contributor

Let me clarify:

  • Crashlytics does not require the Exported Symbols File build setting. Your app will work without it. But if you do set that build setting (for some other reason), you must add __mh_execute_header to the file.
  • The current understanding is this GitHub issue only impacts apps that have set Exported Symbols File, and do not add __mh_execute_header to it.
  • If you're finding that your app is impacted by this issue, as indicated by the following log, we need to investigate further and see if there are other build settings that could be causing it.
[Firebase/Crashlytics][I-CLS000000] An application must have a valid bundle identifier in its Info.plist

@Hans92
Copy link

Hans92 commented Apr 24, 2020

The project related to this issue has nothing in the Exported Symbols File

@kondratk
Copy link
Author

Unfortunately, the issue still exists. The same as @Hans92 I don’t use exported symbols file.

@morganchen12
Copy link
Contributor

@kondratk and @Hans92 are you seeing

[Firebase/Crashlytics][I-CLS000000] An application must have a valid bundle identifier in its Info.plist

in your app's logs? We're currently experiencing a delay in crash processing which may be causing crashes to not appear in console that's unrelated to this issue.

Googlers see outage number 19770

@pmfon
Copy link

pmfon commented Apr 26, 2020

@kondratk @Hans92 the issue could be caused by another build setting or flag which strips that symbol from the binary, such as 'fvisibility' or 'Symbols hidden by default' (or even a run-script phase from another framework). Note that I've never found the 'embedded.mobileprovision' error in my logs.

@Hans92
Copy link

Hans92 commented Apr 27, 2020

Symbols hidden by default has a default value in my project.

@firebase firebase locked and limited conversation to collaborators May 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests