react-native-batch-push icon indicating copy to clipboard operation
react-native-batch-push copied to clipboard

Compilation error on iOS with react-native 0.68

Open alois-beto opened this issue 4 years ago • 8 comments

With react-native 0.68 the AppDelegate has been converted from ObjC (.m) to ObjC++ (.mm).

This leads to a first compilation error: Use of '@import' when C++ modules are disabled, consider using -fmodules and -fcxx-modules on this line: https://github.com/bamlab/react-native-batch-push/blob/5bad30e1896d30d98a6b13bca1e4dd60f99f99e8/ios/RNBatch.h#L13

This error can be fixed by adding -fcxx-modules to OTHER_CPLUSPLUSFLAGS project build settings. It should be written to installation guide.

After the fix of this first error, I got an other one : Definition of type 'NSUInteger' conflicts with typedef of the same name on a file of iOS Batch native SDK. I created an issue for this: https://github.com/BatchLabs/Batch-iOS-SDK/issues/29. When a fix will be available you should bump your package with the fixed version of the native SDK.

Another thing: I think adding pod 'Batch', '~>1.18' like specified in the Readme: https://github.com/bamlab/react-native-batch-push/blob/5bad30e1896d30d98a6b13bca1e4dd60f99f99e8/README.md?plain=1#L28 is useless because your native package RNBatchPush already defines the native SDK dependency in https://github.com/bamlab/react-native-batch-push/blob/5bad30e1896d30d98a6b13bca1e4dd60f99f99e8/ios/RNBatchPush.podspec#L17 and because you didn't specified a version, the dependency resolution of Cocoapods takes the latest version. In my case Cocoapods installed Batch 1.19 even if I have Batch 1.18 specified in Podfile. If you want specify a precise version of Batch you should precis it in RNBatchPush.podspec

alois-beto avatar May 04 '22 16:05 alois-beto

Would reverting to an old #import <Batch/Batch.h> syntax fix the issue with no other cflag?

abarisain avatar May 04 '22 16:05 abarisain

#import <Batch/Batch.h> is working well and does not require the C++ flag -fcxx-modules 🙂

alois-beto avatar May 05 '22 08:05 alois-beto

hmm, if i change #import "RNBatch.h" to #import <Batch/Batch.h> I then get a different error:

error: use of undeclared identifier 'RNBatch'; did you mean 'rpmatch'?
  [RNBatch start];

rossjohnsonMP avatar May 10 '22 11:05 rossjohnsonMP

The import that should be replaced is the one in RNBatch, not RNBatch itself (which is why you're seeing those errors)

abarisain avatar May 10 '22 11:05 abarisain

ahh so you've used something like patch-package for now to do that?

rossjohnsonMP avatar May 10 '22 12:05 rossjohnsonMP

Exactly! This is my patch package: patches/@bam.tech+react-native-batch+7.0.3.patch:

diff --git a/node_modules/@bam.tech/react-native-batch/ios/RNBatch.h b/node_modules/@bam.tech/react-native-batch/ios/RNBatch.h
index 7ba6fcb..bd3259b 100644
--- a/node_modules/@bam.tech/react-native-batch/ios/RNBatch.h
+++ b/node_modules/@bam.tech/react-native-batch/ios/RNBatch.h
@@ -10,7 +10,7 @@
   #import "RCTEventEmitter.h"
 #endif
 
-@import Batch;
+#import <Batch/Batch.h>
 
 #define PluginVersion "ReactNative/7.0.3"
 

alois-beto avatar May 10 '22 12:05 alois-beto

Also running into this error, thanks for the patch @alois-beto

jasondibenedetto avatar Jun 06 '22 06:06 jasondibenedetto

Thanks @alois-beto for your contribution. I'm closing this issue as Batch released a new version and this repository is being archived. This should be addressed in https://github.com/BatchLabs/Batch-React-Native-Plugin

marekkalnik avatar Jul 28 '22 09:07 marekkalnik