Skip to content

Commit cf8a364

Browse files
committed
[local] change post-install to patch RTC-Folly
1 parent 1c4ac48 commit cf8a364

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

scripts/react_native_pods.rb

+32-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def use_react_native! (options={})
7171
def use_flipper!(versions = {}, configurations: ['Debug'])
7272
versions['Flipper'] ||= '~> 0.75.1'
7373
versions['Flipper-DoubleConversion'] ||= '1.1.7'
74-
versions['Flipper-Folly'] ||= '~> 2.5'
74+
versions['Flipper-Folly'] ||= '~> 2.5.3'
7575
versions['Flipper-Glog'] ||= '0.3.6'
7676
versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
7777
versions['Flipper-RSocket'] ||= '~> 1.3'
@@ -138,10 +138,26 @@ def exclude_architectures(installer)
138138
end
139139

140140
def react_native_post_install(installer)
141+
pods_prefix = File.dirname(installer.pods_project.path)
142+
141143
if has_pod(installer, 'Flipper')
142144
flipper_post_install(installer)
143145
end
144146

147+
## Fix for RTC-Folly on iOS 14.5 - makes Hermes work again
148+
find_and_replace(
149+
"#{pods_prefix}/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
150+
'atomic_notify_one(state)',
151+
'folly::atomic_notify_one(state)'
152+
)
153+
154+
find_and_replace(
155+
"#{pods_prefix}Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
156+
'atomic_wait_until(&state, previous | data, deadline)',
157+
'folly::atomic_wait_until(&state, previous | data, deadline)'
158+
)
159+
160+
## Exclude `i386` from valid architectures when building with Hermes on iOS
145161
exclude_architectures(installer)
146162
end
147163

@@ -199,3 +215,18 @@ def use_react_native_codegen!(spec, options={})
199215

200216
spec.prepare_command = "#{mkdir_command} && touch #{generated_files.reduce() { |str, file| str + " " + file }}"
201217
end
218+
219+
# Local method for the Xcode 12.5 fix
220+
def find_and_replace(dir, findstr, replacestr)
221+
Dir[dir].each do |name|
222+
text = File.read(name)
223+
replace = text.gsub(findstr, replacestr)
224+
replaced = text.index(replacestr)
225+
next if !replaced.nil? || text == replace
226+
227+
puts "Patching #{name}"
228+
File.open(name, 'w') { |file| file.puts replace }
229+
$stdout.flush
230+
end
231+
Dir["#{dir}*/"].each(&method(:find_and_replace))
232+
end

0 commit comments

Comments
 (0)