maps: iOS 8.1.0-rc: Xcode 'Archive' produces a corrupt archive

Describe the bug iOS: Xcode ‘Archive’ produces a corrupt archive. Seems to be possibly related to iOS Mapbox SDK 5.8. Found a workaround, see below.

To Reproduce

  • npx react-native init RNMapboxTest
  • cd RNMapboxTest
  • yarn add @react-native-mapbox-gl/maps
  • cd ios && pod install
  • Open ios/RNMapboxTest.xcworkspace in Xcode
  • Set build to ‘Any iOS Device’ and set signing
  • Build with Product > Archive. Wait.
  • Build completes without errors, but it doesn’t show up in Organizer
  • When trying to open the build from /Library/Developer/Xcode/Archives, get error ‘The archive may be corrupt or unreadable.’

Expected behavior Expecting to be able to build an Archive for App Store submission.

Screenshots Screen Shot 2020-11-03 at 10 27 14 AM

Versions

  • Platform: iOS
  • Xcode: 12.1
  • react-native-mapbox-gl Version 8.1.0-rc.9
  • React Native Version 0.63.3

Possible reason & Workaround

  • When using react-native-mapbox-gl v 8.0.0, the archive build works. However I need the padding fixes in 8.1 rcs, so I continued looking.
  • Noticed that 8.0.0 installed Mapbox iOS SDK 5.9.0, whereas 8.1.0-rc.9 installs 5.8.0. This is because in 8.0.0 podspec the SDK dependency is defined without a ‘patch’ number, like this: ‘~> 5.7’, leading to installation of the latest 5.X version. In 8.1.0-rc.9 it’s defined with a patch: ‘~> 5.8.0’, installing version 5.8.X.
  • Learned about $ReactNativeMapboxGLIOSVersion to explicitly set the iOS SDK version. However, it seems to apply also to some other dependencies, and if you set it to ‘~> 5.9.0’, @react-native-mapbox-gl-mapbox-static fails to install. However setting it to ‘~> 5.8’ leads to install of Mapbox iOS SDK 5.9.0 and latest 5.X for others. And now archive build works correctly!
  • So the workaround for me was simply to add $ReactNativeMapboxGLIOSVersion = '~> 5.8' into the Podfile, and pod install.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 36
  • Comments: 80 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve been struggling with this too for a bit, and I found that downgrading cocoapods from version 1.10.0 to 1.9.3 fixed the corrupt archive issues above. The command I used:

gem install cocoapods -v '<= 1.9.3' -n /usr/local/bin
  • react-native-mapbox-gl Version 8.1.0-rc.8
  • React Native Version 0.63.2

I was able to workaround this issue by forcing cocapods to use frameworks but only for the MapboxMobileEvents pod. This way I can still use static linking for other pods while fixing this and using cocoapods@1.10.1.

In my app Podfile:

pre_install do |installer|
  fix_mapbox_events(installer)
end

def fix_mapbox_events(installer)
  installer.pod_targets.each do |pod|
    if pod.name == 'MapboxMobileEvents'
      def pod.build_type;
        Pod::BuildType.dynamic_framework
      end
    end
  end
end

Then update pods without the static linking fix:

REACT_NATIVE_MAPBOX_GL_USE_FRAMEWORKS=1 pod update

Quick note for other folks looking for this: I was able to get this working without overwriting my global cocoapods install by using a Gemfile with the following contents in the RN ios folder:

source 'https://rubygems.org'

# use cocoapods v 1.9.3 as work-around for mapbox issues when archiving
# https://github.com/react-native-mapbox-gl/maps/issues/1097
gem 'cocoapods', '~> 1.9.3'

Then instead of the usual pod install command, use bundle exec pod install.

Downgrading to Cocoapods 1.9.3 also fixed this issue for me. Has anyone manage to get this working with Cocoapods 1.10.0?

Downgrading to cocoapods 1.9.3 fixed this for me!

Thank you for pointing me in the right direction 😃 I got it to work with cocoapods v1.10.1, and "@react-native-mapbox-gl/maps": "^8.2.0-beta1" and adding pre and post install methods in Podfile.

Fixed by upgrading from "@react-native-mapbox-gl/maps": "^8.1.0", to "@react-native-mapbox-gl/maps": "^8.2.0-beta1",. Need to define pre_install and post_install in your ios/Podfile. Then yarn install, npx pod-install. And now I can see archived build in organizer.

I can confirm that is also happening with rc6 and rc9 i did not check the rest. i need rc6 for the padding fixing of the ios.

Since React Native 0.64 (upcoming release) is not compatible with CocoaPods 1.9.3 anymore (because of Hermes afaik), simply downgrading to 1.9.3 is not, and never was a solution.

Has anyone found any information on what might be causing this?

Downgrading to cocoapods 1.9.3 fixed this for me!

I have the same problem. Downgrading is working for me too

Yes Appcenter does not respect the Podfile.lock version and will use whatever is installed to the runner machine. And the version was just upgraded to 1.10.0 and that is when my problems started.

I used this script to enforce to use the version defined in the Podfile.lock. Which is in general better because now I can be in control what is used.

https://github.com/microsoft/appcenter/blob/master/sample-build-scripts/react-native/compare-cocoapods/appcenter-post-clone.sh

I’ve added a fix #1262

Note that it requires Podfile modification - see https://github.com/react-native-mapbox-gl/maps/pull/1262#issue-584279625

Awesome! That did the trick for me @janicduplessis. Thanks so much, this has been a thorn in my side.

Added the env-variable in our Podfile too: https://github.com/AtB-AS/mittatb-app/pull/935/files#diff-281ded35b124f5160d0a57e47e521ee6f49f233933e091a0d33f3fd42a74abc8R6 (so my team doesn’t have to remember to set it locally / on CI).

Another issue I faced after was that pod update also broke our build because of a libevent conflict with Flipper. So a general pod update might trigger the same for others? Just pod install so it doesn’t update all Pods worked for me 👌🏻 Though I see you’ve noticed that too: https://github.com/facebook/flipper/issues/1916

@SanjanaTailor

Removing the build phase fixed the malformed archive problem (in my case).

I’m not having errors when doing ‘pod install’ but I’m using an older ruby version (2.6), you might try to downgrade your ruby.

@SanjanaTailor Fixed the issue in starter project with @react-native-mapbox-gl/maps. Below are configuration and versions used:

Going back to 1.9.3 fixed it for us too

The Archive build gets corrupted again if I set Mapbox iOS SDK to 6.X version (using $ReactNativeMapboxGLIOSVersion).

Turns out that it’s possible use Mapbox iOS SDK 6.X and avoid corruption with $ReactNativeMapboxGLIOSVersion = '~> 6.2.1'

Previously I pinned to exact version '6.2.1' because the latest version 6.2.2 crashes in Xcode Release build on armv7 device. But it seems to work fine when using Archive and testing through TestFlight 🤷‍♂️…

The root cause for the malformed archive is probably this: https://github.com/CocoaPods/CocoaPods/issues/10385 The root cause for the build issues may be this: https://github.com/CocoaPods/CocoaPods/issues/10373

Using COCOAPODS: 1.10.1 and @react-native-mapbox-gl/maps": “8.1.0”

I had the exact same problem (archive succeed but actually malformed) Just open the xcarchive and you’ll see there are missing parts (the plist for example).

The trick for me was to remove the copy dsym build phase of the @react-native-mapbox-gl-mapbox-static pod

This phase was causing build failure with some config and malformed archive with others, I don’t really get the crux of the problem but may be it can help some of you…

I’ve noticed a similar issue on AppCenter:

error: archive at path '<snip>' is malformed
** EXPORT FAILED **

Tried pinning to ~> 5.8 but instead of a malformed archive, I now get the following error:

Print: Entry, "CFBundleIdentifier", Does Not Exist
##[error]Failed to automatically generate an `Export options` plist file to export an IPA. Please specify an `Export options` plist file in `Package options`.

If I downgrade to 8.1.0-rc.4 the archiving succeeds though.

@ghadeeraqraa1992 Similar thing happend to me out of the blue, you may want to try the following thread: https://github.com/mapbox/mapbox-gl-native-ios/issues/555

Edit: ahhh nevermind, you already found that one

@NathanNovak

@SebiVPS How did you get 8.2.0-beta1 to install on yours?

there is nothing special here, just add the specific version in your package.json and install. (No login needed) But i still use "react-native" : "0.63.4", maybe there is a problem with 0.64 and react v17 ?

Quick note for other folks looking for this: I was able to get this working without overwriting my global cocoapods install by using a Gemfile with the following contents in the RN ios folder:

source 'https://rubygems.org'

# use cocoapods v 1.9.3 as work-around for mapbox issues when archiving
# https://github.com/react-native-mapbox-gl/maps/issues/1097
gem 'cocoapods', '~> 1.9.3'

Then instead of the usual pod install command, use bundle exec pod install.

Spent a good two days on this issue after an accidental computer restart triggered an Xcode update…I have tried everything, thank you!!!

Cheers @RobertSasak . That looks super helpful - I will give it a go. Wasn’t aware of the --all --executables options - suspect anyone trying to clean up local env (using my steps above) might find those helpful. PS - like norgeskart!

@ryderdonahue Please try to read the full issue before asking. Its probably a bug in cocoapods: https://github.com/react-native-mapbox-gl/maps/issues/1097#issuecomment-770071623

@SanjanaTailor Fixed the issue in starter project with @react-native-mapbox-gl/maps. Below are configuration and versions used:

This was really helpful unblocking me yesterday!

What is the longer term solution though? I imagine we can’t just kick down our ruby/cocoapods version forever.

@SanjanaTailor Fixed the issue in starter project with @react-native-mapbox-gl/maps. Below are configuration and versions used:

Thank you @AmalMenachery Ruby version downgraded from 3.3.0 to 2.7.1 which resolved an issue of running this command below bundle exec pod install and after that IPA generated successfully

thanks @acecilia it really looks like the same problems, I’ll give a try to your workaround

after running pod install command getting this error ruby download_file_async’: undefined method `encode’ for URI:Module (NoMethodError) due to that pod install not successfull.

Quick note for other folks looking for this: I was able to get this working without overwriting my global cocoapods install by using a Gemfile with the following contents in the RN ios folder:

source 'https://rubygems.org'

# use cocoapods v 1.9.3 as work-around for mapbox issues when archiving
# https://github.com/react-native-mapbox-gl/maps/issues/1097
gem 'cocoapods', '~> 1.9.3'

Then instead of the usual pod install command, use bundle exec pod install.

after following these steps and run the commad bundle exec pod install getting this error under ruby folder download_file_async’: undefined method `encode’ for URI:Module (NoMethodError) under ruby folder, please help Thanks

ruby version - 3.0.0 cocoapods - 1.9.3

The Archive build gets corrupted again if I set Mapbox iOS SDK to 6.X version (using $ReactNativeMapboxGLIOSVersion).

It’s quite annoying as 5.9 has a symbols flickering while zooming out issue, which 5.8 didn’t have, and it’s fixed in 6.X.