From a8786da6ce52b8a3f41e6825bbd005700f0db17c Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Mon, 2 Mar 2020 18:27:17 +0100 Subject: [PATCH] fix(cordova): handle source-file with framework attribute (#2507) --- cli/src/ios/update.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cli/src/ios/update.ts b/cli/src/ios/update.ts index 5da32c51ed..e3f70e358b 100644 --- a/cli/src/ios/update.ts +++ b/cli/src/ios/update.ts @@ -279,19 +279,21 @@ function copyPluginsNativeFiles(config: Config, cordovaPlugins: Plugin[]) { const filePath = getFilePath(config, p, codeFile.$.src); const fileDest = join(pluginsPath, destFolder, p.name, fileName); copySync(filePath, fileDest); - let fileContent = readFileSync(fileDest, 'utf8'); - if (fileExt === 'swift') { - fileContent = 'import Cordova\n' + fileContent; - writeFileSync(fileDest, fileContent, 'utf8'); - } else { - if (fileContent.includes('@import Firebase;')) { - fileContent = fileContent.replace('@import Firebase;', '#import '); - writeFileSync(fileDest, fileContent, 'utf8'); - } - if (fileContent.includes('[NSBundle bundleForClass:[self class]]') || fileContent.includes('[NSBundle bundleForClass:[CDVCapture class]]')) { - fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', '[NSBundle mainBundle]'); - fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', '[NSBundle mainBundle]'); + if (!codeFile.$.framework) { + let fileContent = readFileSync(fileDest, 'utf8'); + if (fileExt === 'swift') { + fileContent = 'import Cordova\n' + fileContent; writeFileSync(fileDest, fileContent, 'utf8'); + } else { + if (fileContent.includes('@import Firebase;')) { + fileContent = fileContent.replace('@import Firebase;', '#import '); + writeFileSync(fileDest, fileContent, 'utf8'); + } + if (fileContent.includes('[NSBundle bundleForClass:[self class]]') || fileContent.includes('[NSBundle bundleForClass:[CDVCapture class]]')) { + fileContent = fileContent.replace('[NSBundle bundleForClass:[self class]]', '[NSBundle mainBundle]'); + fileContent = fileContent.replace('[NSBundle bundleForClass:[CDVCapture class]]', '[NSBundle mainBundle]'); + writeFileSync(fileDest, fileContent, 'utf8'); + } } } });