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 15REACT_NATIVE_MINOR_VERSION = 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.platform = :ios, '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 s.user_target_xcconfig = { 63 "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/ExpoModulesCore/Swift Compatibility Header\" \"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers\"", 64 } 65 66 compiler_flags = folly_compiler_flags + ' ' + "-DREACT_NATIVE_MINOR_VERSION=#{REACT_NATIVE_MINOR_VERSION}" 67 68 s.dependency 'React-Core' 69 s.dependency 'ReactCommon/turbomodule/core' 70 s.dependency 'React-RCTAppDelegate' if REACT_NATIVE_MINOR_VERSION >= 71 71 s.dependency 'React-NativeModulesApple' if REACT_NATIVE_MINOR_VERSION >= 72 72 73 if fabric_enabled 74 compiler_flags << ' ' << fabric_compiler_flags 75 76 s.dependency 'React-RCTFabric' 77 s.dependency 'RCT-Folly', folly_version 78 end 79 80 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') 81 s.source_files = 'ios/**/*.h', 'common/cpp/**/*.h' 82 s.vendored_frameworks = "ios/#{s.name}.xcframework" 83 else 84 s.source_files = 'ios/**/*.{h,m,mm,swift,cpp}', 'common/cpp/**/*.{h,cpp}' 85 end 86 87 exclude_files = ['ios/Tests/'] 88 if !fabric_enabled 89 exclude_files.append('ios/Fabric/') 90 exclude_files.append('common/cpp/fabric/') 91 end 92 93 s.exclude_files = exclude_files 94 s.compiler_flags = compiler_flags 95 s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h'] 96 97 s.test_spec 'Tests' do |test_spec| 98 test_spec.dependency 'ExpoModulesTestCore' 99 100 test_spec.source_files = 'ios/Tests/**/*.{m,swift}' 101 end 102end 103