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

Not able to generate archive when using a Pod file #14749

Closed
compojoom opened this issue Jun 27, 2017 · 29 comments
Closed

Not able to generate archive when using a Pod file #14749

compojoom opened this issue Jun 27, 2017 · 29 comments
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@compojoom
Copy link
Contributor

I managed to update to 0.46 rc2 from 0.43 today and everything was looking ok. Building a debug or production release was working. However when I tried to create an archive I ran in the following error:

Undefined symbols for architecture armv7:
  "_JSNoBytecodeFileFormatVersion", referenced from:
      +[RCTJavaScriptLoader loadBundleAtURL:onProgress:onComplete:] in libReact.a(RCTJavaScriptLoader.o)
      +[RCTJavaScriptLoader attemptSynchronousLoadOfBundleAtURL:runtimeBCVersion:sourceLength:error:] in libReact.a(RCTJavaScriptLoader.o)
  "facebook::react::parseTypeFromHeader(facebook::react::BundleHeader const&)", referenced from:
      +[RCTJavaScriptLoader attemptSynchronousLoadOfBundleAtURL:runtimeBCVersion:sourceLength:error:] in libReact.a(RCTJavaScriptLoader.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

In my project I'm using react-native-maps and since I'm running google maps on iOS I have a podfile similar to this one:
https://github.com/airbnb/react-native-maps/blob/master/example/ios/Podfile

It turns out that when I remove the following lines

  pod 'React', path: '../../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]

the archive is being built correctly.

I've reproduced the error here:
https://github.com/compojoom/rn46crash/tree/7c34cf696cf940e21566d73b7e76365fb6aab677

As you can see the podfile just has the pod Yoga and pod React lines.

To run the app, clone the repository and do yarn. Afterwards open the rn46crash.xcworkspace with XCode, assign a team to the project and build it. You should run in the specified error above.

I'm pasting this issue here and not in the react-native-maps repository as with RN 0.43 - I was able to create an archive with that pod configuration, that's why I think that there is something wrong in the RN package.

  • React Native version: 0.46 rc2
  • Platform: ios
  • Development Operating System: macOS
  • Build tools: Xcode 8.3.3
@litmanenPL
Copy link

It seems that adding BatchedBridge subspec resolves the issue.
I found it out based on React.podspec file analysis. JSNoBytecodeFileFormatVersion is defined in JSCWrapper.cpp

@tuckg
Copy link

tuckg commented Jul 27, 2017

@litmanenPL how to solve?

@litmanenPL
Copy link

@tuckg as mentioned above by adding BatchedBridge React subspec in Podfile

pod 'React', path: '../../node_modules/react-native', :subspecs => [
   ...,
   'BatchedBridge',
   ...
  ]

@tuckg
Copy link

tuckg commented Jul 27, 2017

@litmanenPL Nice, It work

@icarus-sullivan
Copy link

@litmanenPL I have been staring at this for the last 3-4 days. You my friend, are awesome.

@ryancarlson
Copy link

Ah this! Thank you @litmanenPL !

@guilhermepontes
Copy link

Thank you @litmanenPL!!!

@jpamarohorta
Copy link

@litmanenPL solution fixed that error but now I'm getting duplicate symbols for architecture armv7. I suppose that happens because now I have 2 copies of React in the project, one from cocoapods and one in the Libraries themselves.

What can be done to fix this? Removing React from the Libraries (like it's suggested in https://github.com/auth0/react-native-lock/issues/3) ends up giving a lot of runtime errors.

@litmanenPL
Copy link

@jpamarohorta duplicate symbols for architecture armv7 is probably caused by some issue with your project configuration and it's not related to the original issue from this ticket at all. So probably it can be fixed only by properly configuring your project. Configuring React via cocoapods should be enough - there is no need to add it as other libraries, subproject, etc.

@artyom-developer
Copy link

artyom-developer commented Sep 16, 2017

@litmanenPL solution fixed that error but now I'm getting error

ArchiveIntermediates/elBacan/BuildProductsPath/Release-iphoneos/libRCTWebSocket.a(RCTWebSocketModule.o)
ld: 424 duplicate symbols for architecture arm64

@dotansimha
Copy link

@ArtyomCommander remove the libReact.a and RTCWebSocket from your XCode project because if you added it in the Podfile, you don't need to include it in your project. Please try andsee it the error count is lower now.

@tehong
Copy link

tehong commented Oct 22, 2017

@dotansimha Thanks you. I upgraded to 0.48.4, I also encountered duplicated symbols between libReact.a and libRCTWebSocket.a. With your advice, I removed the libRCTWebSocket.a from my xcode target's "Link Library with libraries" after putting the 'RCTWebSocket' in the pod 'React' subspecs. Now I can both run debug and archive.

@ararog
Copy link

ararog commented Nov 30, 2017

@tehong I don't have the same luck as you, I have to keep adding libs when running debug and removing when I'm about to run fastlane to build, archive and upload.

@rborn
Copy link

rborn commented Dec 1, 2017

I have the same issue, cannot build the archive no matter what I try to put in the Podfile.
RN 0.50.3

@rborn
Copy link

rborn commented Dec 5, 2017

I managed to make it work by linking in the xcode project the next 2 libs
screen shot 2017-12-05 at 14 24 08

the pod file stays "simple"

platform :ios, '9.1'
target 'App' do
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'GoogleMaps'
  pod 'React', :path => '../node_modules/react-native'
  pod 'RNI18n', :path => '../node_modules/react-native-i18n'
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
end

Now I can send the app to Testflight using fastlane 🎉

@brownieboy
Copy link

@rborn 's solution did it for me. I just added the libs libcxxreact.a and libjschelpers.a to XCode as he said. I also removed the libReact.a as @dotansimha said, because I was also loading React in my Pod file.

@Andreyco
Copy link
Contributor

Andreyco commented Jan 25, 2018

Guys, are you having luck building "release" archive after importing libcxxxreact.a, libjschelpers.a and removing libReact.a? App builds, opens, but screen stays blank.

Running app in "release" mode (via xCode + cable) is causing no problems. The issue comes when app is archived.

@brownieboy
Copy link

brownieboy commented Jan 26, 2018

@Andreyco,

Yes, I am having that very problem.

When I build and archive, submit that archive to Test Flight, and then download the app from there then the app hangs on a blank, white screen. When I built the app from Xcode and installed directly on my iPhone via a cable then it works fine. There should be no difference between the two processes, but there obviously is.

I haven't, until now, had any clue what the cause might be because I was quite late introducing Test Flight into my process. (Lesson learned there!)

@brownieboy
Copy link

So I've now added BatchedBridge to the React subspec in my Pod file. I can now build, upload and then download from TestFlight, and the resulting app no longer hangs on the blank screen.

Here's how I changed my Pod file:

  pod 'React', path: '../node_modules/react-native', :subspecs => [
   'BatchedBridge'
  ]

So pretty much as @litmanenPL first said. That was the only change that I made.

@Andreyco
Copy link
Contributor

@brownieboy what RN version are you running? I believe BatchedBridge was deprecated in favour of CxxBridge which was causing me another troubles. Gonna give it another try after proper sleep, lol

@brownieboy
Copy link

@Andreyco,

React-Native 52.1 now, although I think I was on 51 when the problems first appeared.

@Andreyco
Copy link
Contributor

This is madness...
Despite BatchedBridge is legacy and CxxBridge should be used instead going with CxxBridge is no option for me. It has several dependencies (folly, boost, ...) which take forever to download (there is pending PR which replaces boost with boost-for-react-native and drops build time) and break our cloud builds (30m timeouts).

For now, I opt in removal of React as target

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

target '{project}' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for {project}

  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'BatchedBridge',
    'DevSupport'
  ]

  target '{project}Tests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target '{project}-tvOS' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for {project}-tvOS

  target '{project}-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Mar 9, 2018
@msand
Copy link
Contributor

msand commented Mar 9, 2018

@grabbou @ide Would it be possible to get an example project with a working debug and release build, and at the same time possibility to archive? I've tried to get a plain react-native init, pod init, pod install working using 0.54.0 but no luck. Only way to get it working is with linking React manually and this hack: #15838 (comment)

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

Which kind of goes against the whole point of cocoapods.
If I don't link it manually I get this instead: #14925

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RCTReconnectingWebSocket", referenced from:
      objc-class-ref in libReact.a(RCTPackagerConnection.o)
  "_OBJC_CLASS_$_RCTSRWebSocket", referenced from:
      objc-class-ref in libReact.a(RCTInspectorPackagerConnection.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Taking use_frameworks! into use causes these:
#17893
#16039
https://stackoverflow.com/questions/48705250/react-native-ios-could-not-build-module-yoga-algorithm-file-not-found

@msand
Copy link
Contributor

msand commented Mar 10, 2018

Managed to get use_frameworks building with the patches from here: #17764 (comment) but archiving fails on 0.54 with this: #18205

@msand
Copy link
Contributor

msand commented Mar 10, 2018

I noticed that "react-native run-ios" was working and making a functional debug build (using RN 0.53.3). While building, running and archiving in XCode was broken. So I took the command it was running and changed Debug to Release, drag and dropped the app to the simulator, and voila, it was working. Changed the command a bit more, and managed to get it to produce an archive which shows up in the organizer.
So, I added two commands to my package.json: msand/SVGPodTest@5343af5#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R8

"release": "cd ios && xcodebuild -workspace SVGPodTest.xcworkspace -configuration Release -scheme SVGPodTest -destination id=711F49EC-5747-4393-94DB-77B97D466541 -derivedDataPath build",
"archive": "cd ios && xcodebuild -workspace SVGPodTest.xcworkspace -configuration Release -scheme SVGPodTest -derivedDataPath build  -archivePath ./YourApp.xcarchive archive"

The error in XCode is this (in case it rings any bells for anyone):

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RCTReconnectingWebSocket", referenced from:
      objc-class-ref in libReact.a(RCTPackagerConnection.o)
  "_OBJC_CLASS_$_RCTSRWebSocket", referenced from:
      objc-class-ref in libReact.a(RCTInspectorPackagerConnection.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@msand msand mentioned this issue Mar 11, 2018
@tlloydukdev
Copy link

tlloydukdev commented Mar 12, 2018

I'm getting the same issue @msand - I can't get debug, release and archive to work without manually adding/removing Link Binary with Libraries each time :/

I have to add libRCTWebSocket.a back in in order to get rid of that link error you pasted in

@msand
Copy link
Contributor

msand commented Mar 14, 2018

@tlloydukdev Found another workaround for the non use_frameworks case: #15838 (comment) Essentially a duplicate target for debugging with manually linked React Native modules, and using the xcodebuild cli to build release for simulator and archive for TestFlight / AppStore.

@stale
Copy link

stale bot commented Jun 12, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 12, 2018
@stale
Copy link

stale bot commented Jul 12, 2018

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jul 12, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Jul 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests