11require 'json'
2+ require 'rubygems' # Required for version comparison
23
34new_arch_enabled = ENV [ 'RCT_NEW_ARCH_ENABLED' ] == '1'
45
@@ -33,17 +34,45 @@ Pod::Spec.new do |s|
3334 s . dependency "React-Core"
3435 s . dependency 'SSZipArchive'
3536
36- project_root = File . expand_path ( '../../' , __dir__ )
37- project_package_json = File . join ( project_root , 'package.json' )
3837 is_expo_project = false
38+ expo_dependency_added = false
39+ supports_bundle_url_final = false
3940
40- if ( File . exist? ( project_package_json ) )
41- package_json = JSON . parse ( File . read ( project_package_json ) )
42- has_expo_dependency = package_json [ 'dependencies' ] && package_json [ 'dependencies' ] [ 'expo' ]
43- has_expo_modules_core = Dir . exist? ( 'node_modules/expo-modules-core' )
44- is_expo_project = has_expo_dependency || has_expo_modules_core
45- if is_expo_project
46- s . dependency 'ExpoModulesCore'
41+ # Use CocoaPods mechanism to find Podfile
42+ begin
43+ podfile_path = File . join ( Pod ::Config . instance . installation_root , 'Podfile' )
44+ if File . exist? ( podfile_path )
45+ podfile_content = File . read ( podfile_path )
46+ is_expo_project = podfile_content . include? ( 'use_expo_modules!' )
47+ end
48+ rescue
49+ # Silently skip if CocoaPods config is not available
50+ end
51+
52+ if is_expo_project
53+ s . dependency 'ExpoModulesCore'
54+ expo_dependency_added = true
55+
56+ # Current directory is in node_modules/react-native-update, so parent is node_modules
57+ expo_core_package_json_path = File . join ( __dir__ , '..' , 'expo-modules-core' , 'package.json' )
58+
59+ if File . exist? ( expo_core_package_json_path )
60+ begin
61+ core_package_json = JSON . parse ( File . read ( expo_core_package_json_path ) )
62+ installed_version_str = core_package_json [ 'version' ]
63+
64+ if installed_version_str
65+ begin
66+ installed_version = Gem ::Version . new ( installed_version_str )
67+ target_version = Gem ::Version . new ( '1.12.0' )
68+ supports_bundle_url_final = installed_version >= target_version
69+ rescue ArgumentError
70+ # Silently skip version parsing errors
71+ end
72+ end
73+ rescue JSON ::ParserError , StandardError
74+ # Silently skip file reading and parsing errors
75+ end
4776 end
4877 end
4978
@@ -62,9 +91,13 @@ Pod::Spec.new do |s|
6291 ss . public_header_files = 'ios/RCTPushy/HDiffPatch/**/*.h'
6392 end
6493
65- if is_expo_project
94+ if expo_dependency_added
6695 s . subspec 'Expo' do |ss |
6796 ss . source_files = 'ios/Expo/**/*.{h,m,mm,swift}'
97+ if supports_bundle_url_final
98+ ss . pod_target_xcconfig = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'EXPO_SUPPORTS_BUNDLEURL' }
99+ end
100+ ss . dependency 'ExpoModulesCore'
68101 end
69102 end
70103
@@ -79,7 +112,7 @@ Pod::Spec.new do |s|
79112 s . pod_target_xcconfig = {
80113 "HEADER_SEARCH_PATHS" => "\" $(PODS_ROOT)/boost\" " ,
81114 "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
82- }
115+ } . merge ( s . pod_target_xcconfig )
83116 s . dependency "React-Codegen"
84117 s . dependency "RCT-Folly"
85118 s . dependency "RCTRequired"
0 commit comments