Skip to content

Manual plugin integration for iOS (in case your dependencies do not support `use_frameworks!`)

Davor Komušanac edited this page Dec 5, 2022 · 1 revision

Deprecated : Starting from 6.2.0 plugin version you can integrate plugin without use_frameworks!, check the migration guide.

Some Cocoapod dependencies may not support building as dynamic framework, it may arise following error with use_frameworks! added to the Podfile, when you are doing pod install:

[!] The 'Example' target has transitive dependencies that include statically linked binaries: ...

You can use Manual integration for iOS in this case.

Additional requirements for iOS:

  • Carthage (brew install carthage), version upper 0.37.0

Notice

If previously MobileMessaging plugin was integrated automatically, following steps better to do before doing manual integration:

  • cleanup pods - cd ios & pod deintegrate & pod update
  • cleanup Xcode derived data - Product->Clean Build Folder in Xcode and from Terminal rm -rf ~/Library/Developer/Xcode/DerivedData/*
  • npm start --reset-cache

Manual integration steps

  1. Disable autolinking for plugin - add react-native.config.js file or edit your current.

    module.exports = {
      dependencies: {
        'infobip-mobile-messaging-react-native-plugin': {
          platforms: {
            ios: null,
          },
        },
      },
    };
    
  2. npm install infobip-mobile-messaging-react-native-plugin

  3. Build MobileMessaging.framework

    • cd node_modules/infobip-mobile-messaging-react-native-plugin
    • npm run mm_build
  4. Open your Main app targets' General settings tab in Xcode, scroll to the Frameworks, Libraries, and Embedded Content section, drag and drop MobileMessaging.xcframework from the node_modules/infobip-mobile-messaging-react-native-plugin/ios/Carthage/Build folder. In the "Embed" section, select "Embed and sign" from the pulldown menu.

Add_MM_xcframework
  1. In the targets Build Settings tab add path "$(SRCROOT)/../node_modules/infobip-mobile-messaging-react-native-plugin/ios/Carthage/Build" to the Framework Search Paths. This needs to be done for Main app target and for MobileMessagingNotificationExtension target as well.
Set_FrameworkSearchPaths
  1. Drag and drop node_modules/infobip-mobile-messaging-react-native-plugin/ios/MobileMessagingPlugin folder to your project in xCode, choose Copy items if needed and Create groups options. Add files to your main application target.
dragndrop_Plugin_files
  1. Add bridging header, if it's not exist - create <MainTarget>-Bridging-Header.h file and setup it as Objective-C Bridging Header in Build Settings for you Main app target. Add it to bridging header:
     #import <React/RCTBridgeModule.h>
     #import <React/RCTEventEmitter.h>
     #import <React/RCTViewManager.h>
    

Notice

If you have any problems with creating Bridging Header, just create and add temporary .swift file to your project, xCode will automatically provide dialog with option "Create Bridging Header". After that you can delete this .swift file.

  1. c,d steps from Quick Start Guide->Configure Platforms->iOS
  1. Install and run our special Ruby Gem called "mmine" as described in the 1st step of Notification Service Extension setting up Xcode project instruction

  2. Specify path to MobileMessaging.xcframework in Framework Search Path for MobileMessagingNotificationExtension target as described in the 5th step of Manual integration steps.

How to return back to normal integration, since starting from 6.2.0 plugin version it can be used without use_frameworks!.

  1. Enable back autolinking for plugin - remove react-native.config.js file or remove following from it.

    module.exports = {
      dependencies: {
        'infobip-mobile-messaging-react-native-plugin': {
          platforms: {
            ios: null,
          },
        },
      },
    };
    
  2. Reinstall plugin npm uninstall infobip-mobile-messaging-react-native-plugin && npm install infobip-mobile-messaging-react-native-plugin

  3. Open your Main app targets' General settings tab in Xcode, scroll to the Frameworks, Libraries, and Embedded Content section, remove MobileMessaging.xcframework, repeat the same for the NotificationExtension target if applicable.

  4. In the targets Build Settings tab remove path "$(SRCROOT)/../node_modules/infobip-mobile-messaging-react-native-plugin/ios/Carthage/Build" from the Framework Search Paths. This needs to be done for Main app target and for MobileMessagingNotificationExtension target as well.

  5. Remove group MobileMessagingPlugin with files inside it from your project in xCode

  6. From the ios folder perform pod deintegrate && pod install

  7. You can remove BridgingHeader file if you don't have other swift files in your project's main target.

  8. In the AppDelegate.m file change @import MobileMessaging to the #import <MobileMessaging/MobileMessagingPluginApplicationDelegate.h>

Clone this wiki locally