|
1 | 1 | import plist from 'plist'; |
2 | | -import path, { join } from 'path'; |
| 2 | +import path, { join, sep } from 'path'; |
3 | 3 | import fetch from 'cross-fetch'; |
4 | 4 | import { copy, pathExists, readdir, writeFile } from '@ionic/utils-fs'; |
5 | 5 |
|
@@ -86,7 +86,7 @@ export class IosProject extends PlatformProject { |
86 | 86 | } |
87 | 87 |
|
88 | 88 | async getPlistFile(path: string) { |
89 | | - return this.getProjectFile(path, (filename: string) => new PlistFile(filename, this.project.vfs)); |
| 89 | + return this.getProjectFile(path, (filename: string) => new PlistFile(filename, this.project.vfs, this.project)); |
90 | 90 | } |
91 | 91 |
|
92 | 92 | getPbxProject() { |
@@ -534,8 +534,9 @@ export class IosProject extends PlatformProject { |
534 | 534 | return value.isa === 'PBXGroup' && (value.name === appTarget || value.path === appTarget); |
535 | 535 | }); |
536 | 536 |
|
537 | | - if (appGroup) { |
538 | | - this.pbxProject?.addSourceFile(path, {}, appGroup?.[0]); |
| 537 | + const pathSplit = path.split(sep); |
| 538 | + if (pathSplit[0] === appTarget && appGroup) { |
| 539 | + this.pbxProject?.addSourceFile(pathSplit.slice(1).join(sep), {}, appGroup?.[0]); |
539 | 540 | } else { |
540 | 541 | this.pbxProject?.addSourceFile(path, {}, emptyGroup?.[0]); |
541 | 542 | } |
@@ -623,7 +624,7 @@ export class IosProject extends PlatformProject { |
623 | 624 | return open.getData() as PlistFile; |
624 | 625 | } |
625 | 626 |
|
626 | | - const plistFile = new PlistFile(filename, this.project.vfs); |
| 627 | + const plistFile = new PlistFile(filename, this.project.vfs, this.project); |
627 | 628 |
|
628 | 629 | await plistFile.load(); |
629 | 630 |
|
@@ -678,15 +679,4 @@ export class IosProject extends PlatformProject { |
678 | 679 | await writeFile(file.getFilename(), this.pbxProject.writeSync()); |
679 | 680 | } |
680 | 681 | } |
681 | | - |
682 | | - private plistCommitFn = async (file: VFSFile) => { |
683 | | - const data = file.getData() as PlistFile; |
684 | | - const xml = plist.build(data.getDocument() ?? {}, { |
685 | | - indent: ' ', // Tab character |
686 | | - offset: -1, |
687 | | - newline: '\n' |
688 | | - }); |
689 | | - await assertParentDirs(file.getFilename()); |
690 | | - return writeFile(file.getFilename(), xml); |
691 | | - } |
692 | 682 | } |
0 commit comments