klaviyo / klaviyo-react-native-sdk

MIT License
4 stars 3 forks source link

Rich Push iOS issue : 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead. #141

Closed youcefswoo closed 5 months ago

youcefswoo commented 5 months ago

Checklist

Description

I was attempting to integrate rich notifications. I followed the instructions step by step in the iOS documentation. I created the Notification Service Extension as mentioned. However, when I downloaded the KlaviyoSwiftExtension using CocoaPods, I encountered the error and couldn't build the project.

Expected behavior

I expected the build to be successful.

Actual behavior

Build error :'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.

Steps to reproduce

Follow the steps to integrate Rich Push.

The Klaviyo React Native SDK version information

0.3.1

Environment Description

react native 0.73.3

ajaysubra commented 5 months ago

@youcefswoo could you please share your podfile?

youcefswoo commented 5 months ago

@youcefswoo could you please share your podfile? @ajaysubra this my Podfile.

image

I m using firebase and react-native-permissions. and for the name of the extension it's RichNotification.

youcefswoo commented 5 months ago

@ajaysubra And this is the error that I encounter in the KlaviyoEnvironment struct when attempting to build the project.

image
ajaysubra commented 5 months ago

Thanks for sharing your podfile. Can you try moving the extension target outside your app target like indicated in step 3 of the iOS installation guide here?

Example of what worked for me in the example app:

target 'KlaviyoReactNativeSdkExample' do
  config = use_native_modules!

  use_frameworks! :linkage => :static

  use_react_native!(
    :path => config[:reactNativePath],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
#    :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'KlaviyoReactNativeSdkExampleTests' do
    inherit! :complete
    # Pods for testing
  end

  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
    )
  end
end

target 'KlaviyoReactNativeSdkExampleExtension' do
  use_frameworks! :linkage => :static
  pod 'KlaviyoSwiftExtension'
end
youcefswoo commented 5 months ago

@ajaysubra After updating the podfile to

image

i got this new build error

Cycle inside APP_NAME; building could produce unreliable results.

ajaysubra commented 5 months ago

@ajaysubra After updating the podfile to

image

i got this new build error

Cycle inside APP_NAME; building could produce unreliable results.

@youcefswoo I created a PR here in the example app that uses KlaviyoSwiftExtension in the podfile. I tested this locally and it seems to work. I have not seen that build error on my end when trying to use extension pod.

youcefswoo commented 5 months ago

@ajaysubra I will check it and update you soon.

youcefswoo commented 5 months ago

@ajaysubra After reviewing the example and following it step by step, I had the same build issue here. I resolved the issue with this suggestion Thanks for your support.

ajaysubra commented 5 months ago

@youcefswoo Thanks for posting your solution here. Closing this issue now. Feel free to reach out if you need anything else.

youcefswoo commented 5 months ago

@ajaysubra thanks