firebase-ios-sdk: Xcode 12 GM Archive Error SPM - unexpected Mach-O header code: 0x72613c21
[REQUIRED] Step 1: Describe your environment
- Xcode version: Xcode 12 GM (12A7208)
- Firebase SDK version: 6.32-spm-beta
- Firebase Component: Analytics
- Component version: 6.32
- Installation method: Swift Package Manager
[REQUIRED] Step 2: Describe the problem
When trying to upload an archive to App Store connect Xcode 12 GM gives me the following error:
Found an unexpected Mach-O header code: 0x72613c21
If I change my build configuration to development the app builds and runs fine but if I switch to a release configuration and try to run the app on the latest iOS 14 iPhone 11 Pro simulator I get the following error:
Undefined symbol: _OBJC_CLASS_$_FIRAnalytics
and the following warnings:
missing required architecture arm64 in file /Users/neil/Library/Developer/Xcode/DerivedData/Kantinebaas-gnwjztsimxavkscwhhoheneylhus/Build/Products/Alpha-iphonesimulator/FirebaseAnalytics.framework/FirebaseAnalytics
missing required architecture arm64 in file /Users/neil/Library/Developer/Xcode/DerivedData/Kantinebaas-gnwjztsimxavkscwhhoheneylhus/Build/Products/Alpha-iphonesimulator/FIRAnalyticsConnector.framework/FIRAnalyticsConnector
missing required architecture arm64 in file /Users/neil/Library/Developer/Xcode/DerivedData/Kantinebaas-gnwjztsimxavkscwhhoheneylhus/Build/Products/Alpha-iphonesimulator/GoogleAppMeasurement.framework/GoogleAppMeasurement (2 slices)
Steps to reproduce:
Archive and try to submit project with a release build configuration using Xcode 12 GM with Firebase analytics added to the project using SPM.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 45
- Comments: 160 (38 by maintainers)
Links to this issue
Commits related to this issue
- Add archive post-action script to remove extra copies of Sparkle.framework https://github.com/firebase/firebase-ios-sdk/issues/6472 https://forums.swift.org/t/swift-package-binary-framework-issue/419... — committed to XcodesOrg/XcodesApp by interstateone 3 years ago
- SPMTest - add post-action to build step that removes libKountDataCollector.a in order to avoid symbols error when uploading See https://github.com/firebase/firebase-ios-sdk/issues/6472#issuecomment-6... — committed to braintree/braintree_ios by sestevens 3 years ago
- SPM archive/upload work-arounds (#600) * SPMTest - add post-action to build step that removes libKountDataCollector.a in order to avoid symbols error when uploading. See https://github.com/firebase/f... — committed to braintree/braintree_ios by sestevens 3 years ago
- Fix nasty Xcode 12 SPM bug by using this fix (Firebase SPM package was culprit): https://github.com/firebase/firebase-ios-sdk/issues/6472#issuecomment-694449182 — committed to OpenZesame/Zhip by Sajjon 3 years ago
- đ Build script to prevent archive upload issues https://github.com/firebase/firebase-ios-sdk/issues/6472 — committed to CovidTrackerFr/vitemadose-ios by victor-sarda 3 years ago
- đ Build script to prevent archive upload issues https://github.com/firebase/firebase-ios-sdk/issues/6472 — committed to CovidTrackerFr/vitemadose-ios by victor-sarda 3 years ago
As of Xcode version 12.4, I have verified following script eliminates this issue when added to âPost-actionsâ phase of âArchiveâ. It removes all static frameworks as some people are experiencing issues due to unrelated frameworks.
I was able to get a variation of @dinâs suggested workaround to work for me:
Add the following to the Schemeâs Build Post-Action:
Make sure to select Provide build settings from the app.
I can archive its when I try to upload to the App Store I get the
Found an unexpected Mach-O header code: 0x72613c21error. The other error was when I tried to run it on a simulator.The mentioned above Build scheme post-actions didnât help in my case, so I did a bit differently, maybe it will help someone as well:
I added the following script in the post-actions of Archive scheme:
Unexpected Mach-O header code: 0x72613c21 is still an issue on Xcode 12.3 beta. In my case, the Post-Action workaround worked well.
Here are the steps to follow, in case someone is still having issues:
Show in FinderShow Package ContentsProducts > Applicationsand then right click onYourApp.apptoShow Package ContentsFrameworksFirebaseAnalytics.frameworkandGoogleAppMeasurement.frameworkManage schemes > Edit scheme, then underBuild, selectPost-actions. Make sure to checkProvide build settings from -> YourApp.run scriptPost-action with the following:Generate a new Archive. It should validate now.
p.s. In step 4, you can actually delete the frameworks manually from Finder, then go back to Organizer and click
Validate. This is a quick way to test whether youâre deleting the right frameworks to bypass the Mach-O error.Just to throw another option into the list 𤣠I modified the example from @surajbarkale to work as a script build-phase instead of a scheme post-build action so that it applies regardless of build scheme. The issue would apply to debug builds too itâs just Xcode doesnât complain about it so seems valid to perform the stripping of the static frameworks for all builds.
I put this as my last build phase.
Also, I can confirm this workaround is fixed and no longer required in Xcode 12.5 (12E5220o) đ
Confirmed that this issue is fixed in the public version of Xcode 12.5. đ
Thank you everyone for your patience and helping out with workarounds! If you did add a workaround for your project, itâs probably best to remove it to ensure it doesnât cause any issues in the future.
great help this worked just right.
I tried with Xcode 12.3 beta 1 release today and the
.frameworkfiles are still embedded. Hopefully this gets resolved in this cycle of betas.The answer posted by @paulb777 initially worked for me. But after I added a widget extension to my app, I started getting the same error again when uploading to the app store.
After digging into the .xcarchive files of the successfully uploaded and the failed uploads, it seems that XCode adds a new
PlugInsdirectory to the archive if you add a widget with the same Firebase frameworks in that directory, so I had to remove the Firebase frameworks from thePlugInsdirectory in addition toFrameworks.There might be other reasons the
PlugInsdirectory shows up in your archive.So hereâs my post-script:
Now it uploads to the App Store! Hopefully this helps.
Tested on Xcode 12.5 beta (12E5220o) and this doesnât seem to be an issue anymore. Iâve only tested with a basic iOS app with no extensions and got the archive successfully validated.
Issus still there with Xcode 12.3.
Xcode version: 12.3 (12C33) Firebase SDK version: 7.3.0 Firebase Components: Analytics, Crashlytics Component version: 7.3.0 Installation method: Swift Package Manager
If your project has Watch extension as well, you need to delete Firebase frameworks from
Watchfolder, too. Here is my script which works for this scenario.Firebase using SwiftPM is definitely the hackiest approach you can take đ
Hereâs an yet unreleased blog post how we explain our SwiftPM integration: https://pspdfkit.com/blog/2020/binary-frameworks-as-swift-packages/ - will become a public URL in a few days but Iâm ok with sharing it early here if it helps.
We use dynamic frameworks only, not statics, and the above radar has been fixed in the GM. Let me know if that helps, happy to share more to get Firebase across to SwiftPM! I also know the SwiftPM maintainer if we need further help.
Changing TARGET_NAME to PRODUCT_NAME worked splendidly for me. I guess it might not work for everyone depending on your project-settings, but if Iâm not mistaking it is the Xcode default.
Unfortunately this issue still reproduces in the 12.3 RC released today.
Confirmed this is still fixed in the Xcode 12.5 RC released today - will leave it open until the fix is the publicly released version.
${PRODUCT_NAME}should be used instead of${TARGET_NAME}, since the target name might differ from the product name (which is what weâre after). So:For me, it worked by adding the post-actions for the build scheme.
Quick update to my previous comment:
Apparently, the problem was connected with App Store Connect issues. I tried again today, and it works as expected. The build was successfully deployed on TestFlight.
There is one more thing I would like to add. Perhaps it will be useful for someone struggling with the issue:
In my project (iOS app) I have multiple framework targets. One of them is a âsharedâ framework (named
Common.framework) that I use as a dependency for all other targets. All libraries added via SPM (in Xcode) are added to this framework. For that reason, my appâs archive structure looked a bit different from what is described in this topic. I browsed my archive in Finder to locate where the Firebase frameworks are located exactly, and it looked like this:To make it work, I needed not only to remove
FirebaseAnalytics.frameworkandGoogleAppMeasurement.frameworkbut also the wholeFrameworksdirectory containing the frameworks. Even if theFrameworksdirectory was empty, I couldnât upload the archive to App Store Connect.I adjusted the post-action script (added to Archive action) to remove the whole
Frameworksdirectory:In âProvide build settings fromâ I have my app target selected.
With the above, I can archive and upload my app with Firebase integrated via SPM to App Store Connect without an issue using Xcode 12.3 (12C33).
Itâs probably better to use
PRODUCT_NAMEinstead ofTARGET_NAMEbecause they can be different (like in my case) and the workaround wouldnât work in this situation.Hey @RealTechyGod,
We support both CocoaPods and Swift Package Manager on the most recent non-beta version of macOS. macOS 11 beta may have some compatibility issues, though from what I understand CocoaPods still works for most users and based on the issue you filed on the CocoaPods repository you may need to adjust your local Ruby environment in order to get it to work. You may be able to find some relevant materials for fixing your local Ruby environment on StackOverflow.
While we appreciate your classification of dead vs not-dead dependency managers, itâs not useful for us to collapse dependency manager usage into a binary state, since a dependency manager with a relatively small market share may still be used by enough developers to warrant support.
Iâll be hiding some of these comments since theyâve gone off-topic from the original issue, but their contents will still be accessible. Thanks for your feedback!
At this time SPM way seems to take much longer to fetch and resolve the dependencies graph. At least longer than with cocoapods. Even if we forget about the fact that it has some things to fix at this point, will it always take so long?
Thanks for everyoneâs help. I did something similar, but attempted an automated approach to look for static frameworks.
In my schemeâs Build Post-action I added a run script which I call with: $SRCROOT/buildScripts/fix_swift_pm_build_post_action.sh
Remember to chmod it so it can execute. The shell script I used is:
I encountered this issue too and had to modify the post-action script to remove additional frameworks. It looks like you also need to remove the frameworks for any other targets you might have, such as the Watch extension (as someone mentioned above) but also for the App Clips. Notice the the extra couple of frameworks in the
AppClipsfolder.Unfortunately I just tried with Xcode 12.2 RC released yesterday and the
.frameworkfiles are still embedded.@din that workaround did not work for me đŚ
As a temporary workaround for building add
Post Actionto your Scheme with the following content:This is the only solution that worked for me. None of the above did the trick, because the path to the frameworks was never found. But I based on those solutions for writing this one. Using Xcode 12.4, just in case.
rm -rf â${ARCHIVE_PRODUCTS_PATH}/Applications/${TARGET_NAME}.app/Frameworks/FirebaseAnalytics.frameworkâ rm -rf â${ARCHIVE_PRODUCTS_PATH}/Applications/${TARGET_NAME}.app/Frameworks/GoogleAppMeasurement.frameworkâ
This issue is acknowledged in the Xcode 12.4 release notes along with a variation of the workarounds discussed here.
For folks having issues today: this is an outage on Appleâs side and is not related to this issue. https://developer.apple.com/system-status/
cc @darrarski, @kylebrowning, @AndrewBennet
My companyâs app uses FirebaseAnalytics via Swift Package Manager with this workaround and we successfully submitted a build to Apple as recently as last night with no issues.
Product > Scheme > Edit Scheme > Click on Build > Post Action
@0x6A75616E Thanks for the detailed walkthrough, worked for me. Had to choose my app in the âProvide build settings fromâ dropdown in Post-action.
Iâve done the workaround and itâs working when i archive upload. But using fastlane gym iâm still getting the following errors.
Now that Xcode 12.5 stable is release, this issue should be fixed, right?
We use both Google and Firebase Frameworks. If your using FirebaseAuth or Firebase and some other Google Product then you probably are too. Do an archive and look inside the frameworks, plugins and watch folders. If you have something googley or Firebase in those folders chances are it shouldnât be there.
Possibly if you donât have a watch app you might need to delete the entire folder ie
We also had a few app extensions containing the frameworks, which we had to remove as well:
After checking the product after building, I noticed that the frameworks may be copied to several folders, so I used the following commands: rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Frameworks/FirebaseAnalytics.frameworkâ rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Frameworks/GoogleAppMeasurement.frameworkâ rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Frameworks/FIRAnalyticsConnector.frameworkâ rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Plugins/FirebaseAnalytics.frameworkâ rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Plugins/GoogleAppMeasurement.frameworkâ rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Plugins/FIRAnalyticsConnector.frameworkâ rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Watch/FirebaseAnalytics.frameworkâ rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Watch/GoogleAppMeasurement.frameworkâ rm -rf â${TARGET_BUILD_DIR}/${TARGET_NAME}.app/Watch/FIRAnalyticsConnector.frameworkâ
I was able to successfully submit a build to the App Store đđź
I am also experiencing this issue. I have tried the Post action on the build phase and a run script. Neither of them worked for me.
I will have to revert back to pods until this is fixed
Combining @paulb777 and @ThePragmaticArt solutions works for me.
@jamiehunt Only acknowledgement that it is an issue so far.
Not that this is an appropriate conversation in this context, but a CDN doesnât change the fact that youâre downloading over a gig of data. For most automation setups involving proper configurations (VMs spun up for single one offs with no cache), this is a heavy hit on time setting up a fresh copy of the project and overall overhead on the HDD/SSD among other things and can take around 5-10 minutes per run. Itâs extraordinarily inefficient and slow especially for variable environments and network speeds. CDN doesnât change thatâŚ
âPods have to download that insane Spec repo on top of everything elseâŚâ stupid statement with cocoapods cdn
This is an opinionated statement that probably shouldnât be here. Without cache, SPM is drastically faster than Cocoapods and avoids many of the clashing cache issues and project config issues Pods have. Pods have to download that insane Spec repo on top of everything elseâŚ
This issue is still exist on Xcode 12.5 (12E262). I could not upload the binary to App Store without adding Post-actions script.
This script by @surajbarkale covers all the cases in our app (with embedded watch and iMessage extensions).
For us, we had to use
${PRODUCT_NAME}instead of${TARGET_NAME}in the directory path:I have a Share Extension that was causing this Match-O header issue and this is what worked for me as well as an Archive post action:
That workaround and that one worked well here. Thank you guys.
Hi @ZaniLuca ! Try adding the similar scripts for all your targets. I suppose youâll have to add something similar to your widget scheme. Try opening failed build products (your archive --> open package contents --> ⌠--> open package contents --> Frameworks) and see if there are miscopied frameworks that need to be removed.
Applied @darrarski solutions above for GoogleMaps as well - didnât realize that had the same issue as Firebase. Posting here because I originally thought it was a Firebase issue even after using the solution, so this should save some google maps people some time
rm -rf â${ARCHIVE_PRODUCTS_PATH}/Applications/outfield-swift.app/Frameworks/GoogleMapsUtils.frameworkâ rm -rf â${ARCHIVE_PRODUCTS_PATH}/Applications/outfield-swift.app/PlugIns/GoogleMapsUtils.frameworkâ
Iâve heard that this error is a current App Store Connect issue, rather than related to this workaround.
I followed the instructions provided by @0x6A75616E and @Fedos here:
After doing it, the app archives, passes validation, and successfully uploads to App Store Connect from Xcode 12.3 (12C33).
Unfortunately, it canât be processed. It doesnât appear on App Store Connect website at all. After a while, I received following email message from App Store Connect for the build Iâve uploaded:
It looks like the solution is not valid anymore.
The problem with this solution is that if you have a
Run Scriptwhich is required forCrashlyticsis going to fail because it canât find the filesIs there a solution for this?
@marekpridal thank you for the updated script! I totally spaced frameworks being part of the plug ins. The only thing is that I had to change it to use
PRODUCT_NAMEinstead ofTARGET_NAME@borut-t I have a framework that includes Firebase, so I had to modify those paths, open the
organizer -> .xcarchive --> .ipaand look for the actual paths.As a note to follow up on the original diagnosis, I do recommend adding the remove process as a build phase action (no different than stripping binaries) to prevent the need for duplicating across targets and decoupling it from the schemes as such:
Does anyone have the script working with Xcode Version 12.0.1 (12A7300)?
The workaround suggested by @paulb777 worked for me, using Xcode Version 12.0 (12A7208). Thank you đŻ
@ThePragmaticArt Sorry mate. Didnât mean to insult anyone here. Iâm actually a huge fan of SPM and promote it in local dev communities here in Russia. So, no hard feelings.
@antonmartinsson check that your TARGET_NAME is the same as a product that you try to deploy to device. In my case, I had JuiceFit target but Juice.app and that fix would not work until Iâve fixed my naming
I had to adapt the workaround for my unique setup. I have a separate target that contains all of my dependencies, so I had to change the path to go into the nested
Frameworksdirectory within that other target. Then on top of that, because the other targetâsFrameworkswas empty, I needed to change the script to delete the entireFrameworksdirectory instead of the individual frameworks within:I reproduced the issue, still unzipping the new GM seed and will test it there but Iâll see if I can find a workaround for the first GM seed.