Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of undeclared identifier 'AEPMobileCore' #346

Open
3 tasks done
jerry7411 opened this issue Apr 16, 2024 · 23 comments
Open
3 tasks done

Use of undeclared identifier 'AEPMobileCore' #346

jerry7411 opened this issue Apr 16, 2024 · 23 comments
Labels

Comments

@jerry7411
Copy link

jerry7411 commented Apr 16, 2024

Prerequisites

  • This is not a Security Disclosure, otherwise please follow the guidelines in Security Policy.
  • I have searched in this repository's issues to see if it has already been reported.
  • I have updated to the latest released version of the SDK and the issue still persists.

Bug summary

Hi guys, I'm trying to implement the latest version of AEP SDK .
I already followed the guidelines and I got this error

Use of undeclared identifier AEPMobileCore

I cannot use any classes from AEP SDK even though I already imported according to the guidelines
image

Environment

Node: 20.12.0
NPM: 10.5.0
Xcode: 15.3
React Native: 0.70.14
React Native AEP SDK: 6.0.0

@jerry7411 jerry7411 added bug Something isn't working triage-required Triage required on a new issue logged for this project. Used by issue templates labels Apr 16, 2024
@cacheung
Copy link
Contributor

@jerry7411, we don't have enough information from you to debug what step was missing in the setup.
Have you followed the installation steps?

Some quick guide:

  1. Install packages
    e.g npm install @adobe/react-native-aepcore

  2. Go to iOS folder to run pod install
    https://github.com/adobe/aepsdk-react-native?tab=readme-ov-file#ios-development

  3. Initializing SDK
    https://github.com/adobe/aepsdk-react-native?tab=readme-ov-file#initializing

It should be able to run the app. If you see error, you can look at the troubleshooting and known issues

@jerry7411
Copy link
Author

jerry7411 commented Apr 17, 2024

Hi @cacheung ,
I already followed exactly the installation steps
Maybe Xcode cannot index the AEP classes and interfaces.
I'm wondering if it could be related to arm64 and x86_64 architecture?

@cacheung
Copy link
Contributor

cacheung commented Apr 18, 2024

Hi @jerry7411
Which architecture you are using to reproduce the issue? What's your Xcode version?

Any error you see other than the undeclared identifier error?
Can you attach the logs you see in the Xcode debug window here to show us?

@cacheung
Copy link
Contributor

Hi @jerry7411 , do you have any more info about how to reproduce it?

@snowiesuet
Copy link

Hello @cacheung, I'm experiencing this error as well:
Screenshot 2024-05-01 at 3 25 10 PM

Screenshot 2024-05-01 at 3 33 05 PM

@jerry7411, we don't have enough information from you to debug what step was missing in the setup. Have you followed the installation steps?

Some quick guide:

1. Install packages
   e.g npm install @adobe/react-native-aepcore

2. Go to iOS folder to run pod install
   https://github.com/adobe/aepsdk-react-native?tab=readme-ov-file#ios-development

3. Initializing SDK
   https://github.com/adobe/aepsdk-react-native?tab=readme-ov-file#initializing

It should be able to run the app. If you see error, you can look at the troubleshooting and known issues

I've followed the steps above and I see the AEM packages in my Pods folder:
Screenshot 2024-05-01 at 3 26 24 PM
imported them in my .h file

Screenshot 2024-05-01 at 3 32 07 PM

I can't figure out what I'm missing and been stuck for days, could you please assist me? Thank you!

Environment:
Node: v18.19.1
React-native: 0.70.8
react-native-aepcore: 6.0.1
Xcode: 15.3

@cacheung
Copy link
Contributor

cacheung commented May 1, 2024

You have an error "Import of C++ module 'Foundation' appears within extern "C" language linkage specification. You might want to fix that first. The libraries can be blocked to import with errors.

Seems like you are using expo? We don't officially support expo. We recommend users to use React Native CLI environment to build with Adobe mobile aepsdk-react-native.
https://reactnative.dev/docs/environment-setup?package-manager=npm&guide=native (React Native CLI)

Our sample app of the AppDelegate.h and AppDelegate.mm files.

If you can provide a sample skeleton package, we can debug it, that would be great.

@snowiesuet
Copy link

You're right @cacheung I do think its an issue with expo installer, i created new projects one with Expo and one with React Native Cli and the one with Expo have the same errors as above :(

@cacheung
Copy link
Contributor

cacheung commented May 6, 2024

@snowiesuet So it works with your React Native Cli setup?
We are not official support for Expo due to our sdk has native platforms setup requirement.
We will record in our feature request list.

@mayank-shekhar
Copy link
Member

Hi, one workaround is that you can try to eject the expo app to get the required ios/android files.

  1. Eject the Expo app.
npx expo prebuild
  1. Follow the installation steps

You can still run the expo commands to run the app locally.

@tr3v3r
Copy link

tr3v3r commented May 10, 2024

@cacheung we have completely the same error, but we use Bare React Native and installed the expo module (expo-image). It's not an option for us to get rid of expo module - any suggestions / workarounds?

image

@tr3v3r
Copy link

tr3v3r commented May 10, 2024

Ok it seems this could help:

#247 (comment)

@cacheung
Copy link
Contributor

@tr3v3r I haven't got chance to look into the Expo environment closely. Good you found the possible fix. Can you let me know if this solution works after you test it?

@tr3v3r
Copy link

tr3v3r commented May 14, 2024

@tr3v3r I haven't got chance to look into the Expo environment closely. Good you found the possible fix. Can you let me know if this solution works after you test it?

Yes, that works!

Instead of initializing directly in AppDelegeate, I've created a separate module and call it in AppDelegate.mm:

  1. Create files AdobeBridge.h and AdobeBridge.m for your iOS project with the following content:

AdobeBridge.h

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface AdobeBridge : NSObject
+ (void)configure: (UIApplicationState)state;
@end

AdobeBridge.m

#import "AdobeBridge.h"
#import <UIKit/UIKit.h>
@import AEPCore;
@import AEPEdgeIdentity;
@import AEPEdgeConsent;
@import AEPAssurance;
@import AEPEdge;
@import AEPIdentity;
@import AEPLifecycle;
@import AEPSignal;
@import AEPServices;
@import AEPUserProfile;
@import AEPOptimize;
@implementation AdobeBridge
+ (void)configure: (UIApplicationState)appState
{
  [AEPMobileCore setLogLevel: AEPLogLevelDebug];
  NSArray *extensionsToRegister = @[
      AEPMobileEdgeIdentity.class,
      AEPMobileEdgeConsent.class,
      AEPMobileAssurance.class,
      AEPMobileEdge.class,
      AEPMobileIdentity.class,
      AEPMobileLifecycle.class,
      AEPMobileOptimize.class,
      AEPMobileSignal.class,
      AEPMobileUserProfile.class
      ];
      [AEPMobileCore registerExtensions:extensionsToRegister completion:^{
        [AEPMobileCore configureWithAppId: @"KEY"];
        if (appState != UIApplicationStateBackground) {
            [AEPMobileCore lifecycleStart:@{@"": @""}];
        }
    }];
}
@end
  1. Update AppDelegate.mm as:
#import "AdobeBridge.h" // add this import
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  [AdobeBridge configure: application.applicationState]; // Add this line
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@sdubey01
Copy link

@tr3v3r I haven't got chance to look into the Expo environment closely. Good you found the possible fix. Can you let me know if this solution works after you test it?

Yes, that works!

Instead of initializing directly in AppDelegeate, I've created a separate module and call it in AppDelegate.mm:
...

Can you clarify if you are running on an M1 (or M2) macbook. I have attempted to get this working in a project that has been upgraded to RN 72 with Expo SDK 49 but keep running into this error
"Undefined symbols for architecture x86_64:
"OBJC_CLASS$_AdobeBridge", referenced from: in AppDelegate.old: symbol(s) not found for architecture x86_64"

We are a bare RN app with the Expo SDK dependency for a number of native modules and removing the Expo SDK is not an option for us. I need to find a way to get the Adobe code to work with the Expo SDK setups.

@tr3v3r
Copy link

tr3v3r commented May 20, 2024

Hello @sdubey01,

I use M1 pro max, Xcode 15.3.

It seems you have another problem. My issue was connected with the language conflict between adobe sdk and expo sdk as I understand.

@sdubey01
Copy link

Hello @sdubey01,

I use M1 pro max, Xcode 15.3.

It seems you have another problem. My issue was connected with the language conflict between adobe sdk and expo sdk as I understand.

Thanks for clarifying. It at least rules out the M1 architecture as my issue. I will have to try this approach on the older branch I have for RN 70 or 71 to see if it is an issue with the RN 72/Expo 49 configurations. So frustrating that the 'official response' seems to be 'Expo is not supported' with no real effort to sort out why there is a conflict between the two SDK's. The Expo SDK is widely used for native feature access!

@yangyansong-adbe yangyansong-adbe added Expo and removed bug Something isn't working triage-required Triage required on a new issue logged for this project. Used by issue templates labels May 20, 2024
@beatlecz
Copy link

We have the same problem with implementing your library into Expo project. We use expo development client, and we are able to integrate almost everything except your library.

@sdubey01
Copy link

sdubey01 commented May 30, 2024

@cacheung or @yangyansong-adbe - Can you confirm if there is any official statement of support (or no support) for Bare React Native apps that use the Expo SDK for native integrations (like media files, camera, location access, etc.) ?

I am supporting an app for a large company migrating from the ACP SDK to the AEP SDK and we are having major issues getting iOS to build. Android seems to build and collect analytics as expected but iOS fails. We are not able to use the suggested '-fcxx-modules' build flag because of the Expo SDK. I also have not been successful in getting the suggested 'alternate solution' of using a separate AdobeBridge.h and AdobeBridge.mm to work in this application as others have posted about. Taking this approach leaves me with a new build error referencing "OBJC_CLASS$_AdobeBridge", referenced from: in AppDelegate.old: symbol(s) not found for architecture x86_64"

@cacheung
Copy link
Contributor

cacheung commented Jun 3, 2024

@sdubey01 We are not officially supporting Bare React Native apps that use the Expo SDK at this moment. We are currently in the process of evaluating the scope and details of the work required for this support internally.

@sainjay
Copy link

sainjay commented Jun 11, 2024

@cacheung what's the workaround or setup process for Expo - managed project? I'm on React Native 0.74.2 and Expo - 51.0.11. We have to keep our application updated to the latest version because of the security vulnerability.
Can you share the steps for integrating Adobe Analytics in Expo managed project?

@cacheung
Copy link
Contributor

@sainjay There is currently no official workaround for integrating Expo with the Mobile SDK for React Native, some users have reported success with certain steps mentioned in this thread. I recommend exploring those steps to see if they work for your specific use case. Our team is actively evaluating Expo support requirements. If you need further assistance, consider reaching out to Adobe support via a ticket for Expo-related inquiries.

@sainjay
Copy link

sainjay commented Jun 12, 2024

@tr3v3r I haven't got chance to look into the Expo environment closely. Good you found the possible fix. Can you let me know if this solution works after you test it?

Yes, that works!

Instead of initializing directly in AppDelegeate, I've created a separate module and call it in AppDelegate.mm:

  1. Create files AdobeBridge.h and AdobeBridge.m for your iOS project with the following content:

AdobeBridge.h

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface AdobeBridge : NSObject
+ (void)configure: (UIApplicationState)state;
@end

AdobeBridge.m

#import "AdobeBridge.h"
#import <UIKit/UIKit.h>
@import AEPCore;
@import AEPEdgeIdentity;
@import AEPEdgeConsent;
@import AEPAssurance;
@import AEPEdge;
@import AEPIdentity;
@import AEPLifecycle;
@import AEPSignal;
@import AEPServices;
@import AEPUserProfile;
@import AEPOptimize;
@implementation AdobeBridge
+ (void)configure: (UIApplicationState)appState
{
  [AEPMobileCore setLogLevel: AEPLogLevelDebug];
  NSArray *extensionsToRegister = @[
      AEPMobileEdgeIdentity.class,
      AEPMobileEdgeConsent.class,
      AEPMobileAssurance.class,
      AEPMobileEdge.class,
      AEPMobileIdentity.class,
      AEPMobileLifecycle.class,
      AEPMobileOptimize.class,
      AEPMobileSignal.class,
      AEPMobileUserProfile.class
      ];
      [AEPMobileCore registerExtensions:extensionsToRegister completion:^{
        [AEPMobileCore configureWithAppId: @"KEY"];
        if (appState != UIApplicationStateBackground) {
            [AEPMobileCore lifecycleStart:@{@"": @""}];
        }
    }];
}
@end
  1. Update AppDelegate.mm as:
#import "AdobeBridge.h" // add this import
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  [AdobeBridge configure: application.applicationState]; // Add this line
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

Tried this in RN 0.74.2 and Expo 51.0.11, facing the following error:

image

Any suggestions on how to get rid of this error?

@sainjay
Copy link

sainjay commented Jun 17, 2024

For project using Expo 51, RN 0.74, you can use the following configuration:

AppDelegate.h

`
#import <RCTAppDelegate.h>
#import <UIKit/UIKit.h>
// #import <Expo/Expo.h>

#import <ExpoModulesCore/EXAppDelegateWrapper.h>
@interface AppDelegate : EXAppDelegateWrapper

@EnD
`

AppDelegate.mm

`
@import AEPRulesEngine;
@import AEPCore;
@import AEPLifecycle;
@import AEPEdge;
@import AEPEdgeIdentity;
@import AEPEdgeBridge;
@import AEPAssurance;
@import AEPSignal;

@implementation AppDelegate

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"main";

// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};

// Initialize Adobe SDK
[AEPMobileCore setLogLevel:AEPLogLevelDebug];
[AEPMobileCore configureWithAppId:@"appIDKey"];

const UIApplicationState appState = application.applicationState;

[AEPMobileCore registerExtensions: @[
AEPMobileLifecycle.class,
AEPMobileEdge.class,
AEPMobileSignal.class,
AEPMobileIdentity.class,
AEPMobileAssurance.class,
AEPMobileEdgeIdentity.class,
AEPMobileEdgeBridge.class
] completion:^{
if (appState != UIApplicationStateBackground) {
[AEPMobileCore lifecycleStart:nil];
}
}];

return [super application:application didFinishLaunchingWithOptions:launchOptions];
}`

Add the flags as per: #247

This works and builds successfully. Android is also building without issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants