Skip to content

Commit b20c14f

Browse files
committed
fix: reprepare iOS plugins on cleanup
1 parent 7d540b6 commit b20c14f

3 files changed

Lines changed: 167 additions & 109 deletions

File tree

lib/services/bundler/bundler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ declare global {
7979
}
8080

8181
interface IPlatformProjectService
82-
extends NodeJS.EventEmitter,
83-
IPlatformProjectServiceBase {
82+
extends NodeJS.EventEmitter, IPlatformProjectServiceBase {
8483
getPlatformData(projectData: IProjectData): IPlatformData;
8584
validate(
8685
projectData: IProjectData,
@@ -153,6 +152,11 @@ declare global {
153152
options?: any,
154153
): Promise<void>;
155154

155+
shouldRepreparePlugin?(
156+
pluginData: IPluginData,
157+
projectData: IProjectData,
158+
): boolean;
159+
156160
/**
157161
* Removes native code of a plugin (CocoaPods, jars, libs, src).
158162
* @param {IPluginData} Plugins data describing the plugin which should be cleaned.

lib/services/ios-project-service.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ const getConfigurationName = (release: boolean): string => {
9292
return release ? Configurations.Release : Configurations.Debug;
9393
};
9494

95-
export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase {
95+
export class IOSProjectService
96+
extends projectServiceBaseLib.PlatformProjectServiceBase
97+
{
9698
private static IOS_PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__";
9799
private static IOS_PLATFORM_NAME = "ios";
98100

@@ -1164,6 +1166,52 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
11641166
);
11651167
}
11661168

1169+
public shouldRepreparePlugin(
1170+
pluginData: IPluginData,
1171+
projectData: IProjectData,
1172+
): boolean {
1173+
const pluginPlatformsFolderPath = pluginData.pluginPlatformsFolderPath(
1174+
IOSProjectService.IOS_PLATFORM_NAME,
1175+
);
1176+
1177+
for (const fileName of this.getAllLibsForPluginWithFileExtension(
1178+
pluginData,
1179+
".a",
1180+
)) {
1181+
const staticLibPath = path.join(pluginPlatformsFolderPath, fileName);
1182+
const libraryName = path.basename(staticLibPath, ".a");
1183+
const headersSubpath = path.join(
1184+
path.dirname(staticLibPath),
1185+
"include",
1186+
libraryName,
1187+
);
1188+
1189+
if (!this.$fs.exists(headersSubpath)) {
1190+
continue;
1191+
}
1192+
1193+
const headerFiles = this.$fs
1194+
.readDirectory(headersSubpath)
1195+
.filter(
1196+
(f) =>
1197+
path.extname(f) === ".h" &&
1198+
this.$fs.getFsStats(path.join(headersSubpath, f)).isFile(),
1199+
);
1200+
1201+
if (
1202+
headerFiles.length > 0 &&
1203+
!this.$fs.exists(path.join(headersSubpath, "module.modulemap"))
1204+
) {
1205+
this.$logger.trace(
1206+
`Plugin ${pluginData.name}: modulemap missing at ${headersSubpath}, will re-prepare`,
1207+
);
1208+
return true;
1209+
}
1210+
}
1211+
1212+
return false;
1213+
}
1214+
11671215
public async removePluginNativeCode(
11681216
pluginData: IPluginData,
11691217
projectData: IProjectData,

0 commit comments

Comments
 (0)