0

I have been following this tutorial, which is talking about how to communicated from React Native and objective C. I followed the tutorial, and got a good result. The problem started when I wanted to add a new function called sendData. This would be called in JS and it would pass a string, and in objective C, it would receive the string.

But, the bridging wasn't working.

Here is my code:

RCT_REMAP_METHOD(sendData : (NSString*)str,
                 sendData_resolver:(RCTPromiseResolveBlock)resolve
                 sendData_rejecter:(RCTPromiseRejectBlock)reject)
{
  BOOL response = [_cppApi sendData];
  resolve(response);
}

This code gives the error No visible @interface for 'CCCppCom' declares the selector 'sendData' in Xcode. (CCCppCom is a header file) another function I have, which is getData seems to work fine.

RCT_REMAP_METHOD(getData,
                 resolver:(RCTPromiseResolveBlock)resolve
                 rejecter:(RCTPromiseRejectBlock)reject)
{
  NSString *response = [_cppApi getData];
  resolve(response);
}

I'm not entirely sure what is going on here. I checked CCCppCom, and sendData is indeed there.

Can someone help me? Thanks in advance.

  • Hi @Mannan Could you just share the complete ```CCCppCom.h``` and ```CCCppCom.m``` files here – EL173 Oct 31 '20 at 10:23

1 Answers1

0

I solved the problem by using RCT_EXPORT_METHOD instead of RCT_REMAP_METHOD.