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
- Create a new project:
react-native init AwesomeProject --version 0.60.0-rc.2
. - Add
use_frameworks!
to the top ofios/Podfile
- Install pods:
cd ios && pod install
. - 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
- Demonsrtate fix for https://github.com/facebook/react-native/issues/25349 — committed to jtreanor/react-native-cocoapods-frameworks by jtreanor 5 years ago
- Demonsrtate fix for https://github.com/facebook/react-native/issues/25349 — committed to jtreanor/react-native-cocoapods-frameworks by jtreanor 5 years ago
- Demonsrtate fix for https://github.com/facebook/react-native/issues/25349 — committed to jtreanor/react-native-cocoapods-frameworks by jtreanor 5 years ago
- CocoaPods frameworks compatibility: Step 1 (#25496) Summary: This is the first step towards fixing https://github.com/facebook/react-native/issues/25349. These are the changes to the podspec to corre... — committed to facebook/react-native by jtreanor 5 years ago
- Remove 's.static_framework = true' requirement for podspec (#25816) Summary: As part of the fix for https://github.com/facebook/react-native/issues/25349 I added `s.static_framework = true` to each p... — committed to facebook/react-native by jtreanor 5 years ago
- Test RNTesterPods on CI with use_frameworks! enabled (#25818) Summary: This adds a `test_ios_frameworks` job to CircleCI to test the `RNTesterPods` project with `use_frameworks!` enabled. It will ens... — committed to facebook/react-native by jtreanor 5 years ago
- - [dependencies][android] remove all Firebase SDKs in favour of Firebase BoM - [android] upgrade to Android X - [android] upgrade gradle wrapper to v5.4.1 - [android][ios][tests] remove manual package... — committed to invertase/react-native-firebase by Salakar 5 years ago
- CocoaPods frameworks compatibility: Step 1 (#25496) Summary: This is the first step towards fixing https://github.com/facebook/react-native/issues/25349. These are the changes to the podspec to corre... — committed to TMomemt/react-native by jtreanor 5 years ago
- CocoaPods frameworks compatibility: Step 2 (#25619) Summary: This is my proposal for fixing `use_frameworks!` compatibility without breaking all `<React/*>` imports I outlined in https://github.com/f... — committed to TMomemt/react-native by jtreanor 5 years ago
- Remove 's.static_framework = true' requirement for podspec (#25816) Summary: As part of the fix for https://github.com/facebook/react-native/issues/25349 I added `s.static_framework = true` to each p... — committed to TMomemt/react-native by jtreanor 5 years ago
- Test RNTesterPods on CI with use_frameworks! enabled (#25818) Summary: This adds a `test_ios_frameworks` job to CircleCI to test the `RNTesterPods` project with `use_frameworks!` enabled. It will ens... — committed to TMomemt/react-native by jtreanor 5 years ago
- CocoaPods frameworks compatibility: Step 1 (#25496) Summary: This is the first step towards fixing https://github.com/facebook/react-native/issues/25349. These are the changes to the podspec to corre... — committed to react-native-tvos/react-native-tvos by jtreanor 5 years ago
- CocoaPods frameworks compatibility: Step 1 (#25496) Summary: This is the first step towards fixing https://github.com/facebook/react-native/issues/25349. These are the changes to the podspec to corre... — committed to react-native-tvos/react-native-tvos by jtreanor 5 years ago
- - [dependencies][android] remove all Firebase SDKs in favour of Firebase BoM - [android] upgrade to Android X - [android] upgrade gradle wrapper to v5.4.1 - [android][ios][tests] remove manual package... — committed to uphold-forks/react-native-firebase by Salakar 5 years ago
- - [dependencies][android] remove all Firebase SDKs in favour of Firebase BoM - [android] upgrade to Android X - [android] upgrade gradle wrapper to v5.4.1 - [android][ios][tests] remove manual package... — committed to vixtech/react-native-firebase by Salakar 5 years ago
- - [dependencies][android] remove all Firebase SDKs in favour of Firebase BoM - [android] upgrade to Android X - [android] upgrade gradle wrapper to v5.4.1 - [android][ios][tests] remove manual package... — committed to vixtech/react-native-firebase by Salakar 5 years ago
- - [dependencies][android] remove all Firebase SDKs in favour of Firebase BoM - [android] upgrade to Android X - [android] upgrade gradle wrapper to v5.4.1 - [android][ios][tests] remove manual package... — committed to hmhm2292/react-native-firebase by Salakar 5 years ago
- - [dependencies][android] remove all Firebase SDKs in favour of Firebase BoM - [android] upgrade to Android X - [android] upgrade gradle wrapper to v5.4.1 - [android][ios][tests] remove manual package... — committed to androidIsForVivek/react-native-firebase by Salakar 5 years ago
- - [dependencies][android] remove all Firebase SDKs in favour of Firebase BoM - [android] upgrade to Android X - [android] upgrade gradle wrapper to v5.4.1 - [android][ios][tests] remove manual package... — committed to androidIsForVivek/react-native-firebase by Salakar 5 years ago
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:
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
We faced a very similar issue when doing cocoapod repo lint when
React-cxxreact
was added as a dependency together withDoubleConversion
andFolly
. 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:
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 removinguse_frameworks!
from your Podfile or using the lastest RN frommaster
.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'
toReact-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 thatReact-Core
now exposes C++ headers, such asJSCExecutorFactory.h
. Since the module is imported by plain old Objective C headers, such asRCTWebSocketExecutor.h
above, Xcode tries to build the C++ headers as ObjC and fails. This was not the case before the split asReact/CxxBridge
andReact/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:
React-Core.podspec
intoReact-Core.podspec
,React-CxxBridge.podspec
and a third podspec with shared logic (since dependencies can’t be circular).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!
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 removeuse_frameworks!
,pod install
gives me this error: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 eitheruse_modular_headers!
oruse_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:
This is my Podfile:
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…
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!
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
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.
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"
toHEADER_SEARCH_PATHS
ofReact-cxxreact
,React-jsi
andReact-jsiexecutor
.Once I did this, I started seeing a different error:
I fixed this by setting
header_files
inyoga.podspec
toyoga/{Yoga,YGEnums,YGMacros,YGValue}.h
(reverts the change in https://github.com/facebook/react-native/commit/97e6ea13714c7741d0ba6105523cfebd6e11f963).Next I saw this error:
I solved this by adding
React-jsi
as a dependency ofReact-Core
.Now I saw this error:
This was solved by adding
glog
as a dependency ofReact-Core
.Finally, I am now seeing the following error:
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 becauseReact/
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: