tinycreative / react-native-intercom

React Native wrapper for Intercom.io
MIT License
405 stars 279 forks source link

Use of undeclared identifier 'Intercom' in AppDelegate.m #391

Closed thecodecafe closed 4 years ago

thecodecafe commented 4 years ago

Hi, please I'm running into some problems when using this library. I've installed this library and it works fine in development, but when it's time to build I get an error saying that Intercom is undefined in AppDelegate.m. "Use of undeclared identifier 'Intercom'" I installed intercom-ios manually(since it is recommended), this library installs it also via cocoa pods when I run pod install (I am using react-native 0.63) but I don't get any error for duplicate symbols so I guess that's not an issue. However, in my AppDelegate.m I have the following code.

...
#import "Intercom/intercom.h"
...
// Intercom
[Intercom setApiKey:@"IOS-API-KEY" forAppId:@"APP-ID"];
...
- (void)application:(UIApplication *)application
    didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  // Intercom
  [Intercom setDeviceToken:deviceToken];
}

Here's everything I've done.

  1. I have added Intercom.framework into my project.
  2. I have set it to embed and sign.
  3. I have installed this library via cocoa pods (building fails without no error when I link this library manually I'm using react-native 0.63 so everything React is installed via cocoa pods).
  4. I have added the build phase script.
  5. I have tried installing intercom-ios via cocoa pods.

I think at this point I've already exhausted my options, is there anything else in the docs that I'm missing? Please help, I'm stuck.

thecodecafe commented 4 years ago

You won't believe what solved this for me. If you go into the framework's Headers folder in your workspace (Workspace -> Intercom.framework -> Headers) you will see the Intercom.h file, notice Intercom in the file name is spelt with a capital "i" this means when importing the library in AppDelegate.m you are to import it with a capital "i" like so. #import "Intercom/Intercom.h" in the documentation, however, this is imported with a small letter "i" it might have been correct but not so right no, possibly an update to XCode makes it case sensitive to filenames. See the code below on the corrections you need to make.

Wrong Code

#import "Intercom/intercom.h"

Correct Code

#import "Intercom/Intercom.h"

Closing this as my problem has been solved!