Skip to content
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

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

Closed
sampok opened this issue Nov 3, 2020 · 80 comments · Fixed by #1262
Closed

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

sampok opened this issue Nov 3, 2020 · 80 comments · Fixed by #1262

Comments

@sampok
Copy link

sampok commented Nov 3, 2020

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.
@sampok
Copy link
Author

sampok commented Nov 4, 2020

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.

@sampok
Copy link
Author

sampok commented Nov 4, 2020

It's strange that the app builds fine with all Mapbox iOS SDK versions for Debug and Release, but with Archive it becomes corrupted (except with 5.9.0).

When I peek inside the generated .xcarchive file that Archive creates, I see that the 'corrupted ones' lack Info.plist file and SCMBlueprint folder with .xcscmblueprint file inside it. Also BCSymbolsMaps folder seems to have less items.

The Archive process completes without any errors. It does have a lot of warnings, but they look like kind of "normal" for React Native builds.

@SalihZinaty
Copy link

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.

@cbrevik
Copy link
Contributor

cbrevik commented Nov 4, 2020

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.

@sampok
Copy link
Author

sampok commented Nov 4, 2020

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

I guess a possible, even likely (?) explanation is that in rc4 the Mapbox SDK version was defined without a patch number, and now resolves to the highest minor version, i.e. 5.9.0. (rc4 to rc5 diff)

@chriscohoat
Copy link

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

@tomihuttunen
Copy link

We had similar issues with react-native-mapbox-gl 8.0.0 and the cocoapods downgrade to 1.9.3 resolved those as well. 1.10.0 did not create a valid archive.

@cbrevik
Copy link
Contributor

cbrevik commented Nov 5, 2020

I've tried downgrading our Podfile.lock to 1.9.3, but I am unsure if the AppCenter VMs will use 1.9.3 in that case. It failed even with the downgrade, in any case. They have 1.10.0 installed by default it seems - so I'm a bit unsure of how to verify on my end.

@tomihuttunen
Copy link

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

@sampok
Copy link
Author

sampok commented Nov 5, 2020

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 🤷‍♂️..

@naftalibeder
Copy link
Collaborator

Downgrading to cocoapods 1.9.3 fixed this for me!

@westanvv
Copy link

Downgrading to cocoapods 1.9.3 fixed this for me!

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

@samjusaitis
Copy link

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

@aprilzero
Copy link

Going back to 1.9.3 fixed it for us too

@patternleaf
Copy link

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.

@luskin
Copy link

luskin commented Jan 19, 2021

There is a conflicting issue with the latest AppCenter packages though as they require 1.10.X to archive. Anybody got this to work with any of the AppCenter packages on 4.0.X?

@bottle-rocket-11
Copy link

Any news on this? I keep using 1.9.3 for this project and 1.10.1 for my other projects

@acecilia
Copy link

Was somebody able to report this issue in the cocoapods repository? I cant find any related issues 😞

@SanjanaTailor
Copy link

SanjanaTailor commented Jan 29, 2021

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

@acaraty
Copy link

acaraty commented Jan 29, 2021

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...

@acecilia
Copy link

acecilia commented Jan 29, 2021

The root cause for the malformed archive is probably this: CocoaPods/CocoaPods#10385
The root cause for the build issues may be this: CocoaPods/CocoaPods#10373

@acaraty
Copy link

acaraty commented Jan 29, 2021

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

@SanjanaTailor
Copy link

sing COCOAPODS: 1.10.1 and @react-native-mapbox-gl/maps": "8.1.0"

Was somebody able to report this issue in the cocoapods repository? I cant find any related issues 😞

no not able to see facing same issue posted over here

@SanjanaTailor
Copy link

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

@SanjanaTailor
Copy link

the copy dsym build phase of the @react-native-mapbox-gl-mapbox-static pod

@acaraty - can you explain from where it is resolved - The trick for me was to remove the copy dsym build phase of the @react-native-mapbox-gl-mapbox-static pod ?

@Alaa-Ben
Copy link

Alaa-Ben commented Mar 8, 2021

Same issue as @SebiVPS ! archive builds and available but error when uploading to app store:

ITMS-90562: Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.

@mfazekas
Copy link
Contributor

mfazekas commented Mar 8, 2021

@Alaa-Ben, @SebiVPS what is the MPGL version used?!

@SebiVPS
Copy link

SebiVPS commented Mar 8, 2021

@Alaa-Ben, @SebiVPS what is the MPGL version used?!

The latest version you mentioned above:
"@react-native-mapbox-gl/maps": "^8.2.0-beta1"

@mfazekas
Copy link
Contributor

mfazekas commented Mar 8, 2021

I meant if you have $ReactNativeMapboxGLIOSVersion = '~> 6.3', or similar in your Podfile. If not please try with that too.

@janicduplessis
Copy link
Contributor

@SebiVPS One way to verify the fix work is check if MapboxMobileEvents is actually being included as a framework per my comment here https://github.com/react-native-mapbox-gl/maps/issues/1097#issuecomment-788180364.

Maybe it doesn't work with certain cocoapod version? What version are you using?

@RobertSasak
Copy link
Contributor

RobertSasak commented Mar 8, 2021

I would like to again bring attention to comment by @sampok
https://github.com/react-native-mapbox-gl/maps/issues/1097#issuecomment-722498863
This one line resolved all the issues with corrupted archives while still using "@react-native-mapbox-gl/maps": "8.1.0",

$ReactNativeMapboxGLIOSVersion = '~> 6.2.1'

I can only confirm that 6.2.2 or 6.3.3 version have still issue with corrupted archive.

@SebiVPS
Copy link

SebiVPS commented Mar 8, 2021

Thank you for your comments, i tried using gem 'cocoapods', '~> 1.9.3'
and $ReactNativeMapboxGLIOSVersion = '~> 6.2.1' in Podfile

Currently i get an error at pod install, looks like a temporarily issue at server side, i'll try again tomorrow:

[!] Error installing @react-native-mapbox-gl-mapbox-static
[!] /usr/bin/curl -f -L -o /var/folders/vc/5cybcdsd7zn7v1mbng40wx7h0000gp/T/d20210308-54315-1bh2bgn/file.zip https://api.mapbox.com/downloads/v2/mobile-maps/releases/ios/6.2.1/mapbox-ios-sdk-dynamic-with-events.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.9.3 cocoapods-downloader/1.4.0'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 401 Unauthorized

@Alaa-Ben
Copy link

Alaa-Ben commented Mar 8, 2021

Hmm upgrading cocoapods to 1.10.2, upgrading mapboxgl to 8.2.0-beta1 and adding pre and post install methods in podfile solved this for me.

@RobertSasak
Copy link
Contributor

@SebiVPS In order to use new Mapbox SDK you need to have a special password in .netrc. Please refer to Mapbox iOS SDK fo more info.

# Add Mapbox password to .netrc in order to download iOS SDK
echo -e "machine $NETRC_MAPBOX_MACHINE\nlogin $NETRC_MAPBOX_LOGIN\npassword $NETRC_MAPBOX_PASSWORD" > ~/.netrc

@janicduplessis
Copy link
Contributor

janicduplessis commented Mar 8, 2021

I tested this patch on cocoapods 1.10.x so maybe it doesn't work on 1.9.x. Maybe it is possible to get it to work on 1.9.x or document the requirement of using 1.10.x

@SebiVPS
Copy link

SebiVPS commented Mar 9, 2021

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.

@bdtren
Copy link

bdtren commented Mar 12, 2021

I've added a fix #1262

Note that it requires Podfile modification - see #1262 (comment)

Dear @mfazekas, I tried this solution. Archive and build success.
But I cannot upload the archived version to App Store, because of the MapboxMobileEvents

Error:

ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'App.app/Frameworks/MapboxMobileEvents.framework/MapboxMobileEvents' is not permitted. 
Your app can’t contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. 
Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the iOS app bundle structure."

@gregogalante
Copy link

I'm getting the same problem of @bdtren with 8.2.0-beta1 version and the pre_install and post_install tasks on my Podfile

@NathanNovak
Copy link

NathanNovak commented Mar 30, 2021

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.

I get a corrupt archive and keep getting this error when trying to upgrade to 8.2.0-beta1:

npm ERR! Could not resolve dependency: npm ERR! peer react@"^16.6.1" from @react-native-mapbox-gl/maps@8.2.0-beta1 npm ERR! node_modules/@react-native-mapbox-gl/maps npm ERR! @react-native-mapbox-gl/maps@"8.2.0-beta1" from the root project

"react": "17.0.1",
"react-native": "0.64.0",

Can someone let me know how to solve this.

@abakhtiar
Copy link

I have the same corrupted archive problem with "@react-native-mapbox-gl/maps": "^8.1.0-beta.1". Upgrading to latest versions also breaks my build for hooks dependancies.
It is really a big mess in our apps! :(
"react": "16.8.6",
"react-native": "0.60.5",
Anybody knows a way please let me know.
Thanks

@NathanNovak
Copy link

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

@SebiVPS
Copy link

SebiVPS commented Mar 31, 2021

@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 ?

@NathanNovak
Copy link

NathanNovak commented Mar 31, 2021

@SebiVPS Thats is the key difference right there. React had a rather large changelog with 17.0.0.

Does anyone know if using '--legacy-peer-deps' flag creates havoc?

Update: I was able to archive and create the .ipa file by using the master version in package.json:

"@react-native-mapbox-gl/maps": "github:react-native-mapbox-gl/maps#master", with the flag --legacy-peer-deps

I also added:

    $RNMBGL.pre_install(installer)
  end

  post_install do |installer|
    $RNMBGL.post_install(installer)
  end

as per @mfazekas suggestion.

So far this works with

"react": "17.0.1",
"react-native": "0.64.0",

@designervoid
Copy link

Same issue

@designervoid
Copy link

designervoid commented Apr 4, 2021

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.

@b3hz4d
Copy link

b3hz4d commented Apr 8, 2021

I did all the above solution with clean installation but I'm getting this error
Info.plist: No such file or directory
Any idea how to solve it?
Using cocoapods V1.10.1 & Xcode 12.4

@ghadeeraqraa1992
Copy link

I did all the above solution with clean installation but I'm getting this error
Info.plist: No such file or directory
Any idea how to solve it?
Using cocoapods V1.10.1 & Xcode 12.4

I have the same issue
did you solve it ?

@Hless
Copy link

Hless commented Jun 21, 2021

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

Edit: ahhh nevermind, you already found that one

@ghadeeraqraa1992
Copy link

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

Edit: ahhh nevermind, you already found that one

did you find a solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.