Skip to content

Commit 4512b0a

Browse files
committed
fix: project parsed once and overrides previous target
1 parent 51ed81b commit 4512b0a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/definitions/project.d.ts

-2
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,9 @@ interface IAddExtensionsFromPathOptions{
579579
projectData: IProjectData;
580580
platformData: IPlatformData;
581581
pbxProjPath: string;
582-
project: IXcode.project;
583582
}
584583

585584
interface IRemoveExtensionsOptions {
586-
project: IXcode.project;
587585
pbxProjPath: string
588586
}
589587

lib/services/ios-extensions-service.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import * as path from "path";
22

33
export class IOSExtensionsService implements IIOSExtensionsService {
44
constructor(private $fs: IFileSystem,
5-
private $pbxprojDomXcode: IPbxprojDomXcode) {
5+
private $pbxprojDomXcode: IPbxprojDomXcode,
6+
private $xcode: IXcode) {
67
}
78

8-
public async addExtensionsFromPath({extensionsFolderPath, projectData, platformData, pbxProjPath, project}: IAddExtensionsFromPathOptions): Promise<void> {
9+
public async addExtensionsFromPath({extensionsFolderPath, projectData, platformData, pbxProjPath}: IAddExtensionsFromPathOptions): Promise<void> {
910
const targetUuids: string[] = [];
1011
if (!this.$fs.exists(extensionsFolderPath)) {
1112
return;
1213
}
13-
14+
const project = new this.$xcode.project(pbxProjPath);
15+
project.parseSync();
1416
this.$fs.readDirectory(extensionsFolderPath)
1517
.filter(fileName => {
1618
const filePath = path.join(extensionsFolderPath, fileName);
@@ -79,7 +81,9 @@ export class IOSExtensionsService implements IIOSExtensionsService {
7981
xcode.save();
8082
}
8183

82-
public removeExtensions({project, pbxProjPath}: IRemoveExtensionsOptions): void {
84+
public removeExtensions({pbxProjPath}: IRemoveExtensionsOptions): void {
85+
const project = new this.$xcode.project(pbxProjPath);
86+
project.parseSync();
8387
project.removeTargetsByProductType("com.apple.product-type.app-extension");
8488
this.$fs.writeFile(pbxProjPath, project.writeSync({omitEmptyValues: true}));
8589
}

lib/services/ios-project-service.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
984984
}
985985

986986
const pbxProjPath = this.getPbxProjPath(projectData);
987-
const project = this.createPbxProj(projectData);
988-
this.$iOSExtensionsService.removeExtensions({project, pbxProjPath});
987+
this.$iOSExtensionsService.removeExtensions({pbxProjPath});
989988
await this.addExtensions(projectData);
990989
}
991990
public beforePrepareAllPlugins(): Promise<void> {
@@ -1109,15 +1108,14 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11091108
);
11101109
const platformData = this.getPlatformData(projectData);
11111110
const pbxProjPath = this.getPbxProjPath(projectData);
1112-
const project = this.createPbxProj(projectData);
1113-
await this.$iOSExtensionsService.addExtensionsFromPath({extensionsFolderPath: resorcesExtensionsPath, projectData, platformData, pbxProjPath, project});
1111+
await this.$iOSExtensionsService.addExtensionsFromPath({extensionsFolderPath: resorcesExtensionsPath, projectData, platformData, pbxProjPath});
11141112
const plugins = await this.getAllInstalledPlugins(projectData);
11151113
for (const pluginIndex in plugins) {
11161114
const pluginData = plugins[pluginIndex];
11171115
const pluginPlatformsFolderPath = pluginData.pluginPlatformsFolderPath(IOSProjectService.IOS_PLATFORM_NAME);
11181116

11191117
const extensionPath = path.join(pluginPlatformsFolderPath, constants.NATIVE_EXTENSION_FOLDER);
1120-
await this.$iOSExtensionsService.addExtensionsFromPath({extensionsFolderPath: extensionPath, projectData, platformData, pbxProjPath, project});
1118+
await this.$iOSExtensionsService.addExtensionsFromPath({extensionsFolderPath: extensionPath, projectData, platformData, pbxProjPath});
11211119
}
11221120
}
11231121

0 commit comments

Comments
 (0)