iosxcodereact-nativelinker-errorsintercom-ios

react-native-intercom throws cryptic error - Undefined symbols for architecture x86_64


I am using react-native-intercom plugin along with latest intercom ios library using manual linking.

The project is building fine till linking stage and then throws this error.

I have done all the steps described in the intercom manual linking process including adding the strip frameworks script as run script phase in build settings.

This is the error message it throws.

undef: _OBJC_CLASS_$_ICMCompany
undef: _OBJC_CLASS_$_ICMUserAttributes
undef: _IntercomUnreadConversationCountDidChangeNotification
undef: _OBJC_CLASS_$_Intercom
Undefined symbols for architecture x86_64:
   "_OBJC_CLASS_$_ICMCompany", referenced from:
  objc-class-ref in libRNIntercom.a(IntercomUserAttributesBuilder.o)
  "_OBJC_CLASS_$_ICMUserAttributes", referenced from:
  objc-class-ref in libRNIntercom.a(IntercomUserAttributesBuilder.o)
  "_IntercomUnreadConversationCountDidChangeNotification", referenced 
from:
  ___48-[IntercomEventEmitter handleUpdateUnreadCount:]_block_invoke in libRNIntercom.a(IntercomEventEmitter.o)
  -[IntercomEventEmitter constantsToExport] in libRNIntercom.a(IntercomEventEmitter.o)
  -[IntercomEventEmitter supportedEvents] in libRNIntercom.a(IntercomEventEmitter.o)
  -[IntercomEventEmitter startObserving] in libRNIntercom.a(IntercomEventEmitter.o)
 "_OBJC_CLASS_$_Intercom", referenced from:
  objc-class-ref in AppDelegate.o
 (maybe you meant: _OBJC_CLASS_$_IntercomUserAttributesBuilder, 
 _OBJC_CLASS_$_IntercomWrapper , _OBJC_CLASS_$_IntercomEventEmitter )
 ld: symbol(s) not found for architecture x86_64
 clang: error: linker command failed with exit code 1 (use -v to see 
 invocation)

I presume its something do with the framework architectures supported by the project but I am a novice on iOS builds and don't have a clue as to how to fix this.


Solution

  • During the Intercom installation there is a step to add a "Run Script Phase":

    bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Intercom.framework/strip-frameworks.sh"

    You need to make sure this phase is actually being executed.

    Try using an invalid path e.g. /Intercom.framework/foo/strip-frameworks.sh, and if the build process does not error due to the above change, then there are issues elsewhere and you need make sure you have followed the other installation steps correctly.

    As long as this script runs it will strip the framework correctly.

    Took me a while too but I was able to debug it this way and eventually got it working with 12.3.0.