MaxAst / expo-share-extension

Expo config plugin for creating iOS share extensions with a custom view.
MIT License
230 stars 8 forks source link

Prebuild fails after upgrade to expo SDK 52 #53

Open sufficientforce opened 3 weeks ago

sufficientforce commented 3 weeks ago

Thank you for the incredible package, huge timesaver for my project. Great work.

After upgrading to SDK 52, something goes wrong with the build's modification of podfiles and I get this extensive error when running npx expo prebuild -p ios --clean

✔ Cleared ios code
✔ Created native directory
✔ Updated package.json | no changes
✖ Prebuild failed
Error: [ios.dangerous]: withIosDangerousBaseMod: Failed to match "Pod::UI.warn e" in contents:
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'] || '15.1'
install! 'cocoapods',
  :deterministic_uuids => false

prepare_react_native_project!

target 'goodinternet' do
  use_expo_modules!

  if ENV['EXPO_USE_COMMUNITY_AUTOLINKING'] == '1'
    config_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
  else
    config_command = [
      'node',
      '--no-warnings',
      '--eval',
      'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
      'react-native-config',
      '--json',
      '--platform',
      'ios'
    ]
  end

  config = use_native_modules!(config_command)

  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']

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    :privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      :ccache_enabled => podfile_properties['apple.ccacheEnabled'] == 'true',
    )

# @generated begin post-install-build-settings - expo prebuild (DO NOT MODIFY) sync-f4e2a1acf7da60b403fcf5c1d5d9517cb9953853
    installer.pods_project.targets.each do |target|
      unless target.name == 'Sentry'
        target.build_configurations.each do |config|
          config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
        end
      end
    end
# @generated end post-install-build-settings
    # 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
end

Error: [ios.dangerous]: withIosDangerousBaseMod: Failed to match "Pod::UI.warn e" in contents:
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'] || '15.1'
install! 'cocoapods',
  :deterministic_uuids => false

prepare_react_native_project!

target 'goodinternet' do
  use_expo_modules!

  if ENV['EXPO_USE_COMMUNITY_AUTOLINKING'] == '1'
    config_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
  else
    config_command = [
      'node',
      '--no-warnings',
      '--eval',
      'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
      'react-native-config',
      '--json',
      '--platform',
      'ios'
    ]
  end

  config = use_native_modules!(config_command)

  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']

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    :privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      :ccache_enabled => podfile_properties['apple.ccacheEnabled'] == 'true',
    )

# @generated begin post-install-build-settings - expo prebuild (DO NOT MODIFY) sync-f4e2a1acf7da60b403fcf5c1d5d9517cb9953853
    installer.pods_project.targets.each do |target|
      unless target.name == 'Sentry'
        target.build_configurations.each do |config|
          config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
        end
      end
    end
# @generated end post-install-build-settings
    # 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
end

    at addLines (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/utils/generateCode.js:85:19)
    at mergeContents (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/utils/generateCode.js:58:17)
    at /Users/sufficientforce/fun/code/good-internet/node_modules/expo-share-extension/plugin/build/withPodfile.js:63:63
    at action (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/plugins/withMod.js:199:29)
    at interceptingMod (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/plugins/withMod.js:104:27)
    at action (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/plugins/withMod.js:204:14)
    at async interceptingMod (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/plugins/withMod.js:104:21)
    at async interceptingMod (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/plugins/withMod.js:104:21)
    at async action (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/plugins/createBaseMod.js:60:21)
    at async interceptingMod (/Users/sufficientforce/fun/code/good-internet/node_modules/@expo/config-plugins/build/plugins/withMod.js:104:21)
MaxAst commented 3 weeks ago

Hey @sufficientforce, thanks for reporting! I still need to update expo-share-extension to work with react native's new architecture, which is enabled by default with expo v52. So for the time being you can only use this with v51

sufficientforce commented 3 weeks ago

Thanks @MaxAst -- makes sense. FWIW I'm trying to include this change https://github.com/expo/expo/pull/31278 which is highly relevant for expo-share-extension as it makes sqlite databases sharable b/w extension and main app.

I wonder if it's cherry pickable to v51 in some way...regardless, thanks again for your work

MaxAst commented 3 weeks ago

yep I saw that change too, pretty exciting. Have you tried disabling new arch via expo-build-properties, while still running v52?

sufficientforce commented 3 weeks ago

Yeah, I've had this in my build even with earlier Expo versions:

(Note: is it possible that the above error is unrelated to the new architecture and is caused by some other modification to podfile structure? Or maybe in v52 the newArchEnabled:false setting is no longer honored...?)

"plugins":` [
      "expo-router",
      "expo-font",
      [
        "expo-build-properties",
        {
          "ios": {
            "newArchEnabled": false
          },
          "android": {
            "newArchEnabled": false
          }
        }
      ],
Remeic commented 2 weeks ago

Hi @sufficientforce, have you find a temporary solution to the issue? Thanks in advance

erdkodla commented 3 days ago

Did anyone find a solution?

awinton64 commented 3 days ago

@erdkodla Did downgrading to expo v51 work for you?

I ended up just downgrading back to "expo": "~51.0.38" as suggested earlier in the thread by @MaxAst. I am also using mmkv and had to downgrade to "react-native-mmkv": "^2.12.2". And this seems to work for me.