1

https://github.com/salesforce-marketingcloud/react-native-marketingcloudsdk

How can I import salesforce marketing cloud in ios

After npm install and pod install, when I put the below code in AppDelegate.m

MarketingCloudSDKConfigBuilder *mcsdkBuilder = [MarketingCloudSDKConfigBuilder new];
      [mcsdkBuilder sfmc_setApplicationId:@"{MC_APP_ID}"];
      [mcsdkBuilder sfmc_setAccessToken:@"{MC_ACCESS_TOKEN}"];
      [mcsdkBuilder sfmc_setAnalyticsEnabled:@(YES)];
      [mcsdkBuilder sfmc_setMarketingCloudServerUrl:@"{MC_APP_SERVER_URL}"];

      NSError *error = nil;
      BOOL success =
          [[MarketingCloudSDK sharedInstance] sfmc_configureWithDictionary:[mcsdkBuilder sfmc_build]
                                                                     error:&error];

It show some error regarding Use of undeclared identifier. Like Use of undeclared identifier 'mcsdkBuilder'

Thanks

3 Answers 3

3

Please ensure you have imported the SDK's header file at the top of your AppDelegate.m.

#import "AppDelegate.h"
#import <MarketingCloudSDK/MarketingCloudSDK.h>

...

MarketingCloudSDKConfigBuilder *mcsdkBuilder = [MarketingCloudSDKConfigBuilder new];
      [mcsdkBuilder sfmc_setApplicationId:@"{MC_APP_ID}"];
      [mcsdkBuilder sfmc_setAccessToken:@"{MC_ACCESS_TOKEN}"];
      [mcsdkBuilder sfmc_setAnalyticsEnabled:@(YES)];
      [mcsdkBuilder sfmc_setMarketingCloudServerUrl:@"{MC_APP_SERVER_URL}"];

      NSError *error = nil;
      BOOL success =
          [[MarketingCloudSDK sharedInstance] sfmc_configureWithDictionary:[mcsdkBuilder sfmc_build]
                                                                     error:&error];

Also it is important to note that after a pod install you will now need to open the .xcworkspace instead of the .xcodeproj.

2
  • I have already pod install and using .xcworkspace but it still show 'MarketingCloudSDK/MarketingCloudSDK.h' file not found
    – kenny
    Apr 9, 2021 at 2:25
  • @kenny open a support case through your account representative.
    – Bill Mote
    Apr 9, 2021 at 12:06
1

@kenny I resolved this issue by manually linking the library at the base project i.e. react-native link react-native-marketingcloudsdk , now when you run your pod install you should see MarketingCloudSDK being installed as well.

0

Check if you MarketingCloudSDK package is in Podfile.lock with a path to node_modules, and if is inside the Pods path. On the AppDelegate.m, try to import on the top of the file how Skyler said. I had the same problem and solved with this solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .