Skip to content

Commit

Permalink
fix(cordova): handle source-file with framework attribute (#2507)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Mar 2, 2020
1 parent ffdd78c commit f7cd4c0
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions cli/src/ios/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Firebase/Firebase.h>');
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 <Firebase/Firebase.h>');
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');
}
}
}
});
Expand Down

0 comments on commit f7cd4c0

Please sign in to comment.