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

[Bug]: Pinning pod removes extra targets in podfile #1

Open
1 task done
vethan opened this issue Mar 27, 2024 · 5 comments
Open
1 task done

[Bug]: Pinning pod removes extra targets in podfile #1

vethan opened this issue Mar 27, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@vethan
Copy link

vethan commented Mar 27, 2024

What happened?

When pinning a pod version, if a later plugin changes the podfile, these changes are lost

Steps to reproduce?

1. Install Onesignal react native expo plugin
2. Install ExpoPodPinner
3. List ExpoPodPinner followed by Onesignal native expo plugin in plugins
4. Run expo prebuild for ios
5. Observe missing 'OneSignalNotificationServiceExtension' target.

Swap the order and observe OneSignalNotificationServiceExtension target is present.

What did you expect to happen?

Plugin order to not change behaviour

Expo Pod Pinner Plugin version

1.0.0

Platform

iOS

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@vethan vethan added the bug Something isn't working label Mar 27, 2024
@rgomezp
Copy link
Owner

rgomezp commented Mar 27, 2024

@vethan ,
That's humorous. I happen to be the author of both of those plugins.

As is documented in the onesignal-expo-plugin and surfaced in this issue, it's important to always put that plugin first!

While that is the case, I'm not able to reproduce the issue regardless with:

"plugins": [
      [
        "expo-pod-pinner",
        {
          "targetName": "StickerSmash",
          "pods": [
            {
              "BoringSSL-GRPC": "0.0.24"
            }
          ]
        }
      ],
      ["onesignal-expo-plugin", {
        "mode": "development"
      }]
    ]

Can you please share your Podfile?

@vethan
Copy link
Author

vethan commented Mar 27, 2024

I hadn't seen that it had to go first, probably just speed reading when I was originally setting up a while back! Fun that the problems only cropped up with the firebase faff! I suppose that was the real problem after all. Just for info:

Podfile with pinning first:

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 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

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

prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...), which will be excluded. To fix this,
# you can also exclude `react-native-flipper` in `react-native.config.js`
#
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
#   }
# }
# ```
flipper_config = FlipperConfiguration.disabled
if ENV['NO_FLIPPER'] == '1' then
 # Explicitly disabled through environment variables
 flipper_config = FlipperConfiguration.disabled
elsif podfile_properties.key?('ios.flipper') then
 # Configure Flipper in Podfile.properties.json
 if podfile_properties['ios.flipper'] == 'true' then
   flipper_config = FlipperConfiguration.enabled(["Debug", "Release"])
 elsif podfile_properties['ios.flipper'] != 'false' then
   flipper_config = FlipperConfiguration.enabled(["Debug", "Release"], { 'Flipper' => podfile_properties['ios.flipper'] })
 end
end

target 'Crowdev' do
 pod 'BoringSSL-GRPC', '0.0.24'
 use_expo_modules!
 config = use_native_modules!

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

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

 use_react_native!(
   :path => config[:reactNativePath],
   :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
   :fabric_enabled => flags[:fabric_enabled],
   # An absolute path to your application root.
   :app_path => "#{Pod::Config.instance.installation_root}/..",
   # Note that if you have use_frameworks! enabled, Flipper will not work if enabled
   :flipper_configuration => flipper_config
 )

 post_install do |installer|
   react_native_post_install(
     installer,
     config[:reactNativePath],
     :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

And with pinning second/Last

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 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

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

prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...), which will be excluded. To fix this,
# you can also exclude `react-native-flipper` in `react-native.config.js`
#
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
#   }
# }
# ```
flipper_config = FlipperConfiguration.disabled
if ENV['NO_FLIPPER'] == '1' then
  # Explicitly disabled through environment variables
  flipper_config = FlipperConfiguration.disabled
elsif podfile_properties.key?('ios.flipper') then
  # Configure Flipper in Podfile.properties.json
  if podfile_properties['ios.flipper'] == 'true' then
    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"])
  elsif podfile_properties['ios.flipper'] != 'false' then
    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"], { 'Flipper' => podfile_properties['ios.flipper'] })
  end
end

target 'Crowdev' do
  pod 'BoringSSL-GRPC', '0.0.24'
  use_expo_modules!
  config = use_native_modules!

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

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

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    # Note that if you have use_frameworks! enabled, Flipper will not work if enabled
    :flipper_configuration => flipper_config
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :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 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
end


@rgomezp
Copy link
Owner

rgomezp commented Mar 28, 2024

Interesting. I've tried it multiple times and can't repro. What do the logs say in your console?

@vethan
Copy link
Author

vethan commented Mar 28, 2024

Weird... could be some odd quirk? I tried doing a prebuild with a minimal set of plugins on my project (just pinner + onesignal in my plugins array) and it still repro'd. If it's just me, and the fix is "put pinner later" it's probably not a big deal

$ yarn expo prebuild --platform ios --clean
yarn run v1.22.22
$ expo prebuild --platform ios --clean
Warning! Your git working tree is dirty.
It's recommended to commit all your changes before proceeding, so you can revert the changes made by this command if necessary.

✔ Would you like to proceed? … yes

✔ Cleared ios code

✔ Created native project | gitignore skipped
› Using current versions instead of recommended expo@~49.0.23, react-native@0.72.10.
✔ Updated package.json and added index.js entry point for iOS and Android
› Installing using yarn
> yarn install
        expo-pod-pinner: Added BoringSSL-GRPC to Crowdev target in Podfile.
        expo-pod-pinner: Podfile updated successfully.
✔ Config synced
✔ Skipped installing CocoaPods because operating system is not on macOS.
Done in 2.60s.

@rgomezp
Copy link
Owner

rgomezp commented Mar 28, 2024

Ah interesting. I don't see the onesignal logs:

✔ Updated package.json | no changes
        onesignal-expo-plugin: OneSignalNotificationServiceExtension target already added to Podfile. Skipping...
        expo-pod-pinner: BoringSSL-GRPC is already at version 0.0.24 in Podfile. No update needed.
        expo-pod-pinner: No changes made to the Podfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants