Skip to content

Commit 3787075

Browse files
committed
Remove plugin native source code on 'tns plugin remove'
1 parent 9a111d4 commit 3787075

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

lib/services/ios-project-service.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@ import * as mobileprovision from "ios-mobileprovision-finder";
1717
import { SpawnOptions } from "child_process";
1818
import { BUILD_XCCONFIG_FILE_NAME } from "../constants";
1919

20-
interface INativeSourceCodeDescription {
21-
path: string;
22-
name: string;
23-
}
24-
2520
interface INativeSourceCodeGroup {
2621
name: string;
2722
path: string;
28-
files: INativeSourceCodeDescription[];
23+
files: string[];
2924
}
3025

3126
export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase implements IPlatformProjectService {
@@ -949,6 +944,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
949944
public async removePluginNativeCode(pluginData: IPluginData, projectData: IProjectData): Promise<void> {
950945
const pluginPlatformsFolderPath = pluginData.pluginPlatformsFolderPath(IOSProjectService.IOS_PLATFORM_NAME);
951946

947+
this.removeNativeSourceCode(pluginPlatformsFolderPath, pluginData, projectData);
952948
this.removeFrameworks(pluginPlatformsFolderPath, pluginData, projectData);
953949
this.removeStaticLibs(pluginPlatformsFolderPath, pluginData, projectData);
954950
this.removeCocoapods(pluginPlatformsFolderPath, projectData);
@@ -1123,20 +1119,19 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11231119
private async prepareNativeSourceCode(pluginName: string, pluginPlatformsFolderPath: string, projectData: IProjectData): Promise<void> {
11241120
const project = this.createPbxProj(projectData);
11251121
const group = this.getRootGroup(pluginName, pluginPlatformsFolderPath);
1126-
project.addPbxGroup(group.files.map(f => f.path), group.name, group.path, null, {isMain:true});
1122+
project.addPbxGroup(group.files, group.name, group.path, null, {isMain:true});
11271123
project.addToHeaderSearchPaths(group.path);
11281124
this.savePbxProj(project, projectData);
11291125
}
11301126

11311127
private getRootGroup(name: string, rootPath: string) {
1132-
const filesArr: INativeSourceCodeDescription[] = [];
1133-
const rootGroup: INativeSourceCodeGroup = { name: name, files: filesArr, path: rootPath };
1128+
const filePathsArr: string[] = [];
1129+
const rootGroup: INativeSourceCodeGroup = { name: name, files: filePathsArr, path: rootPath };
11341130

11351131
if (this.$fs.exists(rootPath) && !this.$fs.isEmptyDir(rootPath)) {
11361132
this.$fs.readDirectory(rootPath).forEach(fileName => {
11371133
const filePath = path.join(rootGroup.path, fileName);
1138-
const file: INativeSourceCodeDescription = { name: fileName, path: filePath};
1139-
filesArr.push(file);
1134+
filePathsArr.push(filePath);
11401135
});
11411136
}
11421137

@@ -1199,6 +1194,14 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11991194
}
12001195
}
12011196

1197+
private removeNativeSourceCode(pluginPlatformsFolderPath: string, pluginData: IPluginData, projectData: IProjectData): void {
1198+
const project = this.createPbxProj(projectData);
1199+
const group = this.getRootGroup(pluginData.name, pluginPlatformsFolderPath);
1200+
project.removePbxGroup(group.name, group.path);
1201+
project.removeFromHeaderSearchPaths(group.path);
1202+
this.savePbxProj(project, projectData);
1203+
}
1204+
12021205
private removeFrameworks(pluginPlatformsFolderPath: string, pluginData: IPluginData, projectData: IProjectData): void {
12031206
const project = this.createPbxProj(projectData);
12041207
_.each(this.getAllLibsForPluginWithFileExtension(pluginData, ".framework"), fileName => {

0 commit comments

Comments
 (0)