Skip to content

Commit 7a43b7a

Browse files
committed
chore: fix tests
1 parent 9bdefab commit 7a43b7a

File tree

2 files changed

+63
-58
lines changed

2 files changed

+63
-58
lines changed

lib/services/ios-project-service.ts

+45-52
Original file line numberDiff line numberDiff line change
@@ -1116,57 +1116,47 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11161116

11171117
const project = this.createPbxProj(projectData);
11181118

1119-
this.$fs.readDirectory(extensionsFolderPath).forEach(extensionFolder => {
1120-
const extensionPath = path.join(extensionsFolderPath, extensionFolder);
1121-
const group = this.getRootGroup(extensionFolder, extensionPath);
1122-
1123-
const target = project.addTarget(
1124-
extensionFolder,
1125-
'app_extension',
1126-
path.relative(this.getPlatformData(projectData).projectRoot, extensionPath)
1127-
1128-
);
1129-
project.addBuildPhase(
1130-
[],
1131-
'PBXSourcesBuildPhase',
1132-
'Sources',
1133-
target.uuid
1134-
);
1135-
1136-
project.addBuildPhase(
1137-
[],
1138-
'PBXResourcesBuildPhase',
1139-
'Resources',
1140-
target.uuid
1141-
);
1142-
1143-
project.addBuildPhase(
1144-
[],
1145-
'PBXFrameworksBuildPhase',
1146-
'Frameworks',
1147-
target.uuid
1148-
);
1149-
1150-
const extJsonPath = path.join(extensionsFolderPath, extensionFolder, "extension.json");
1151-
if(this.$fs.exists(extJsonPath)) {
1152-
const extensionJson = this.$fs.readJson(extJsonPath);
1153-
_.forEach(extensionJson.frameworks, framework => {
1154-
project.addFramework(
1155-
framework,
1156-
{ target: target.uuid }
1157-
);
1158-
});
1159-
}
1160-
1119+
this.$fs.readDirectory(extensionsFolderPath)
1120+
.filter(fileName => {
1121+
const filePath = path.join(extensionsFolderPath, fileName);
1122+
const stats = this.$fs.getFsStats(filePath);
1123+
return stats.isDirectory() && !fileName.startsWith(".");
1124+
})
1125+
.forEach(extensionFolder => {
1126+
const extensionPath = path.join(extensionsFolderPath, extensionFolder);
1127+
const extensionRelativePath = path.relative(this.getPlatformData(projectData).projectRoot, extensionPath);
1128+
const group = this.getRootGroup(extensionFolder, extensionPath);
1129+
const target = project.addTarget(extensionFolder, 'app_extension', extensionRelativePath);
1130+
project.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid);
1131+
project.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid);
1132+
project.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', target.uuid);
1133+
1134+
const extJsonPath = path.join(extensionsFolderPath, extensionFolder, "extension.json");
1135+
if(this.$fs.exists(extJsonPath)) {
1136+
const extensionJson = this.$fs.readJson(extJsonPath);
1137+
_.forEach(extensionJson.frameworks, framework => {
1138+
project.addFramework(
1139+
framework,
1140+
{ target: target.uuid }
1141+
);
1142+
});
1143+
if(extensionJson.assetcatalogCompilerAppiconName){
1144+
project.addToBuildSettings("ASSETCATALOG_COMPILER_APPICON_NAME", extensionJson.assetcatalogCompilerAppiconName, target.uuid);
1145+
}
1146+
}
11611147

1162-
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true, target: target.uuid, filesRelativeToProject: true });
1163-
project.addBuildProperty("PRODUCT_BUNDLE_IDENTIFIER", `${projectData.projectIdentifiers.ios}.${extensionFolder}`, "Debug", extensionFolder);
1164-
project.addBuildProperty("PRODUCT_BUNDLE_IDENTIFIER", `${projectData.projectIdentifiers.ios}.${extensionFolder}`, "Release", extensionFolder);
1165-
targetUuids.push(target.uuid);
1166-
});
1148+
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true, target: target.uuid, filesRelativeToProject: true });
1149+
project.addBuildProperty("PRODUCT_BUNDLE_IDENTIFIER", `${projectData.projectIdentifiers.ios}.${extensionFolder}`, "Debug", extensionFolder);
1150+
project.addBuildProperty("PRODUCT_BUNDLE_IDENTIFIER", `${projectData.projectIdentifiers.ios}.${extensionFolder}`, "Release", extensionFolder);
1151+
targetUuids.push(target.uuid);
1152+
project.addToHeaderSearchPaths(group.path, target.pbxNativeTarget.productName);
1153+
});
11671154

11681155
this.savePbxProj(project, projectData, true);
1156+
this.prepareExtensionSigning(targetUuids, projectData);
1157+
}
11691158

1159+
private prepareExtensionSigning(targetUuids: string[], projectData:IProjectData) {
11701160
const xcode = this.$pbxprojDomXcode.Xcode.open(this.getPbxProjPath(projectData));
11711161
const signing = xcode.getSigning(projectData.projectName);
11721162
if(signing !== undefined) {
@@ -1189,11 +1179,14 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11891179
const filePathsArr: string[] = [];
11901180
const rootGroup: INativeSourceCodeGroup = { name: name, files: filePathsArr, path: rootPath };
11911181

1192-
if (this.$fs.exists(rootPath) && !this.$fs.isEmptyDir(rootPath)) {
1193-
this.$fs.readDirectory(rootPath).forEach(fileName => {
1194-
const filePath = path.join(rootGroup.path, fileName);
1195-
filePathsArr.push(filePath);
1196-
});
1182+
if (this.$fs.exists(rootPath)) {
1183+
const stats = this.$fs.getFsStats(rootPath);
1184+
if(stats.isDirectory() && !this.$fs.isEmptyDir(rootPath)) {
1185+
this.$fs.readDirectory(rootPath).forEach(fileName => {
1186+
const filePath = path.join(rootGroup.path, fileName);
1187+
filePathsArr.push(filePath);
1188+
});
1189+
}
11971190
}
11981191

11991192
return rootGroup;

test/ios-project-service.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { DeviceDiscovery } from "../lib/common/mobile/mobile-core/device-discove
2222
import { IOSDeviceDiscovery } from "../lib/common/mobile/mobile-core/ios-device-discovery";
2323
import { AndroidDeviceDiscovery } from "../lib/common/mobile/mobile-core/android-device-discovery";
2424
import { PluginVariablesService } from "../lib/services/plugin-variables-service";
25-
import { PluginsService } from "../lib/services/plugins-service";
2625
import { PluginVariablesHelper } from "../lib/common/plugin-variables-helper";
2726
import { Utils } from "../lib/common/utils";
2827
import { CocoaPodsService } from "../lib/services/cocoapods-service";
@@ -77,7 +76,8 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
7776
projectIdentifiers: { android: "", ios: "" },
7877
projectDir: "",
7978
appDirectoryPath: "",
80-
appResourcesDirectoryPath: ""
79+
appResourcesDirectoryPath: "",
80+
getAppResourcesDirectoryPath: ()=>""
8181
});
8282
projectData.projectDir = temp.mkdirSync("projectDir");
8383
projectData.appDirectoryPath = path.join(projectData.projectDir, "app");
@@ -115,7 +115,9 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
115115
testInjector.register("iosDeviceOperations", {});
116116
testInjector.register("pluginVariablesService", PluginVariablesService);
117117
testInjector.register("pluginVariablesHelper", PluginVariablesHelper);
118-
testInjector.register("pluginsService", PluginsService);
118+
testInjector.register("pluginsService", {
119+
getAllInstalledPlugins: (): string[] => []
120+
});
119121
testInjector.register("androidProcessService", {});
120122
testInjector.register("processService", {});
121123
testInjector.register("sysInfo", {
@@ -127,6 +129,8 @@ function createTestInjector(projectPath: string, projectName: string, xcode?: IX
127129
constructor() { /* */ }
128130
parseSync() { /* */ }
129131
pbxGroupByName() { /* */ }
132+
removeTargetsByProductType() { /* */ }
133+
writeSync() { /* */ }
130134
}
131135
});
132136
testInjector.register("userSettingsService", {
@@ -1055,7 +1059,9 @@ describe("iOS Project Service Signing", () => {
10551059
},
10561060
setManualSigningStyle(targetName: string, manualSigning: any) {
10571061
stack.push({ targetName, manualSigning });
1058-
}
1062+
},
1063+
setManualSigningStyleByTargetProductType: () => ({}),
1064+
setManualSigningStyleByTargetKey: () => ({})
10591065
};
10601066
};
10611067
await iOSProjectService.prepareProject(projectData, { sdk: undefined, provision: "NativeScriptDev", teamId: undefined });
@@ -1074,7 +1080,9 @@ describe("iOS Project Service Signing", () => {
10741080
},
10751081
setManualSigningStyle(targetName: string, manualSigning: any) {
10761082
stack.push({ targetName, manualSigning });
1077-
}
1083+
},
1084+
setManualSigningStyleByTargetProductType: () => ({}),
1085+
setManualSigningStyleByTargetKey: () => ({})
10781086
};
10791087
};
10801088
await iOSProjectService.prepareProject(projectData, { sdk: undefined, provision: "NativeScriptDist", teamId: undefined });
@@ -1093,7 +1101,9 @@ describe("iOS Project Service Signing", () => {
10931101
},
10941102
setManualSigningStyle(targetName: string, manualSigning: any) {
10951103
stack.push({ targetName, manualSigning });
1096-
}
1104+
},
1105+
setManualSigningStyleByTargetProductType: () => ({}),
1106+
setManualSigningStyleByTargetKey: () => ({})
10971107
};
10981108
};
10991109
await iOSProjectService.prepareProject(projectData, { sdk: undefined, provision: "NativeScriptAdHoc", teamId: undefined });
@@ -1282,6 +1292,8 @@ describe("buildProject", () => {
12821292
open: () => ({
12831293
getSigning: () => ({}),
12841294
setAutomaticSigningStyle: () => ({}),
1295+
setAutomaticSigningStyleByTargetProductType: () => ({}),
1296+
setAutomaticSigningStyleByTargetKey: () => ({}),
12851297
save: () => ({})
12861298
})
12871299
};

0 commit comments

Comments
 (0)