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

RCTAEPCore is undefined #313

Closed
Issactoto opened this issue Dec 18, 2023 · 10 comments
Closed

RCTAEPCore is undefined #313

Issactoto opened this issue Dec 18, 2023 · 10 comments

Comments

@Issactoto
Copy link

Expected Behaviour

Both Android and IOS device run without error

Actual Behaviour

IOS device runs with error saying that RCTAEPCore is undefined.

Reproduce Scenario (including but not limited to)

Run React Native in IOS device

Steps to Reproduce

react-native: 0.72.6
@adobe/react-native-aepcore: ^5.0.0
Yarn/pnpm

Followed all the steps for IOS and Android documented on the readme.

Platform and Version

Mac M2

Sample Code that illustrates the problem

MobileCore.collectPii({ myPii: 'data' });

Logs taken while reproducing problem

 TypeError: Cannot read property 'collectPii' of null
This error is located at:
    in App
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer

I wonder if there is any configuration for IOS missing on the readme. Thank you very much for your help!

@Issactoto
Copy link
Author

Hi. Yes, I did follow the instructions in the links you sent - added the configurations in both AppDelegate.h and AppDelegate.mm and imported the package the way as you mentioned. I got the error on both M1 and M2 Mac laptops. Meanwhile, I am able to run the sample app without any error.

@cacheung
Copy link
Contributor

You need to add import { MobileCore } from '@adobe/react-native-aepcore' to your React Native side of the code, not on the Native platform code.
Similar to the sample app here - https://github.com/adobe/aepsdk-react-native/blob/main/apps/AEPSampleApp/extensions/CoreView.tsx#L15

Did you do that?

@Issactoto
Copy link
Author

Yes, I imported the package in a tsx view file, just like the sample app.

@cacheung
Copy link
Contributor

Is it possible to share your sample project, we can take a look?

@Issactoto
Copy link
Author

Sure, that would be really helpful. I created a new repo using react-native-cli (https://github.com/Issactoto/adobe-analytics-test/tree/main). I just changed all the files accordingly as mentioned above and the function is used in App.tsx. I am using Yarn and IOS 17.2 for your information. Thanks!

@cacheung
Copy link
Contributor

@Issactoto
When I tried to build the repo you provided in Xcode, I saw errors which can be resolved with these two known workaround:
#247 (comment)
#263 (comment)

 post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    installer.pods_project.targets.each do |t|
      if t.name.start_with?("AEP")
        t.build_configurations.each do |bc|
            bc.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -no-verify-emitted-module-interface'
        end
      end
    end
  end
end

Please give them a try and see if you can build.
These are for iOS.
Did you have the issue on Android?

@Issactoto
Copy link
Author

Thank you very much for the reply and solution. It works for the new repo I shared earlier. However, I am actually using a monorepo for the project I am developing and I am still facing the same error. Unfortunately, I am unable to share the code here. Do you happen to know if there are any specific changes that need to be made in this context? Additionally, I want to note that I don't experience any problems when running the code on Android.

@cacheung
Copy link
Contributor

For the original log, we thought it is possible due to the import statement in the react native side.
import { MobileCore } from '@adobe/react-native-aepcore'

This error is located at:
    in App
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer

But it seems like you have that correctly in the sample app you shared.

If using the same react native code and Android platform is working, then the issue is on the iOS side.
Have you tried to run the iOS app from the Xcode and see if there is any other error shown on the Xcode native platform? Or you can monitor the logs in the Xcode debug windows.

@Issactoto
Copy link
Author

Yes, I think there were some errors on the Xcode native platform. I got it sorted now, thank you very much for your help!

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

No branches or pull requests

2 participants