Skip to content

Commit 23fcd2a

Browse files
committed
feat: add extensions from plugins
1 parent 488fea2 commit 23fcd2a

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

lib/services/ios-project-service.ts

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,6 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
775775
);
776776

777777
await this.prepareNativeSourceCode(constants.TNS_NATIVE_SOURCE_GROUP_NAME, resourcesNativeCodePath, projectData);
778-
await this.prepareExtensionsCode(constants.TNS_NATIVE_EXTENSIONS_GROUP_NAME, path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, constants.NATIVE_EXTENSION_FOLDER), projectData);
779778
}
780779

781780
}
@@ -981,6 +980,17 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
981980
// So the correct order is `pod install` to be executed before merging pod's xcconfig file.
982981
await this.$cocoapodsService.mergePodXcconfigFile(projectData, platformData, opts);
983982
}
983+
984+
this.removeExtensions(projectData);
985+
await this.prepareExtensionsCode(path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, constants.NATIVE_EXTENSION_FOLDER), projectData);
986+
const plugins = await this.getAllInstalledPlugins(projectData);
987+
for (const pluginIndex in plugins) {
988+
const pluginData = plugins[pluginIndex];
989+
const pluginPlatformsFolderPath = pluginData.pluginPlatformsFolderPath(IOSProjectService.IOS_PLATFORM_NAME);
990+
991+
const extensionPath = path.join(pluginPlatformsFolderPath, constants.NATIVE_EXTENSION_FOLDER);
992+
await this.prepareExtensionsCode(extensionPath, projectData);
993+
};
984994
}
985995
public beforePrepareAllPlugins(): Promise<void> {
986996
return Promise.resolve();
@@ -1096,7 +1106,11 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
10961106
this.savePbxProj(project, projectData);
10971107
}
10981108

1099-
private async prepareExtensionsCode(groupName: string, extensionsFolderPath: string, projectData: IProjectData): Promise<void> {
1109+
private async prepareExtensionsCode(extensionsFolderPath: string, projectData: IProjectData): Promise<void> {
1110+
if(!this.$fs.exists(extensionsFolderPath)){
1111+
return;
1112+
}
1113+
11001114
const project = this.createPbxProj(projectData);
11011115

11021116
this.$fs.readDirectory(extensionsFolderPath).forEach(extensionFolder => {
@@ -1109,35 +1123,40 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11091123
path.relative(this.getPlatformData(projectData).projectRoot, extensionPath)
11101124

11111125
);
1112-
const sourcesBuildPhase = project.addBuildPhase(
1126+
project.addBuildPhase(
11131127
[],
11141128
'PBXSourcesBuildPhase',
11151129
'Sources',
11161130
target.uuid
11171131
);
1118-
const frameworksBuildPhase = project.addBuildPhase(
1132+
1133+
project.addBuildPhase(
11191134
[],
1120-
'PBXFrameworksBuildPhase',
1121-
'Frameworks',
1135+
'PBXResourcesBuildPhase',
1136+
'Resources',
11221137
target.uuid
11231138
);
11241139

1125-
const extensionJson = this.$fs.readJson(path.join(extensionsFolderPath, extensionFolder, "extension.json"));
1126-
_.forEach(extensionJson.frameworks, framework => {
1127-
project.addFramework(
1128-
framework,
1129-
{ target: target.uuid }
1130-
);
1131-
});
1132-
var resourcesBuildPhase = project.addBuildPhase(
1140+
project.addBuildPhase(
11331141
[],
1134-
'PBXResourcesBuildPhase',
1135-
'Resources',
1142+
'PBXFrameworksBuildPhase',
1143+
'Frameworks',
11361144
target.uuid
11371145
);
11381146

1147+
const extJsonPath = path.join(extensionsFolderPath, extensionFolder, "extension.json");
1148+
if(this.$fs.exists(extJsonPath)) {
1149+
const extensionJson = this.$fs.readJson(extJsonPath);
1150+
_.forEach(extensionJson.frameworks, framework => {
1151+
project.addFramework(
1152+
framework,
1153+
{ target: target.uuid }
1154+
);
1155+
});
1156+
}
11391157

1140-
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true, target: target.uuid });
1158+
1159+
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true, target: target.uuid, filesRelativeToProject: true });
11411160
project.addBuildProperty("PRODUCT_BUNDLE_IDENTIFIER", `${projectData.projectIdentifiers.ios}.${extensionFolder}`, "Debug", extensionFolder);
11421161
project.addBuildProperty("PRODUCT_BUNDLE_IDENTIFIER", `${projectData.projectIdentifiers.ios}.${extensionFolder}`, "Release", extensionFolder);
11431162
});
@@ -1195,6 +1214,12 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11951214
this.savePbxProj(project, projectData);
11961215
}
11971216

1217+
private removeExtensions(projectData: IProjectData): void {
1218+
const project = this.createPbxProj(projectData);
1219+
project.removeTargetsByProductType("com.apple.product-type.app-extension");
1220+
this.savePbxProj(project, projectData);
1221+
}
1222+
11981223
private removeFrameworks(pluginPlatformsFolderPath: string, pluginData: IPluginData, projectData: IProjectData): void {
11991224
const project = this.createPbxProj(projectData);
12001225
_.each(this.getAllLibsForPluginWithFileExtension(pluginData, ".framework"), fileName => {

0 commit comments

Comments
 (0)