customerio / customerio-reactnative

MIT License
23 stars 11 forks source link

Cannot install Pods after setting up rich push notifications #69

Closed lucasbeatdapp closed 1 year ago

lucasbeatdapp commented 1 year ago

SDK version: "customerio-reactnative": "^2.0.0-beta.1"

Environment: Development

Are logs available?

[!] The 'Pods-NotificationService' target has transitive dependencies that include statically linked binaries: (CustomerIOTracking-static, CustomerIOCommon-static, and CustomerIOMessagingPush-static)

Describe the bug Following CustomerIO React Native Documentation for rich push notifications.

I followed all of the steps to set up rich push notifications on android and ios On IOS I'm getting stuck.

I created the NotificationServiceExtension and called it NotificationServiceExtension

I then added the new lines to Podfile. These section in the docs is confusing since I'm using FCM and objective-c but the docs are suggesting that I have pod 'CustomerIO/MessagingPushAPN', '~> 2.0.2' instead of pod 'CustomerIO/MessagingPushFCM', '~> 2.0.2' (Should be the ladder no?)

Screenshot 2023-01-10 at 4 10 32 PM

From this point on I am unable to install the pods, but I went further incase it fixed itself. I added the new swift file and imported it into my NotficationService.m with the rest of the required text suggested in the docs.

To Reproduce Follow the steps to set up Rich push notifications

Expected behavior Be able to install pods and build the app End goal: We need to be able to send rich push notifications and handle them in app once the app has loaded.

Screenshots This is below all of my info in Podfile.

Screenshot 2023-01-10 at 4 09 01 PM
ami-aman commented 1 year ago

Hi @lucasbeatdapp

Thank you bringing the error in the documentation to our notice. I will make sure to make the update asap.

As I understand, you are using FCM in your project so you need to use the following code snippet

target 'NotificationServiceExtension' do
  pod 'CustomerIO/MessagingPushFCM', '~> 2.0.2'
end

and post this, run pod install in ios sub-folder.

Is there any other issue that you face while installing the pods ?

lucasbeatdapp commented 1 year ago

Thanks for your reply @ami-aman !

Now when I run pod install after updating to FCM I get an error when installing the pods

Screenshot 2023-01-11 at 9 18 25 AM

It was first complaining about not having !use_frameworks so I added that in, now my pod file look more like this:

target 'NotificationService' do
  use_frameworks!

  pod 'CustomerIO/MessagingPushFCM', '~> 2.0.1'
end

Any suggestions are appreciated! Thanks.

levibostian commented 1 year ago

Could you show your entire Podfile? It would be very helpful.

I am wondering if maybe the target name in your Podfile isn't quite accurate.

Using this screenshot, find the name of the target for your notification service extension: CleanShot 2023-01-11 at 15 25 41@2x

In this screenshot example, it's "Notification Service" that is the target name.

Your Podfile should include that name exactly.

# What you currently have:
target 'NotificationServiceExtension' do

# Try changing the name to the name of the target in Xcode:
target 'Notification Service' do
lucasbeatdapp commented 1 year ago

Thanks for the reply @levibostian

Here's my Podfile: In all fairness a large majority of the Podfile was created by command: npx create-expo-app --template bare-minimum

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
install! 'cocoapods',
  :deterministic_uuids => false

target 'renmobileapp' do
  use_frameworks!
  $RNFirebaseAsStaticFramework = true

  use_expo_modules!
  config = use_native_modules!

  use_frameworks! :linkage => :static
  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    #
    # Uncomment to opt-in to using Flipper
    # Note that if you have use_frameworks! enabled, Flipper will not work
    # :flipper_configuration => !ENV['CI'] ? FlipperConfiguration.enabled : FlipperConfiguration.disabled,
  )

  pod 'SRSRadialGradient', :path => '../node_modules/react-native-radial-gradient/ios'
  pod 'CustomerIO/MessagingPushFCM', '~> 2.0.1'

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end

target 'NotificationService' do
  use_frameworks!

  pod 'CustomerIO/MessagingPushFCM', '~> 2.0.1'
end

I've also confirmed that the target name is the same in Podfile as it is in xcode

Screenshot 2023-01-11 at 1 45 16 PM

I believe this error is asking me to statically install the listed dependancies below:

[!] The 'Pods-NotificationService' target has transitive dependencies that include statically linked binaries: (CustomerIOTracking-static, CustomerIOCommon-static, and CustomerIOMessagingPush-static)
levibostian commented 1 year ago

Seeing the whole Podfile and knowing you used npx create-expo-app --template bare-minimum was super helpful. Thank you!

From that information, I think I have reproduced the error.

target 'notificationservice' do pod 'CustomerIO/MessagingPushAPN', '~> 2.0.0' end


* Run `pod install`. I get error:

[!] Unable to integrate the following embedded targets with their respective host targets (a host target is a "parent" target which embeds a "child" target like a framework or extension):

Run pod install and I get the same error you are getting!

[!] The 'Pods-notificationservice' target has transitive dependencies that include statically linked binaries: (CustomerIOTracking-static, CustomerIOCommon-static, and CustomerIOMessagingPush-static)

If I modify the notification service in the Podfile to

target 'notificationservice' do 
  use_frameworks! :linkage => :static 
  pod 'CustomerIO/MessagingPushAPN', '~> 2.0.0'
end 

Run pod install it seems that all cocoapods were installed successfully.


I hope this helps!

lucasbeatdapp commented 1 year ago

I was able to install the pods and my app builds! Thank you so much!

One more question! When I was installing the pods I got this warning...

[!] The `mobileapp [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-mobileapp/Pods-mobileapp.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `mobileapp [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-mobileapp/Pods-mobileapp.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `NotificationService [Debug]` target overrides the `CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER` build setting defined in `Pods/Target Support Files/Pods-NotificationService/Pods-NotificationService.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `NotificationService [Release]` target overrides the `CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER` build setting defined in `Pods/Target Support Files/Pods-NotificationService/Pods-NotificationService.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

Is this warning something that I need to worry myself with?

If not, thank you so much for your help! Life saver!

lucasbeatdapp commented 1 year ago

Also, I did not add a team when first creating the notification service. I'm unable to build my stand alone app through xcode and I think it's due to not having this set up.

Screenshot 2023-01-12 at 10 50 47 AM

This is the error I get when trying to use automatic with the same team but a different signing cert as my main target

Screenshot 2023-01-12 at 10 55 34 AM

I use manually managed signing for my main target. Do I need to create new provisioning profiles and signing certs? Or maybe, I need to create a new provisioning profile with the same signing certs?

If I were to create a new provisioning profile, I'd also assume I need to create a bundle identifier that matches what is in xcode. Which type of identifier should I create for "com.myBundle.Identifier.NotificationService"

Screenshot 2023-01-12 at 11 01 31 AM

All suggestions would be appreciated, thank you!

levibostian commented 1 year ago

In response to this question regarding cocoapods pod install warnings.

I also saw those same warnings when running pod install for the app I generated for reproducing your error. If I were you, I wouldn't worry about them unless you found a problem with your app later down the road.

I use manually managed signing for my main target. Do I need to create new provisioning profiles and signing certs? Or maybe, I need to create a new provisioning profile with the same signing certs?

You should be able to use 1 code signing certificate that works for multiple provisioning profiles. In the example iOS app we maintain, we have 1 certificate that is used to generate 2 provisioning profiles: 1 profile for the host app and 1 for the notification service extension.

So, yes, you need to generate a new provisioning profile for the new target you made (the notification service extension).

If I were to create a new provisioning profile, I'd also assume I need to create a bundle identifier that matches what is in xcode. Which type of identifier should I create for "com.myBundle.Identifier.NotificationService"

Yes, you do need to create a new bundle ID. The App ID type should work for you.


Notification service extensions are treated as separate apps to the iOS OS. So, they need their own separate target, bundle id, and code signing files. You're on the right track - do everything you would for your host app.

lucasbeatdapp commented 1 year ago

Thank you @levibostian you've been an amazing help. Will be working on getting this done now. Much appreciated.

lucasbeatdapp commented 1 year ago

Last question:

Do I need to configure Background Modes, and Push notifications on the Notification service the exact same way that it was set up on the Main target?

Screenshot 2023-01-12 at 12 41 57 PM Screenshot 2023-01-12 at 12 43 32 PM
ami-aman commented 1 year ago

Hi @lucasbeatdapp

Stepping in for Levi!

You just need to set capabilities in your main target and need not do anything in NotificationService Extension. The screenshots you shared look good.

lucasbeatdapp commented 1 year ago

Sounds great thank you!

lucasbeatdapp commented 1 year ago

@ami-aman @levibostian Thank you both for the help!