Skip to content

Commit

Permalink
[fix] Xcode 12.5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
pavjacko committed May 5, 2021
1 parent 133ffdd commit 58c563c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/rnv-engine-rn/src/sdks/sdk-xcode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ const configureXcodeProject = async (c) => {
// INJECTORS
c.pluginConfigiOS = {
podfileInject: '',
podPostInstall: '',
staticPodExtraConditions: '',
staticFrameworks: [],
staticPodDefinition: '',
Expand Down
12 changes: 11 additions & 1 deletion packages/rnv-engine-rn/src/sdks/sdk-xcode/podfileParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@ export const parsePodFile = async (c, platform) => {

const podfile = getFlavouredProp(c, pluginPlat, 'Podfile');
if (podfile) {
const { injectLines } = podfile;
const { injectLines, post_install } = podfile;
// INJECT LINES
if (injectLines) {
injectLines.forEach((v) => {
c.pluginConfigiOS.podfileInject += `${v}\n`;
});
}

if (post_install) {
post_install.forEach((v) => {
c.pluginConfigiOS.podPostInstall += `${v}\n`;
});
}
}
});

Expand Down Expand Up @@ -122,6 +128,10 @@ export const parsePodFile = async (c, platform) => {
pattern: '{{PLUGIN_PODFILE_INJECT}}',
override: c.pluginConfigiOS.podfileInject
},
{
pattern: '{{INJECT_POST_INSTALL}}',
override: c.pluginConfigiOS.podPostInstall
},
{
pattern: '{{PLUGIN_PODFILE_SOURCES}}',
override: c.pluginConfigiOS.podfileSources
Expand Down
23 changes: 23 additions & 0 deletions packages/rnv-engine-rn/templates/platforms/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,27 @@ pre_install do |installer|
end
end


post_install do |installer|
## Fix for XCode 12.5
find_and_replace("{{PATH_REACT_NATIVE}}/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("{{PATH_REACT_NATIVE}}/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
{{INJECT_POST_INSTALL}}
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

{{PLUGIN_PODFILE_INJECT}}
22 changes: 22 additions & 0 deletions packages/rnv-engine-rn/templates/platforms/tvos/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,26 @@ pre_install do |installer|
end
end

post_install do |installer|
## Fix for XCode 12.5
find_and_replace("{{PATH_REACT_NATIVE}}/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("{{PATH_REACT_NATIVE}}/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
{{INJECT_POST_INSTALL}}
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

{{PLUGIN_PODFILE_INJECT}}
6 changes: 2 additions & 4 deletions packages/rnv/pluginTemplates/renative.plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2020,13 +2020,11 @@
"Firebase"
],
"Podfile": {
"injectLines": [
"post_install do |installer|",
"post_install": [
" rnfirebase = installer.pods_project.targets.find { |target| target.name == 'RNFirebase' }",
" rnfirebase.build_configurations.each do |config|",
" config.build_settings['HEADER_SEARCH_PATHS'] = '$(inherited) ${PODS_ROOT}/Headers/Public/**'",
" end",
"end"
" end"
]
},
"appDelegateMethods": {
Expand Down

0 comments on commit 58c563c

Please sign in to comment.