-
Notifications
You must be signed in to change notification settings - Fork 58
/
Podfile
114 lines (89 loc) · 4.73 KB
/
Podfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# frozen_string_literal: true
require 'json'
require 'xcodeproj'
GUTENBERG_PATH = '../gutenberg'
REACT_NATIVE_PATH = File.join(GUTENBERG_PATH, 'node_modules', 'react-native')
require_relative File.join(REACT_NATIVE_PATH, 'scripts', 'react_native_pods')
HERMES_ENABLED = ENV.fetch('HERMES_ENABLED', true)
puts "[Gutenberg] Installing pods with Hermes #{HERMES_ENABLED ? 'enabled' : 'disabled'}"
def setup_rnreanimated_pod_from_fork
# This is required to workaround an issue with RNReanimated after upgrading to version 2.17.0
rn_node_modules = File.join(Dir.pwd, '..', 'gutenberg', 'node_modules')
raise "Could not find node modules at given path #{rn_node_modules}" unless File.exist? rn_node_modules
ENV['REACT_NATIVE_NODE_MODULES_DIR'] = rn_node_modules
puts "[Gutenberg] Set REACT_NATIVE_NODE_MODULES_DIR env var for RNReanimated to #{rn_node_modules}"
# Use a custom RNReanimated version while we coordinate a fix upstream
pod 'RNReanimated', git: 'https://github.com/wordpress-mobile/react-native-reanimated', branch: 'wp-fork-2.17.0'
end
def gutenberg_dependencies
Dir['../third-party-podspecs/*.podspec.json'].each do |podspec_path|
pod_name = JSON.parse(File.read(podspec_path))['name']
raise "Could not find pod name in JSON spec at #{podspec_path}" unless pod_name
# Skip the standard RNReanimated podspec because we use a custom version
# while working on an upstream fix
#
# https://github.com/software-mansion/react-native-reanimated/pull/4684
if pod_name == 'RNReanimated'
setup_rnreanimated_pod_from_fork
next
end
# Skip React-jsc when using Hermes
#
# Context: React native supports different JavaScript engines.
# Hermes is the recommended engine, but we always have the option to switch back to JavaScriptCore (JSC).
# Of course, if we use one we don't need to add the other.
#
# See also:
#
# - https://github.com/facebook/react-native/tree/598b7ed690d908c408adea970d26382c834f5ead/packages/react-native/ReactCommon/jsc
# - https://reactnative.dev/docs/hermes
next if pod_name == 'React-jsc' && HERMES_ENABLED == true
pod pod_name, podspec: podspec_path
end
end
VERSION_XCCONFIG_PATH = File.join(File.expand_path(__dir__), 'Config', 'Gutenberg-Shared.xcconfig')
IOS_VERSION_KEY = 'IPHONEOS_DEPLOYMENT_TARGET'
APP_IOS_DEPLOYMENT_TARGET = Gem::Version.new(Xcodeproj::Config.new(VERSION_XCCONFIG_PATH).to_hash[IOS_VERSION_KEY])
platform :ios, APP_IOS_DEPLOYMENT_TARGET.version
# It's important to call use_frameworks! before use_react_native!
#
# See https://github.com/facebook/react-native/issues/36120#issuecomment-1425892304
use_frameworks! linkage: :static
use_react_native! path: REACT_NATIVE_PATH, hermes_enabled: HERMES_ENABLED
target 'Gutenberg' do
pod 'RNTAztecView', path: File.join(GUTENBERG_PATH, 'packages', 'react-native-aztec')
gutenberg_dependencies
end
post_install do |installer|
react_native_post_install(installer, REACT_NATIVE_PATH)
installer.pods_project.targets.each do |target|
# Work around issue with embedding the Hermes XCFramework
#
# See https://github.com/facebook/react-native/issues/35863
if HERMES_ENABLED && target.name == 'hermes-engine'
installer.pods_project.files.each do |fileref|
next unless fileref.path.end_with? 'hermes.xcframework'
plist_buddy = '/usr/libexec/PlistBuddy'
raise "[Gutenberg] Could not find PlistBuddy at #{plist_buddy}." unless File.exist?(plist_buddy)
hermes_plist_file = "#{fileref.real_path}/Info.plist"
# Patch Hermes to remove the debug symbols entry from the Info.plist (as it's not shipped with it)
# This might be removed once Hermes starts to ship with Debug symbols or we remove our
# direct dependency from the Main iOS target on "hermes.xcframework"
Open3.capture3(plist_buddy, '-c', 'Delete :AvailableLibraries:0:DebugSymbolsPath', hermes_plist_file)
Open3.capture3(plist_buddy, '-c', 'Delete :AvailableLibraries:1:DebugSymbolsPath', hermes_plist_file)
Open3.capture3(plist_buddy, '-c', 'Delete :AvailableLibraries:2:DebugSymbolsPath', hermes_plist_file)
puts '[Gutenberg] Removed Hermes dSYMs references from its XCFramework'
end
end
# Let Pods targets inherit deployment target from the app
# See https://github.com/CocoaPods/CocoaPods/issues/4859
#
# Exclude RCT-Folly as it requires explicit deployment target
# See https://git.io/JPb73
next if target.name == 'RCT-Folly'
target.build_configurations.each do |configuration|
pod_ios_deployment_target = Gem::Version.new(configuration.build_settings[IOS_VERSION_KEY])
configuration.build_settings.delete(IOS_VERSION_KEY) if pod_ios_deployment_target <= APP_IOS_DEPLOYMENT_TARGET
end
end
end