Skip to content

Commit b6e652c

Browse files
committed
initial extensions spike
1 parent e39bbc4 commit b6e652c

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

lib/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ export const APK_EXTENSION_NAME = ".apk";
4545
export const AAB_EXTENSION_NAME = ".aab";
4646
export const HASHES_FILE_NAME = ".nshashes";
4747
export const TNS_NATIVE_SOURCE_GROUP_NAME = "TNSNativeSource";
48+
export const TNS_NATIVE_EXTENSIONS_GROUP_NAME = "TNSExtensions";
4849
export const NATIVE_SOURCE_FOLDER = "src";
4950
export const APPLICATION_RESPONSE_TIMEOUT_SECONDS = 60;
51+
export const NATIVE_EXTENSION_FOLDER = "extensions";
5052

5153
export class PackageVersion {
5254
static NEXT = "next";

lib/services/ios-project-service.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ 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);
778779
}
779780

780781
}
@@ -788,6 +789,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
788789

789790
// src folder should not be copied as the pbxproject will have references to its files
790791
this.$fs.deleteDirectory(path.join(appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, constants.NATIVE_SOURCE_FOLDER));
792+
this.$fs.deleteDirectory(path.join(appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, constants.NATIVE_EXTENSION_FOLDER));
791793

792794
this.$fs.deleteDirectory(this.getAppResourcesDestinationDirectoryPath(projectData));
793795
}
@@ -949,6 +951,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
949951
await this.prepareResources(pluginPlatformsFolderPath, pluginData, projectData);
950952
await this.prepareFrameworks(pluginPlatformsFolderPath, pluginData, projectData);
951953
await this.prepareStaticLibs(pluginPlatformsFolderPath, pluginData, projectData);
954+
//await this.prepareApplicationExtensions(pluginPlatformsFolderPath, pluginData, projectData);
952955

953956
const projectRoot = this.getPlatformData(projectData).projectRoot;
954957
await this.$cocoapodsService.applyPodfileToProject(pluginData.name, this.$cocoapodsService.getPluginPodfilePath(pluginData), projectData, projectRoot);
@@ -1093,6 +1096,51 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
10931096
this.savePbxProj(project, projectData);
10941097
}
10951098

1099+
private async prepareExtensionsCode(groupName: string, extensionsFolderPath: string, projectData: IProjectData): Promise<void> {
1100+
const project = this.createPbxProj(projectData);
1101+
1102+
this.$fs.readDirectory(extensionsFolderPath).forEach(extensionFolder => {
1103+
const group = this.getRootGroup(extensionFolder, path.join(extensionsFolderPath, extensionFolder));
1104+
1105+
const target = project.addTarget(
1106+
extensionFolder,
1107+
'app_extension'
1108+
);
1109+
const sourcesBuildPhase = project.addBuildPhase(
1110+
[],
1111+
'PBXSourcesBuildPhase',
1112+
'Sources',
1113+
target.uuid
1114+
);
1115+
const frameworksBuildPhase = project.addBuildPhase(
1116+
[],
1117+
'PBXFrameworksBuildPhase',
1118+
'Frameworks',
1119+
target.uuid
1120+
);
1121+
1122+
const extensionJson = this.$fs.readJson(path.join(extensionsFolderPath, extensionFolder, "extension.json"));
1123+
_.forEach(extensionJson.frameworks, framework => {
1124+
project.addFramework(
1125+
framework,
1126+
{ target: target.uuid }
1127+
);
1128+
});
1129+
var resourcesBuildPhase = project.addBuildPhase(
1130+
[],
1131+
'PBXResourcesBuildPhase',
1132+
'Resources',
1133+
target.uuid
1134+
);
1135+
1136+
1137+
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true, target: target.uuid });
1138+
1139+
});
1140+
1141+
this.savePbxProj(project, projectData);
1142+
}
1143+
10961144
private getRootGroup(name: string, rootPath: string) {
10971145
const filePathsArr: string[] = [];
10981146
const rootGroup: INativeSourceCodeGroup = { name: name, files: filePathsArr, path: rootPath };
@@ -1131,6 +1179,10 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11311179
}
11321180
}
11331181

1182+
// private prepareApplicationExtensions(pluginPlatformsFolderPath: string, pluginData: IPluginData, projectData: IProjectData): Promise<void> {
1183+
1184+
// }
1185+
11341186
private removeNativeSourceCode(pluginPlatformsFolderPath: string, pluginData: IPluginData, projectData: IProjectData): void {
11351187
const project = this.createPbxProj(projectData);
11361188
const group = this.getRootGroup(pluginData.name, pluginPlatformsFolderPath);

0 commit comments

Comments
 (0)