react-native: [iOS] RN 0.60.0-rc.2 fails to build with CocoaPods frameworks

The changes in 0.60.0 to integrate CocoaPods by default are causing build failures if your Podfile includes use_frameworks!. use_frameworks! is a very commonly used CocoaPods option and it is required by many pods. Prior to 0.60.0 it worked fine with the React Native podspec.

React Native version:

System:
    OS: macOS 10.14.4
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 4.86 GB / 32.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    Android SDK:
      API Levels: 23, 24, 26, 27, 28
      Build Tools: 27.0.0, 27.0.3, 28.0.2, 28.0.3
      System Images: android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
      Android NDK: 18.1.5063045
  IDEs:
    Android Studio: 3.4 AI-183.5429.30.34.5452501
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.0-rc.2 => 0.60.0-rc.2

Steps To Reproduce

  1. Create a new project: react-native init AwesomeProject --version 0.60.0-rc.2.
  2. Add use_frameworks! to the top of ios/Podfile
  3. Install pods: cd ios && pod install.
  4. Build & run the app: cd .. && react-native run-ios

You will see build failures that look something like this:

▸ Compiling JSBigString.cpp

❌  /Users/james/src/tmp/AwesomeProject/ios/Pods/Folly/folly/Conv.h:38:10: 'double-conversion/double-conversion.h' file not found

#include <double-conversion/double-conversion.h> // V8 JavaScript implementation
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


▸ Compiling JSBundleType.cpp
▸ Compiling MethodCall.cpp
▸ Compiling JSExecutor.cpp
▸ Compiling JSIndexedRAMBundle.cpp

❌  /Users/james/src/tmp/AwesomeProject/ios/Pods/Folly/folly/Conv.h:38:10: 'double-conversion/double-conversion.h' file not found

#include <double-conversion/double-conversion.h> // V8 JavaScript implementation
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


▸ Compiling JSDeltaBundleClient.cpp

❌  /Users/james/src/tmp/AwesomeProject/ios/Pods/Folly/folly/Conv.h:38:10: 'double-conversion/double-conversion.h' file not found

#include <double-conversion/double-conversion.h> // V8 JavaScript implementation
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


▸ Compiling ReactMarker.cpp
▸ Compiling React-cxxreact-dummy.m
▸ Compiling RAMBundleRegistry.cpp

❌  /Users/james/src/tmp/AwesomeProject/ios/Pods/Folly/folly/Conv.h:38:10: 'double-conversion/double-conversion.h' file not found

#include <double-conversion/double-conversion.h> // V8 JavaScript implementation
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


▸ Compiling NativeToJsBridge.cpp
▸ Compiling ModuleRegistry.cpp
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening AwesomeProject.xcworkspace. Run CLI with --verbose flag for more details.
** BUILD FAILED **


The following build commands failed:
	CompileC /Users/james/src/tmp/AwesomeProject/ios/build/AwesomeProject/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-cxxreact.build/Objects-normal/x86_64/JSBigString.o /Users/james/src/tmp/AwesomeProject/node_modules/react-native/ReactCommon/cxxreact/JSBigString.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Describe what you expected to happen:

The app should build and run successfully.

Snack, code example, or link to a repository:

I have created a sample repository to demonstrate the issue here: https://github.com/jtreanor/react-native-cocoapods-frameworks.

Causes and fixes

I have been able to fix the error shown in the log above with some .podspec changes, but there are few more errors I haven’t been able to solve. You can see my WIP react-native branch here.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 65
  • Comments: 70 (26 by maintainers)

Commits related to this issue

Most upvoted comments

Just for a general update, the overall work @jtreanor is doing to solve this (of which I’m super grateful 🙇‍♂️) will be released under 0.61 as it will likely involve some breaking changes.

this one works for me:

  • close xcode and any other IDE rm -rf ~/library/developer/xcode/deriveddata rm -rf ~/.rncache rm -rf node_modules && npm install && cd ios && rm -rf Pods && pod install && cd …

then open xcode switching to legacy system, clean build and build again, it works for me 😄

[iOS] RN 0.60.3 fail to build with Cocoapods 🙇‍♂️ - OS: macOS Catalina 10.15 - XCode: 10.2.1

...
ios/Pods/Folly/folly/Conv.h:38:10: fatal error: 'double-conversion/double-conversion.h' file not found
#include <double-conversion/double-conversion.h> // V8 JavaScript implementation
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


** BUILD FAILED **
...

We faced a very similar issue when doing cocoapod repo lint when React-cxxreact was added as a dependency together with DoubleConversion and Folly. The same error was observed during direct Xcode build.

- NOTE | xcodebuild: Folly/folly/Conv.h:38:10: fatal error: 'double-conversion/double-conversion.h' file not found

What worked for me:

  • deleted [ios/Pods]
  • deleted [node_modules]
  • run again $npm install && pod install

this fixed my issue, maybe it helps you.

@MrLaibin You are using the RN version (0.60.4) which does not work with use_frameworks!. I suggest removing use_frameworks! from your Podfile or using the lastest RN from master.

Changing this line in Conv.h just fixed it for me:

#include <double-conversion/double-conversion.h>

to

#include <double-conversion.h>

RN: 0.60.5 Xcode: 10.1

I am continuing to dump everything I find here. Hopefully it will be helpful for coming to a solution. I have made some more progress but I think some non-trivial changes will be needed.

I have managed to get things building, but only by adding 'DEFINES_MODULE' => 'NO' to React-Core.podspec. We definitely don’t want to do this as it would break a number of things but it is a starting point. You can see my branch here.

I believe the reason for the last error in my previous comment ('memory' file not found etc.) is that React-Core now exposes C++ headers, such as JSCExecutorFactory.h. Since the module is imported by plain old Objective C headers, such as RCTWebSocketExecutor.h above, Xcode tries to build the C++ headers as ObjC and fails. This was not the case before the split as React/CxxBridge and React/Core were merged in https://github.com/facebook/react-native/pull/23559/commits/97edac1fb68b65ecee5405b96c5b4caaf52f33b7.

If I am correct about the cause here, I think there are a few options:

  • Split React-Core.podspec into React-Core.podspec, React-CxxBridge.podspec and a third podspec with shared logic (since dependencies can’t be circular).
  • Find a way to build the library podspecs as C++ so that it doesn’t trip up. I’m not sure if it is possible and it may just hide the problem for a later time.

I would love to hear if others think I am on the right track here. I am happy to jump in with any implementation as needed. We are hoping to adopt 0.60.0 in https://github.com/wordpress-mobile/gutenberg-mobile once it is released and this is a blocker for us.

Same here with RN 0.60.4

@jenshandersson Sorry I misread your previous comment. That is a different workflow. Thanks for checking!

What pods are you using so I can test it in my repo?

As I mentioned above, in our case the problem isn’t any individual pod but the fact that our project defines a podspec which depends on React. Since it is written in Swift, if I remove use_frameworks!, pod install gives me this error:

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `Gutenberg` depends upon `React-Core`, `React-cxxreact`, `React-RCTAnimation`, `React-RCTImage`, `React-RCTLinking`, `React-RCTNetwork`, `React-RCTText`, `React-RCTActionSheet`, `React-DevSupport`, and `yoga`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

And if I try to solve this warning by using use_modular_headers! it gives a lot of build errors. Short of rewriting our pod in Objective C, I think either use_modular_headers! or use_frameworks! will be required.

This may be a slightly unusual use case but I do think that if React Native is going to integrate with CocoaPods, it should be compatible with most common setups, and use_frameworks! is certainly widely used.

@genuinezack Nope, the fix isn’t in 0.60.5 due to the breaking changes involved. I would expect to see it in 0.61.0

I’ve updated RN from 0.59.5 to 0.60.3, changed the Podfile to follow the new format and I’m facing the same issue:

  • macOS Mojave 10.14.5
  • XCode Version 10.2.1 (10E1001)
Screenshot 2019-07-18 at 10 39 44

This is my Podfile:

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'DingoApp' do

  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  pod 'React', :path => "#{rn_path}"
  pod 'React-Core', :path => "#{rn_path}/React"
  pod 'React-DevSupport', :path => "#{rn_path}/React"
  pod 'React-fishhook', :path => "#{rn_path}/Libraries/fishhook"
  pod 'React-RCTActionSheet', :path => "#{rn_path}/Libraries/ActionSheetIOS"
  pod 'React-RCTAnimation', :path => "#{rn_path}/Libraries/NativeAnimation"
  pod 'React-RCTBlob', :path => "#{rn_path}/Libraries/Blob"
  pod 'React-RCTImage', :path => "#{rn_path}/Libraries/Image"
  pod 'React-RCTLinking', :path => "#{rn_path}/Libraries/LinkingIOS"
  pod 'React-RCTNetwork', :path => "#{rn_path}/Libraries/Network"
  pod 'React-RCTSettings', :path => "#{rn_path}/Libraries/Settings"
  pod 'React-RCTText', :path => "#{rn_path}/Libraries/Text"
  pod 'React-RCTVibration', :path => "#{rn_path}/Libraries/Vibration"
  pod 'React-RCTWebSocket', :path => "#{rn_path}/Libraries/WebSocket"

  pod 'React-cxxreact', :path => "#{rn_path}/ReactCommon/cxxreact"
  pod 'React-jsi', :path => "#{rn_path}/ReactCommon/jsi"
  pod 'React-jsiexecutor', :path => "#{rn_path}/ReactCommon/jsiexecutor"
  pod 'React-jsinspector', :path => "#{rn_path}/ReactCommon/jsinspector"
  pod 'yoga', :path => "#{rn_path}/ReactCommon/yoga"

  pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

  pod 'react-native-maps', path: rn_maps_path
  pod 'react-native-google-maps', path: rn_maps_path
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'

  pod 'Firebase/Core'
  pod 'Firebase/Messaging'

  pod 'lottie-ios', :path => '../node_modules/lottie-ios'

  use_native_modules!

end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'react-native-google-maps'
            target.build_configurations.each do |config|
                config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
            end
        end
        if target.name == "React"
            target.remove_from_project
        end
    end
end

I can confirm. I’m on 0.61-rc3 and it works.

@cantonalex Here’s how I fixed mine… I changed to XCode legacy build system and built the project once. After which I changed it to new build system and it has been working properly ever since…

I’m using React Native simple toast library which causes the following errors after upgrading to RN 0.60.3 in XCode when I’m trying to build it: Screenshot 2019-07-16 at 2 03 03 PM Screenshot 2019-07-16 at 2 04 53 PM

Is this case releated to this issue?

Did you solve it? I’m having the same issue.

The changes I made to fix this are included in 0.61.0-rc.3 so that version should now be working with use_frameworks!

RN version: 0.59.9

This issue is only concerned with the new CocoaPods integration in 0.60. Any problem you are having with 0.59.9 is unrelated.

I managed to successfully build after

  1. deleting derived data
  2. removing pods and re-installing
  3. cleaning the build
  4. switching to legacy system.

Not sure which step solved it, but hopefully this helps others.

@jtreanor I don’t think mine or @DaniAkash’s issue is specifically CocoaPods. So maybe we’re posting in the wrong thread. But it has happened in two different projects for me with two different modules. Running RN 60.

Screen Shot 2019-07-22 at 8 46 49 pm

I had the same error message, the solution was that firebase wasn’t listed in the podfile anymore. Not sure how that was connected but I removed third-party packages from podfile before the upgrade to rn 0.60.4 because of the promised auto-linking. but had to re-link all third-party packages later again.

@jtreanor Ah, we will check again. We encountered this issue a few days ago.

I have been looking into this some more and I wanted to give a quick update to share what I have found.

The build error I posted in the description is easily solved by adding "$(PODS_ROOT)/DoubleConversion" to HEADER_SEARCH_PATHS of React-cxxreact, React-jsi and React-jsiexecutor.

Once I did this, I started seeing a different error:

▸ Compiling RCTImageSource.m

❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/ReactCommon/yoga/yoga/CompactValue.h:11:10: 'cmath' file not found

#include <cmath>
           ^~~~~~~~~~~~~~~~~~~~~~~~~



❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/React/Base/RCTConvert.h:17:9: could not build module 'yoga'

#import <yoga/Yoga.h>
         ^~~~~~~

I fixed this by setting header_files in yoga.podspec to yoga/{Yoga,YGEnums,YGMacros,YGValue}.h (reverts the change in https://github.com/facebook/react-native/commit/97e6ea13714c7741d0ba6105523cfebd6e11f963).

Next I saw this error:

▸ Linking React

❌  Undefined symbols for architecture x86_64
> Symbol: google::LogMessageFatal::LogMessageFatal(char const*, int)
> Referenced from: facebook::react::DispatchMessageQueueThread::runOnQueueSync(std::__1::function<void ()>&&) in RCTCxxUtils.o



❌  ld: symbol(s) not found for architecture x86_64



❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)

I solved this by adding React-jsi as a dependency of React-Core.

Now I saw this error:

▸ Linking React

❌  Undefined symbols for architecture x86_64
> Symbol: google::LogMessageFatal::LogMessageFatal(char const*, int)
> Referenced from: facebook::react::DispatchMessageQueueThread::runOnQueueSync(std::__1::function<void ()>&&) in RCTCxxUtils.o



❌  ld: symbol(s) not found for architecture x86_64



❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)

This was solved by adding glog as a dependency of React-Core.

Finally, I am now seeing the following error:

▸ Compiling RCTWebSocketExecutor.m

❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/Libraries/WebSocket/RCTWebSocketExecutor.h:8:9: 'React/RCTDefines.h' file not found

#import <React/RCTDefines.h>
        ^~~~~~~~~~~~~~~~~~~~


▸ Compiling React-RCTWebSocket-dummy.m
▸ Compiling RCTReconnectingWebSocket.m

❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.h:8:9: 'React/RCTDefines.h' file not found

#import <React/RCTDefines.h>
        ^~~~~~~~~~~~~~~~~~~~

This is where I am stuck. It seems that #import <React/X> doesn’t work for any of the Library podspecs. My guess is that this is because React/ has multiple definitions, but I don’t have a very good understanding of how this works.

Update: I have been able to resolve the import error above by changing s.header_dir in the podspec. We probably don’t want to do that since it would break existing includes. Anyway, when I did that, it revealed a bunch of C++ import errors:

▸ Compiling RCTWebSocketExecutor.m

❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.h:8:10: 'memory' file not found

#include <memory>
         ^~~~~~~~



❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/ReactCommon/cxxreact/CxxModule.h:8:10: 'functional' file not found

#include <functional>
         ^~~~~~~~~~~~



❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/ReactCommon/jsi/jsi/jsi.h:9:10: 'cassert' file not found

#include <cassert>
         ^~~~~~~~~



❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/React/CxxBridge/JSCExecutorFactory.h:10:10: could not build module 'jsireact'

#include <jsireact/JSIExecutor.h>
 ~~~~~~~~^



❌  /Users/james/src/tmp/AwesomeProject/ios/Pods/glog/src/glog/logging.h:42:10: 'iosfwd' file not found

#include <iosfwd>
         ^~~~~~~~



❌  /Users/james/src/tmp/AwesomeProject/node_modules/react-native/Libraries/WebSocket/RCTWebSocketExecutor.h:8:9: could not build module 'React'

#import <React/RCTDefines.h>
 ~~~~~~~^