Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode stdint.h #error This file should only be included when compiling with MSVC

I've got a CocoaPods React Native project in Xcode that has been working 99% of the time for the past few months. (the 1% is random stuff like this, linker errors, etc... that comes and goes seemingly at random).

I installed a new Pod and its corresponding npm dependency today, and in the past when I added pods I sometimes have issues until I try things like pod deintegrate, pod install, react-native link and clean the Xcode project, for example. But this time it seems nothing is fixing it.

Every time I build, whether for simulator or physical device, I get the following error from stdint.h

This file should only be included when compiling with MSVC.

It's pretty easy too find the source of the error, it's explicitly user-defined in stdint.h:

screenshot of stdint.h

But I can't for the life of me figure out why it's getting triggered. It says right there in the comments that MSVC is included. To my knowledge, the C-based Xcode compiler should provide the MSVC version to satisfy the conditional. Additionally, throughout the course of my troubleshooting/experimenting the past few hours, the culprit calling the error has changed multiple times. Right now it's coming from RCTFBSDK but earlier it came from RNFirebase.

Checking the full error tree, I can find the files requesting `stdint.h, but given that its such a fundamental file I doubt it's relevant- but here:

Xcode Error tree

Based on my investigation so far, I'm inclined to believe it is a configuration error in Xcode causing the problem, specifically something to do with CocoaPods (but frankly I'm not sure)

All I know is that it works without the Pod/npm dependency (which, by the way, is completely unrelated to Facebook SDK currently throwing the error) and when I add it to package.json and Podfile, do the standard npm install pod install react-native link this happens.

Here is what I've tried:

  • Every single combination of npm install npm update npm link react-native link pod deintegrate pod install
  • Deleted xcworkspace and regenerated it with pod install
  • Removed user-defined error conditional (build was successful but crashed shortly after launch with this error: [fatal][tid:com.facebook.react.ShadowQueue] Exception '*** -[__NSArrayM insertObject:atIndex:]: index 1 beyond bounds for empty array' was thrown while invoking manageChildren on target UIManager with params (...
  • Completely reinstalled Xcode
  • Reverted to previous git commit (from before I added the new pod) and it worked fine
  • Shook my fist at it and yelled (last resort)

Also, I have 100% confidence in my Podfile and package.json integrity. I copied the installation procedure from a well established repository.

I was very surprised to find absolutely zero information regarding this. The closest thing I found relates to C++ (understandably).

Anyone got any theories on this? Thanks. Please let me know any other specific info I did not provide.

like image 674
willbattel Avatar asked Mar 11 '26 22:03

willbattel


1 Answers

To quote RNFirebase co-author:

Ye it's an annoying thing at the moment with having leveldb on cocoa pods

Here's a temporary workaround:

cd ios && rm -rf Pods/leveldb-library/port/win

You may also need to update your Podfile as follows:

pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTWebSocket', # needed for debugging
    # Add any other subspecs you want to use in your project
]

This is to avoid further errors if you're running 0.48.x.

You may want to add the temporary workaround at the end of your Podfile so you don't need to worry about it:

# Temporary workaround for https://github.com/invertase/react-native-firebase/issues/395
post_install do
  `rm -rf Pods/leveldb-library/port/win`
end

Sources:

  • https://github.com/invertase/react-native-firebase/issues/395
  • https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
like image 186
designorant Avatar answered Mar 13 '26 16:03

designorant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!