-
Notifications
You must be signed in to change notification settings - Fork 86
/
Podfile
181 lines (159 loc) · 6.82 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
source 'https://cdn.cocoapods.org/'
# Allow using RNFirebase as static frameworks
# https://rnfirebase.io/#allow-ios-static-frameworks
# Otherwise we get the following error:
# `The 'Pods-MobileStack' target has transitive dependencies that include statically linked binaries [...]`
$RNFirebaseAsStaticFramework = true
# Workaround for the following error:
# `The 'Pods-MobileStack' target has transitive dependencies that include statically linked binaries [...]`
$static_framework = [
'react-native-flipper',
'FlipperKit',
'Flipper',
'Flipper-Folly',
'Flipper-DoubleConversion',
'Flipper-Glog',
'Flipper-PeerTalk',
'Flipper-RSocket',
'Flipper-Fmt',
]
# https://github.com/zoontek/react-native-permissions?tab=readme-ov-file#ios
def node_require(script)
# Resolve script with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
"require.resolve(
'#{script}',
{paths: [process.argv[1]]},
)", __dir__]).strip
end
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')
# https://github.com/facebook/flipper/issues/4471#issuecomment-2265941061
def flipper_remove(generated_aggregate_target, config_name, config_file)
xcconfig_path = generated_aggregate_target.xcconfig_path(config_name)
if File.exist?(xcconfig_path)
puts "FLIPPER: Found xcconfig file: #{File.basename(xcconfig_path)}"
xcconfig_content = File.read(xcconfig_path)
modified_content = xcconfig_content.gsub('-l"react-native-flipper"', '')
File.open(xcconfig_path, 'w') { |file| file.write(modified_content) }
else
puts "FLIPPER: xcconfig file does not exist: #{File.basename(xcconfig_path)}"
end
end
# Code to be added for react-native-video/Video
# https://github.com/TheWidlarzGroup/react-native-video/issues/3737
MIN_IOS_OVERRIDE = '13.0'
if Gem::Version.new(MIN_IOS_OVERRIDE) > Gem::Version.new(min_ios_version_supported)
min_ios_version_supported = MIN_IOS_OVERRIDE
end
platform :ios, min_ios_version_supported
prepare_react_native_project!
# linkage = ENV['USE_FRAMEWORKS']
linkage="static"
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
setup_permissions(['Camera', 'AppTrackingTransparency', 'Contacts'])
target "MobileStack" do
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# We're making use_frameworks! work with Flipper by using the following workaround:
# building all Flipper related pods as static libraries, linked against the main app.
# See $static_framework above
:flipper_configuration => FlipperConfiguration.enabled(
["Debug"],
{
# Use a specific version of Flipper-Glog which doesn't vendor glog as a dynamic library
# otherwise the main app fails to link (likely due to the 2 dynamic libraries with the same name)
# Flipper-Glog >= 0.3.7 uses a vendored dynamic library
# See https://github.com/CocoaPods/Specs/blob/86d45638f249b0cb766c8e674a98b1b504b1ac0e/Specs/2/7/2/Flipper-Glog/0.3.7/Flipper-Glog.podspec.json#L21
'Flipper-Glog' => '0.3.5',
}
),
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
# import OpenSSL after use_flipper! to avoid OpenSSL only being enabled for debug configurations
# Flipper-Folly requires this specific version of OpenSSL, so declaring it here to avoid duplicate versions in the podfile.lock.
pod 'OpenSSL-Universal', '1.1.1100', :configurations => ['Debug','Release']
end
target 'NotificationService' do
pod 'CTNotificationService'
pod 'CleverTap-iOS-SDK'
end
# Convert all permission pods into static libraries
# See https://github.com/react-native-community/react-native-permissions#workaround-for-use_frameworks-issues
pre_install do |installer|
installer.pod_targets.each do |pod|
if $static_framework.include?(pod.name) || pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
def pod.build_type;
Pod::BuildType.static_library
end
end
end
end
post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
"../node_modules/react-native",
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["ENABLE_BITCODE"] = "NO"
end
# Fix for Xcode 14, see https://github.com/CocoaPods/CocoaPods/issues/11402#issuecomment-1201464693
# Can be removed once we upgrade CocoaPods to >= 1.12
if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
projects = installer.aggregate_targets
.map{ |t| t.user_project }
.uniq{ |p| p.path }
.push(installer.pods_project)
# This block is needed for preserving the EXCLUDED_ARCHS setting on M1 machines
projects.each do |project|
project.build_configurations.each do |config|
# Needed for now as Xcode 12 now tries to build/link both arm64 and x86_64 slices for the simulator
# but some of our prebuilt deps don't support this
# See:
# - https://stackoverflow.com/a/63955114/158525
# - https://github.com/facebook/react-native/issues/29984
# - https://apontious.com/2020/08/23/arm-wrestling-your-ios-simulator-builds/
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 "
end
project.save()
end
# Include env xccconfig generated by React Native Config
installer.aggregate_targets.each do |target|
target.user_build_configurations.each_key do |key|
cocoapods_xcconfig = target.xcconfig_path(key)
rnconfig_xcconfig = target.client_root + "env.xcconfig"
File.open(cocoapods_xcconfig, 'a') do |f|
f.write <<~EOF
// Env config generated by React Native Config
#include? "#{rnconfig_xcconfig.relative_path_from(cocoapods_xcconfig.dirname)}"
EOF
end
end
end
# Remove Flipper from Release builds
installer.generated_aggregate_targets.each do |generated_aggregate_target|
generated_aggregate_target.xcconfigs.each do |config_name, config_file|
next unless config_name == 'Release'
flipper_remove(generated_aggregate_target, config_name, config_file)
end
end
end