Skip to content

Instantly share code, notes, and snippets.

@jmpinit
Created October 26, 2021 16:26
Show Gist options
  • Save jmpinit/19d20c00f5610e224997da5311df435b to your computer and use it in GitHub Desktop.
Save jmpinit/19d20c00f5610e224997da5311df435b to your computer and use it in GitHub Desktop.
Fix Xcode 12.5 React Native build
# https://github.com/facebook/react-native/issues/28405#issuecomment-827421253
post_install do |installer|
## Fix for XCode 12.5 beta
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
end
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment