2024-09-06 flutter+rn 多target 在iOS上配置

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, '15.0'
prepare_react_native_project!
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

flutter_application_path = '../vr'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

config = use_native_modules!

def share_pods
  use_frameworks!
  
  pod 'Toast-Swift', '5.0.1'
  pod 'Alamofire','5.9.1'
  
end


target 'iOS' do
  share_pods
  
  use_react_native!(
    :path => config[:reactNativePath],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  install_all_flutter_pods(flutter_application_path)
end

target 'iOS_Beta' do
  share_pods
  
  use_react_native!(
    :path => config[:reactNativePath],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  install_all_flutter_pods(flutter_application_path)
end


target 'iOS_Dev' do
  share_pods
  
  use_react_native!(
    :path => config[:reactNativePath],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  install_all_flutter_pods(flutter_application_path)
end


pre_install do |installer|
     installer.pod_targets.each do |pod|
       if pod.name.eql?('RNReanimated')
         def pod.build_type
           Pod::BuildType.static_library
        end
    end
  end
end

post_install do |installer|
  # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
  flutter_post_install(installer) if defined?(flutter_post_install)
  react_native_post_install(
    installer,
    config[:reactNativePath],
    :mac_catalyst_enabled => false,
    # :ccache_enabled => true
  )
  installer.pods_project.targets.each do |target|
    ... # Here are some configurations automatically generated by flutter
    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',
         'PERMISSION_CAMERA=1',
         'PERMISSION_PHOTOS=1',
      ]
    end
  end
end
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容