1require 'json' 2 3package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 5reactNativeVersion = '0.0.0' 6begin 7 reactNativeVersion = `node --print "require('react-native/package.json').version"` 8rescue 9 reactNativeVersion = '0.0.0' 10end 11if ENV["REACT_NATIVE_OVERRIDE_VERSION"] 12 reactNativeVersion = ENV["REACT_NATIVE_OVERRIDE_VERSION"] 13end 14 15reactNativeMinorVersion = reactNativeVersion.split('.')[1].to_i 16 17fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1' 18fabric_compiler_flags = '-DRN_FABRIC_ENABLED -DRCT_NEW_ARCH_ENABLED' 19folly_version = '2021.07.22.00' 20folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' 21 22Pod::Spec.new do |s| 23 s.name = 'ExpoModulesCore' 24 s.version = package['version'] 25 s.summary = package['description'] 26 s.description = package['description'] 27 s.license = package['license'] 28 s.author = package['author'] 29 s.homepage = package['homepage'] 30 s.platforms = { :ios => '13.0', :tvos => '13.0'} 31 s.swift_version = '5.4' 32 s.source = { git: 'https://github.com/expo/expo.git' } 33 s.static_framework = true 34 s.header_dir = 'ExpoModulesCore' 35 36 header_search_paths = [ 37 # EXJavaScriptRuntime -> Hermes 38 '"$(PODS_ROOT)/boost"', 39 '"$(PODS_ROOT)/DoubleConversion"', 40 '"$(PODS_ROOT)/RCT-Folly"', 41 '"${PODS_ROOT}/Headers/Public/React-hermes"', 42 '"${PODS_ROOT}/Headers/Public/hermes-engine"', 43 44 # EXAppDelegateWrapper -> RCTAppDelegate -> RCTCxxBridgeDelegate 45 '"${PODS_ROOT}/Headers/Private/React-Core"', 46 47 # similar to https://github.com/facebook/react-native/commit/c4b51e8d7, review this when we drop SDK 47 48 '"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging"', 49 '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers"', 50 ] 51 52 # Swift/Objective-C compatibility 53 s.pod_target_xcconfig = { 54 'USE_HEADERMAP' => 'YES', 55 'DEFINES_MODULE' => 'YES', 56 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17', 57 'SWIFT_COMPILATION_MODE' => 'wholemodule', 58 'HEADER_SEARCH_PATHS' => header_search_paths.join(' '), 59 "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"", 60 'OTHER_SWIFT_FLAGS' => "$(inherited) #{fabric_enabled ? fabric_compiler_flags : ''}" 61 } 62 user_header_search_paths = [ 63 '"${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header"', 64 '"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging"', 65 '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers"', 66 ] 67 if fabric_enabled && ENV['USE_FRAMEWORKS'] 68 user_header_search_paths << "\"$(PODS_ROOT)/DoubleConversion\"" 69 user_header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers\"" 70 user_header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios\"" 71 user_header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers\"" 72 user_header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers\"" 73 user_header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"" 74 user_header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-RCTFabric/RCTFabric.framework/Headers\"" 75 end 76 s.user_target_xcconfig = { 77 "HEADER_SEARCH_PATHS" => user_header_search_paths, 78 } 79 80 compiler_flags = folly_compiler_flags + ' ' + "-DREACT_NATIVE_MINOR_VERSION=#{reactNativeMinorVersion}" 81 82 s.dependency 'React-Core' 83 s.dependency 'ReactCommon/turbomodule/core' 84 s.dependency 'React-RCTAppDelegate' if reactNativeMinorVersion >= 71 85 s.dependency 'React-NativeModulesApple' if reactNativeMinorVersion >= 72 86 87 if fabric_enabled 88 compiler_flags << ' ' << fabric_compiler_flags 89 90 s.dependency 'React-RCTFabric' 91 s.dependency 'RCT-Folly', folly_version 92 end 93 94 unless defined?(install_modules_dependencies) 95 # `install_modules_dependencies` is defined from react_native_pods.rb. 96 # when running with `pod ipc spec`, this method is not defined and we have to require manually. 97 require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods") 98 end 99 install_modules_dependencies(s) 100 101 if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("ios/#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0') 102 s.source_files = 'ios/**/*.h', 'common/cpp/**/*.h' 103 s.vendored_frameworks = "ios/#{s.name}.xcframework" 104 else 105 s.source_files = 'ios/**/*.{h,m,mm,swift,cpp}', 'common/cpp/**/*.{h,cpp}' 106 end 107 108 exclude_files = ['ios/Tests/'] 109 if !fabric_enabled 110 exclude_files.append('ios/Fabric/') 111 exclude_files.append('common/cpp/fabric/') 112 end 113 114 s.exclude_files = exclude_files 115 s.compiler_flags = compiler_flags 116 s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h'] 117 118 s.test_spec 'Tests' do |test_spec| 119 test_spec.dependency 'ExpoModulesTestCore' 120 121 test_spec.source_files = 'ios/Tests/**/*.{m,swift}' 122 end 123end 124