1require 'json'
2
3package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
5Pod::Spec.new do |s|
6  s.name           = 'EXUpdates'
7  s.version        = package['version']
8  s.summary        = package['description']
9  s.description    = package['description']
10  s.license        = package['license']
11  s.author         = package['author']
12  s.homepage       = package['homepage']
13  s.platforms      = { :ios => '13.0', :tvos => '13.0' }
14  s.swift_version  = '5.4'
15  s.source         = { git: 'https://github.com/expo/expo.git' }
16  s.static_framework = true
17  s.dependency 'ExpoModulesCore'
18  s.dependency 'React-Core'
19  s.dependency 'EXStructuredHeaders'
20  s.dependency 'EXUpdatesInterface'
21  s.dependency 'EXManifests'
22  s.dependency 'EASClient'
23  s.dependency 'ReachabilitySwift'
24  s.dependency 'sqlite3', '~> 3.42.0'
25
26  unless defined?(install_modules_dependencies)
27    # `install_modules_dependencies` is defined from react_native_pods.rb.
28    # when running with `pod ipc spec`, this method is not defined and we have to require manually.
29    require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
30  end
31  install_modules_dependencies(s)
32
33  ex_updates_native_debug = ENV['EX_UPDATES_NATIVE_DEBUG'] == '1'
34
35  other_c_flags = ex_updates_native_debug ? "$(inherited) -DEX_UPDATES_NATIVE_DEBUG=1" : "$(inherited)"
36  other_swift_flags = ex_updates_native_debug ? "$(inherited) -DEX_UPDATES_NATIVE_DEBUG" : "$(inherited)"
37
38  s.pod_target_xcconfig = {
39    'GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS' => 'YES',
40    'GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS' => 'YES',
41    'DEFINES_MODULE' => 'YES',
42    'SWIFT_COMPILATION_MODE' => 'wholemodule',
43    'OTHER_CFLAGS[config=Debug]' => other_c_flags,
44    'OTHER_SWIFT_FLAGS[config=Debug]' => other_swift_flags
45  }
46  s.user_target_xcconfig = {
47    'HEADER_SEARCH_PATHS' => '"${PODS_CONFIGURATION_BUILD_DIR}/EXUpdates/Swift Compatibility Header"',
48  }
49
50  if !ex_updates_native_debug && !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
51    s.source_files = "#{s.name}/**/*.h"
52    s.vendored_frameworks = "#{s.name}.xcframework"
53  else
54    s.source_files = "#{s.name}/**/*.{h,m,swift}"
55  end
56
57  if $expo_updates_create_manifest != false
58    force_bundling_flag = ex_updates_native_debug ? "export FORCE_BUNDLING=1\n" : ""
59    s.script_phase = {
60      :name => 'Generate app.manifest for expo-updates',
61      :script => force_bundling_flag + 'bash -l -c "$PODS_TARGET_SRCROOT/../scripts/create-manifest-ios.sh"',
62      :execution_position => :before_compile
63    }
64
65    # Generate EXUpdates.bundle without existing resources
66    # `create-manifest-ios.sh` will generate app.manifest in EXUpdates.bundle
67    s.resource_bundles = {
68      'EXUpdates' => []
69    }
70  end
71
72  s.exclude_files = 'Tests/'
73  s.test_spec 'Tests' do |test_spec|
74    test_spec.source_files = 'Tests/*.{h,m,swift}'
75    test_spec.resources = 'Tests/Support/**/*'
76
77    # ExpoModulesCore requires React-hermes or React-jsc in tests, add ExpoModulesTestCore for the underlying dependencies
78    test_spec.dependency 'ExpoModulesTestCore'
79
80    test_spec.pod_target_xcconfig = {
81      'USER_HEADER_SEARCH_PATHS' => '"${CONFIGURATION_TEMP_DIR}/EXUpdates.build/DerivedSources"',
82      'GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS' => 'YES',
83      'GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS' => 'YES',
84      'DEFINES_MODULE' => 'YES',
85      'SWIFT_COMPILATION_MODE' => 'wholemodule'
86    }
87  end
88end
89