[ios] Fails to build with default XCode 10 settings
Issue
Below is set of errors that pops up during Compiling RNFirebaseFunctions.m step of the build. Most suggestions online ask to clear build / derived data folder, but it doesn't seem to help.
▸ Building RNFirebase/RNFirebase [Release] ▸ Check Dependencies ▸ Compiling RNFirebaseFunctions.m
❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:10: could not build module 'Darwin' #include <sys/types.h> ~~~~~~~ ^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/usr/include/dispatch/dispatch.h:25:10: could not build module 'Darwin' #include <Availability.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/usr/include/os/object.h:25:10: could not build module 'Darwin' #include <Availability.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: could not build module 'CoreFoundation' #include <CoreFoundation/CoreFoundation.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/usr/include/objc/objc.h:31:10: could not build module 'Darwin' #include <sys/types.h> // for __DARWIN_NULL ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:27:10: could not build module 'Darwin' #include <TargetConditionals.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreServices.framework/Headers/UTCoreTypes.h:19:10: could not build module 'CoreFoundation' #include <CoreFoundation/CoreFoundation.h> ~~~~~~~~^ ❌ /Users/vagrant/git/packages/skimitar-app/node_modules/react-native-firebase/ios/RNFirebase/functions/RNFirebaseFunctions.h:3:9: could not build module 'Foundation' #import <Foundation/Foundation.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:9: could not build module 'Foundation' #import <Foundation/Foundation.h> ~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBase.h:8:10: could not build module 'Darwin' #include <stdbool.h> ~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CABase.h:11:10: could not build module 'Darwin' #include <stdbool.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/EAGL.h:8:10: could not build module 'Foundation' #include <Foundation/Foundation.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLDefines.h:8:9: could not build module 'Darwin' #import <os/availability.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceBase.h:12:10: could not build module 'Darwin' #include <sys/cdefs.h> ~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImageDefines.h:10:10: could not build module 'Darwin' #include <TargetConditionals.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CoreVideo.h:16:10: could not build module 'Darwin' #include <TargetConditionals.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/ImageIO.framework/Headers/ImageIOBase.h:11:10: could not build module 'Darwin' #include <stdbool.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreText.framework/Headers/CTDefines.h:12:10: could not build module 'Darwin' #include <Availability.h> ~~~~~~~~^ ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h:8:9: could not build module 'Foundation' #import <Foundation/Foundation.h> ~~~~~~~~^ ▸ Compiling RNFirebaseInstanceId.m ❌ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:10: could not build module 'Darwin' #include <sys/types.h> ^~~~~~~~ ** ARCHIVE FAILED **
Environment
- Application Target Platform: iOS
- Development Operating System: macOS Mojave 10.14
- Build Tools: XCode 10 (set to legacy build setting)
React Nativeversion: 0.57.1
React Native FirebaseVersion: 5.0.0-rc5
FirebaseModule: Functions?
- Are you using
typescript? yes
Loving react-native-firebase? Please consider supporting them with any of the below:
- 👉 Back financially via Open Collective
- 👉 Follow
React Native FirebaseandInvertaseon Twitter - 👉 Star this repo on GitHub ⭐️
Completely closing xcode, reinstalling node_modules and cleaning derrived data / build helped.
How did you fix this on your CI? I'm facing the same issue on Bitrise
@Fouppy My ci is still broken, but this is not an issue with react native firebase. I assume you updated to XCode 10 there? I'm on bitrise as well, using fastlane and got everything in place to clean build folder and clear derrived data, but for some reason it is not doing the trick :/ I assume it might be an issue with fastlane in my case
Here is an issue I opened there https://github.com/fastlane/fastlane/issues/13436
Meanwhile I am waiting for feedback here, to see if I can set up a bash script to clean all of these areas before building https://stackoverflow.com/questions/52517921/bash-script-to-clean-xcode-10-build-derived-data-folders
Any fix for this yet? I am also using CI and get the exact same issue on two of my projects. Two other projects with the same setup works just fine. I can't seem to find whats different and causing this.
This is probably related to https://github.com/firebase/firebase-ios-sdk/issues/1916 ?
Also having mostly random build failures here, when building from scratch on CircleCI (with Xcode 9.4.1, Firebase 5.9.0, react-native-firebase 5.0.0)
The firebase-ios-sdk issue referenced above has a hint that this might be related to the header map setting? The error messages I'm getting are a bit undeterministic but along the lines of
❌ /Users/distiller/user/projects/xyz/node_modules/react-native-firebase/ios/RNFirebase/instanceid/RNFirebaseInstanceId.h:3:9: could not build module 'Foundation'
#import <Foundation/Foundation.h>
~~~~~~~~^
▸ Compiling RNFirebaseAdMobRewardedVideo.m
▸ Compiling RCTConvert+UIBackgroundFetchResult.m
** ARCHIVE FAILED **
The following build commands failed:
CompileC /Users/distiller/Library/Developer/Xcode/DerivedData/xyz-ankmumdxtthuucctmkmqtifwqzxf/Build/Intermediates.noindex/ArchiveIntermediates/Staging/IntermediateBuildFilesPath/RNFirebase.build/Release-iphoneos/RNFirebase.build/Objects-normal/armv7/RNFirebaseInstanceId.o RNFirebase/instanceid/RNFirebaseInstanceId.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
[08:07:00]: Exit status: 65
I just managed to wire up our iOS build to bitrise (we use Buddybuild for CI, but i'm more familiar with bitrise so I decided to give it a shot). i ran into the same issue with pulling in the incorrect time.h header.
what was interesting, though, is that bitrise seemed to compile successfully before i got all the signing cert stuff set up correctly on bitrise. it seemed to compile RNFIrebaseInstanceId.m and other RNFirebase files without complaining, until barfing because of a lack of signing certs (error: exportArchive: No signing certificate "iOS Distribution" found).
once i fixed the signing / cert config, i then saw the familiar time.h build error again.
i'm not that familiar with the iOS build system (I'm primarily an android dev), so i'm not sure if what i saw was just a red herring.
I am facing the same issue as the author of this thread. My app was running fine on the simulator but when I changed for the generic build it started throwing the errors outlined here. I have no knowledge of the ios build system so don't know what to do..
@hugopretorius72 @gabsschneider @julo15 @codeflows This issue is not related to react-native-firebase per se, after tinkering with it for a while I believe its something to do with XCode 10's legacy build system not being used on CI.
Me and my friend both set our XCode's to use legacy build system, it changed some entry in plist file, so we thought that it will persist everywhere, however when we pulled our repo on a new machine that used fresh version of XCode, it was not set to build system.
Easiest workaround atm is to deploy via non-ci i.e. straight from XCode or revert to earlier react version.
There is also this response I got from bitrise ci support
According to the Xcode documentation you can disable the modern buildsystem using the -UseModernBuildSystem=0
Thats a flag xcode cli tools use ^ I think you can specify it in fastlane or ci tool you are using to archive your apps.
Also, this will likely be resolved with react-native 0.58 as there are efforts being made to make it work with XCode's new build system. https://github.com/facebook/react-native/pull/21458
Hope this helps :)
EDIT: Although it seems you guys are getting same error on v9 of XCode, so I'm not entirely sure that this is what is causing the issue.
You can persist the legacy build system by making sure to add the following file as part of git: https://github.com/invertase/react-native-firebase-starter/blob/master/ios/RNFirebaseStarter.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings - with the setting of course.
I've been having the same issue intermittently (in fact, most of the time) even with XCode 9.
Here's an example of the failing output:
▸ Building library libReactNativeTestFairy.a
▸ Building library libReactNativeTestFairy.a
▸ Building RNFirebase/RNFirebase [Release]
▸ Check Dependencies
▸ Compiling RNFirebaseFunctions.m
❌ /Applications/Xcode-10.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:10: could not build module 'Darwin'
#include <sys/types.h>
^~~~~~~~
And here's a link to an example failing build:
https://circleci.com/gh/dwmkerr/gameboard/945
Reproduction Steps
Push any code to build on CircleCI, it will most likely fail with errors similar to the above. However, it will not fail when building locally. I'm using Fastlane. Here's a link to the repo:
https://github.com/dwmkerr/gameboard/
And the Fastfile:
https://github.com/dwmkerr/gameboard/blob/master/fastlane/Fastfile
To run locally, just use make ios.
What I've Tried
- Cleaning Caches / Derived Data
- Upgrading to XCode 10
- Forcing 'use legacy build' with
xcargs: "-UseModernBuildSystem=0" - Forcing 'use legacy build' with
xcargs: "-UseNewBuildSystem=NO" - Making sure the
xcsettingsare committed, as per @Salakar's suggestion
I just can't get these builds to work now on CircleCI, any other suggestions for what could be going on?
I think this is a RNFirebase issue, if it was simply due to race conditions with the build, I'd expect to see different failures. I have consistently seen the failure with the exact same step, just like @IljaDaderko has. I'd suggest we re-open the issue.
I'd like to have this re-opened as well, our situation is similar to @dwmkerr's. Xcode 9, Circle CI, Fastlane. Working locally 100% of the time but never on the CI.
@Salakar I think this is worth re-opening now, here is additional context: [email protected] was released that claims to fix XCode 10's build issues i.e. we can use default one instead of legacy now: https://twitter.com/Kelset/status/1062390902616920065
However this error keeps happening, now on any build either dev / prod / local or ci if new build system is enabled. Whats curious is that a lot of react / third party libs compile fine before it hits RNFirebase, leading me to think that this might be specific to the library?
If anyone feels brave, I got this working when I changed my project to use react and RNFirebase via CocoaPods (not recommended if you are not comfortable with XCode / iOS dev practices) https://facebook.github.io/react-native/docs/integration-with-existing-apps
Judging by https://github.com/facebook/react-native/issues/20774#issuecomment-438609643
issue that react-native-firebase is having can still be on react-native side, although before I started using CocoaPods approach I applied all necessary patches and still got this error :/
Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
Please do not close this. I am still having the issue
I'm also having the same issue.
@mtnptrsn @ukris Are you guys seeing same error as in https://github.com/invertase/react-native-firebase/issues/1529#issue-363711231 or something else?
Could you drop your environment info. Also is this happening locally or in CI environment? Debug or Release builds?
Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.