sentry-react-native: 'Sentry/Sentry.h' file not found

I’m currently using the following packages:

react-native-sentry: 0.14.5
react-native: 0.46.1

I’ve linked the binary with the sentry library but when i build and try to run my app in the simulator I get the following error: Lexical or Preprocessor Issue: Sentry/Sentry.h file not found - RNSentry.m

I’ve tried cleaning my project in xcode, nuking my node_modules and reinstalling, but still no avail. Any help would be greatly appreciated!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 24 (3 by maintainers)

Most upvoted comments

I`ve tried all solutions in this thread with no success. Using:

  • RN 0.59.9,
  • @sentry/react-native": “^1.3.9” (not react-native-sentry)
  • Also noticed that the file Sentry.h does not exists in node_modules/@sentry.
  • On Android it worked perfectly. Any hint?

Go to ios folder and try this:

sudo gem install cocoapods
pod init
pod install

I had this issue too and the only thing that solved it was:

  1. adding $(SRCROOT)/Sentry/Sources (recursive) to the RNSentry’s target Header Search Paths
  2. replacing #import <Sentry/Sentry.h> with #import "Sentry.h"

Here’s the diff:

--- a/node_modules/react-native-sentry/ios/RNSentry.m
+++ b/node_modules/react-native-sentry/ios/RNSentry.m
@@ -6,7 +6,7 @@
 #import "RCTConvert.h"
 #endif
 
-#import <Sentry/Sentry.h>
+#import "Sentry.h"
 
 NSString *const RNSentryVersionString = @"0.39.0";
 NSString *const RNSentrySdkName = @"sentry.javascript.react-native";
--- a/node_modules/react-native-sentry/ios/RNSentry.xcodeproj/project.pbxproj
+++ b/node_modules/react-native-sentry/ios/RNSentry.xcodeproj/project.pbxproj
@@ -314,6 +314,7 @@
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
 					"$(SRCROOT)/../../react-native/React/**",
+					"$(SRCROOT)/Sentry/Sources/**",
 				);
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
 				OTHER_LDFLAGS = "-ObjC";
@@ -332,6 +333,7 @@
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
 					"$(SRCROOT)/../../react-native/React/**",
+					"$(SRCROOT)/Sentry/Sources/**",
 				);
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
 				OTHER_LDFLAGS = "-ObjC";

Hi,

I too am getting this error, but only when archiving a release build (both on our CI server and locally). Project was successfully linked and the debug configuration compiles / runs perfectly.

Here’s the error xcodebuild returns:

▸ Compiling SentryDebugMeta.m
▸ Compiling SentryFileManager.m
▸ Compiling SentryKSCrashReportConverter.m
▸ Compiling SentryBreadcrumbTracker.m
▸ Building library libSentryStatic.a
▸ Building RNSentry/RNSentry [(Release)]
▸ Check Dependencies

❌  /Users/distiller/app_name_omitted/node_modules/react-native-sentry/ios/RNSentry.m:10:9: 'Sentry/Sentry.h' file not found

#import <Sentry/Sentry.h>

Our app is currently using:

react-native: v0.45.1
react-native-sentry: v0.14.6

I’ve already tried cleaning the project and derived data locally (in Xcode ⇧⌘K to clean, ⌥⇧⌘K to clean build folder and ⌘, to open Settings > Locations > Derived data & delete the folders content). However this won’t affect our CI server as it’s fresh every time (caching has been disabled to rule out such issues)

I’ve also unlinked and re-linked to no avail (including the fix @HazAT suggests).

Thanks for any help.

I am using xcode 8.2.1 and Bitrise CI uses xcode 8.3, On my system the code builds without any errors and On CI it through this same error.

If I download the code from the repository and do a local build using Bitrise cli tools it also fails with the same error. But the same code builds successfully from xcode 8.2.1 editor.

This error is introduced recently, I didn’t remember when, earlier CI doesn’t have any problem.

‘Sentry/SentryBinaryImageCache.h’ file not found issue is still coming in Latest versions. Please reopen the issue and solve this. Need permanent solution.

   "react": "18.2.0",
    "react-native": "0.72.4",
     "@sentry/react-native": "^5.9.0",