Skip to content

Commit 51ed81b

Browse files
committed
chore: fix comments
1 parent 6caa6f6 commit 51ed81b

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

lib/definitions/project.d.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,6 @@ interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectS
472472
getDeploymentTarget(projectData: IProjectData): any;
473473
}
474474

475-
interface INativeSourceCodeGroup {
476-
name: string;
477-
path: string;
478-
files: string[];
479-
}
480-
481475
interface IValidatePlatformOutput {
482476
checkEnvironmentRequirementsOutput: ICheckEnvironmentRequirementsOutput;
483477
}
@@ -576,8 +570,21 @@ interface ICocoaPodsPlatformManager {
576570
* Describes a service used to add and remove iOS extension
577571
*/
578572
interface IIOSExtensionsService {
579-
addExtensionsFromPath(extensionsFolderPath: string, projectData: IProjectData, platformData: IPlatformData, projectPath: string, project: IXcode.project): Promise<void>;
580-
removeExtensions(project: IXcode.project, projectPath: string): void;
573+
addExtensionsFromPath(options: IAddExtensionsFromPathOptions): Promise<void>;
574+
removeExtensions(options: IRemoveExtensionsOptions): void;
575+
}
576+
577+
interface IAddExtensionsFromPathOptions{
578+
extensionsFolderPath: string;
579+
projectData: IProjectData;
580+
platformData: IPlatformData;
581+
pbxProjPath: string;
582+
project: IXcode.project;
583+
}
584+
585+
interface IRemoveExtensionsOptions {
586+
project: IXcode.project;
587+
pbxProjPath: string
581588
}
582589

583590
interface IRubyFunction {

lib/services/ios-extensions-service.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class IOSExtensionsService implements IIOSExtensionsService {
55
private $pbxprojDomXcode: IPbxprojDomXcode) {
66
}
77

8-
public async addExtensionsFromPath(extensionsFolderPath: string, projectData: IProjectData, platformData: IPlatformData, projectPath: string, project: IXcode.project): Promise<void> {
8+
public async addExtensionsFromPath({extensionsFolderPath, projectData, platformData, pbxProjPath, project}: IAddExtensionsFromPathOptions): Promise<void> {
99
const targetUuids: string[] = [];
1010
if (!this.$fs.exists(extensionsFolderPath)) {
1111
return;
@@ -23,8 +23,8 @@ export class IOSExtensionsService implements IIOSExtensionsService {
2323
targetUuids.push(targetUuid);
2424
});
2525

26-
this.$fs.writeFile(projectPath, project.writeSync({omitEmptyValues: true}));
27-
this.prepareExtensionSigning(targetUuids, projectData, projectPath);
26+
this.$fs.writeFile(pbxProjPath, project.writeSync({omitEmptyValues: true}));
27+
this.prepareExtensionSigning(targetUuids, projectData, pbxProjPath);
2828
}
2929

3030
private addExtensionToProject(extensionsFolderPath: string, extensionFolder: string, project: IXcode.project, projectData: IProjectData, platformData: IPlatformData): string {
@@ -33,7 +33,6 @@ export class IOSExtensionsService implements IIOSExtensionsService {
3333
const files = this.$fs.readDirectory(extensionPath)
3434
.filter(filePath => !filePath.startsWith("."))
3535
.map(filePath => path.join(extensionPath, filePath));
36-
const group: INativeSourceCodeGroup = { name: extensionFolder, path: extensionPath, files};
3736
const target = project.addTarget(extensionFolder, 'app_extension', extensionRelativePath);
3837
project.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid);
3938
project.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid);
@@ -53,10 +52,10 @@ export class IOSExtensionsService implements IIOSExtensionsService {
5352
}
5453
}
5554

56-
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true, target: target.uuid, filesRelativeToProject: true });
55+
project.addPbxGroup(files, extensionFolder, extensionPath, null, { isMain: true, target: target.uuid, filesRelativeToProject: true });
5756
project.addBuildProperty("PRODUCT_BUNDLE_IDENTIFIER", `${projectData.projectIdentifiers.ios}.${extensionFolder}`, "Debug", extensionFolder);
5857
project.addBuildProperty("PRODUCT_BUNDLE_IDENTIFIER", `${projectData.projectIdentifiers.ios}.${extensionFolder}`, "Release", extensionFolder);
59-
project.addToHeaderSearchPaths(group.path, target.pbxNativeTarget.productName);
58+
project.addToHeaderSearchPaths(extensionPath, target.pbxNativeTarget.productName);
6059

6160
return target.uuid;
6261
}
@@ -80,9 +79,9 @@ export class IOSExtensionsService implements IIOSExtensionsService {
8079
xcode.save();
8180
}
8281

83-
public removeExtensions(project: IXcode.project, projectPath: string): void {
82+
public removeExtensions({project, pbxProjPath}: IRemoveExtensionsOptions): void {
8483
project.removeTargetsByProductType("com.apple.product-type.app-extension");
85-
this.$fs.writeFile(projectPath, project.writeSync({omitEmptyValues: true}));
84+
this.$fs.writeFile(pbxProjPath, project.writeSync({omitEmptyValues: true}));
8685
}
8786
}
8887

lib/services/ios-project-service.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import { IOSEntitlementsService } from "./ios-entitlements-service";
1515
import * as mobileprovision from "ios-mobileprovision-finder";
1616
import { BUILD_XCCONFIG_FILE_NAME, IosProjectConstants } from "../constants";
1717

18+
interface INativeSourceCodeGroup {
19+
name: string;
20+
path: string;
21+
files: string[];
22+
}
23+
1824
const DevicePlatformSdkName = "iphoneos";
1925
const SimulatorPlatformSdkName = "iphonesimulator";
2026

@@ -977,9 +983,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
977983
await this.$cocoapodsService.mergePodXcconfigFile(projectData, platformData, opts);
978984
}
979985

980-
const pbxprojPath = this.getPbxProjPath(projectData);
986+
const pbxProjPath = this.getPbxProjPath(projectData);
981987
const project = this.createPbxProj(projectData);
982-
this.$iOSExtensionsService.removeExtensions(project, pbxprojPath);
988+
this.$iOSExtensionsService.removeExtensions({project, pbxProjPath});
983989
await this.addExtensions(projectData);
984990
}
985991
public beforePrepareAllPlugins(): Promise<void> {
@@ -1102,16 +1108,16 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11021108
this.getPlatformData(projectData).normalizedPlatformName, constants.NATIVE_EXTENSION_FOLDER
11031109
);
11041110
const platformData = this.getPlatformData(projectData);
1105-
const pbxProjectPath = this.getPbxProjPath(projectData);
1111+
const pbxProjPath = this.getPbxProjPath(projectData);
11061112
const project = this.createPbxProj(projectData);
1107-
await this.$iOSExtensionsService.addExtensionsFromPath(resorcesExtensionsPath, projectData, platformData, pbxProjectPath, project);
1113+
await this.$iOSExtensionsService.addExtensionsFromPath({extensionsFolderPath: resorcesExtensionsPath, projectData, platformData, pbxProjPath, project});
11081114
const plugins = await this.getAllInstalledPlugins(projectData);
11091115
for (const pluginIndex in plugins) {
11101116
const pluginData = plugins[pluginIndex];
11111117
const pluginPlatformsFolderPath = pluginData.pluginPlatformsFolderPath(IOSProjectService.IOS_PLATFORM_NAME);
11121118

11131119
const extensionPath = path.join(pluginPlatformsFolderPath, constants.NATIVE_EXTENSION_FOLDER);
1114-
await this.$iOSExtensionsService.addExtensionsFromPath(extensionPath, projectData, platformData, pbxProjectPath, project);
1120+
await this.$iOSExtensionsService.addExtensionsFromPath({extensionsFolderPath: extensionPath, projectData, platformData, pbxProjPath, project});
11151121
}
11161122
}
11171123

0 commit comments

Comments
 (0)