Skip to content

Commit 2578ae7

Browse files
Fatme HavaluovaFatme Havaluova
authored andcommitted
Execute pod install when a plugin containing only Podfile is added after the ios platform
Fixes #827
1 parent 0debe12 commit 2578ae7

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

lib/definitions/project.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interface IPlatformProjectService {
4343
addLibrary(libraryPath: string): IFuture<void>;
4444
canUpdatePlatform(currentVersion: string, newVersion: string): IFuture<boolean>;
4545
updatePlatform(currentVersion: string, newVersion: string): IFuture<void>;
46-
preparePluginNativeCode(pluginData: IPluginData): IFuture<void>;
46+
preparePluginNativeCode(pluginData: IPluginData, options?: any): IFuture<void>;
4747
removePluginNativeCode(pluginData: IPluginData): IFuture<void>;
4848
afterPrepareAllPlugins(): IFuture<void>;
4949
getAppResourcesDestinationDirectoryPath(): IFuture<string>;

lib/services/ios-project-service.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
329329
return this.$fs.writeFile(this.pbxProjPath, project.writeSync());
330330
}
331331

332-
public preparePluginNativeCode(pluginData: IPluginData): IFuture<void> {
332+
public preparePluginNativeCode(pluginData: IPluginData, opts?: any): IFuture<void> {
333333
return (() => {
334334
let pluginPlatformsFolderPath = pluginData.pluginPlatformsFolderPath(IOSProjectService.IOS_PLATFORM_NAME);
335335
this.prepareFrameworks(pluginPlatformsFolderPath, pluginData).wait();
336-
this.prepareCocoapods(pluginPlatformsFolderPath).wait();
336+
this.prepareCocoapods(pluginPlatformsFolderPath, opts).wait();
337337
}).future<void>()();
338338
}
339339

@@ -372,8 +372,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
372372
this.$childProcess.exec(createSchemeRubyScript, { cwd: this.platformData.projectRoot }).wait();
373373
}
374374

375-
this.$logger.info("Installing pods...");
376-
this.$childProcess.exec("pod install", { cwd: this.platformData.projectRoot }).wait();
375+
this.executePodInstall().wait();
377376
}
378377
}).future<void>()();
379378
}
@@ -418,23 +417,33 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
418417
}).future<void>()();
419418
}
420419

420+
private executePodInstall(): IFuture<any> {
421+
this.$logger.info("Installing pods...");
422+
return this.$childProcess.exec("pod install", { cwd: this.platformData.projectRoot });
423+
}
424+
421425
private prepareFrameworks(pluginPlatformsFolderPath: string, pluginData: IPluginData): IFuture<void> {
422426
return (() => {
423427
_.each(this.getAllFrameworksForPlugin(pluginData).wait(), fileName => this.addLibrary(path.join(pluginPlatformsFolderPath, fileName)).wait());
424428
}).future<void>()();
425429
}
426430

427-
private prepareCocoapods(pluginPlatformsFolderPath: string): IFuture<void> {
431+
private prepareCocoapods(pluginPlatformsFolderPath: string, opts?: any): IFuture<void> {
428432
return (() => {
429-
if(!this.$fs.exists(this.projectPodFilePath).wait()) {
430-
this.$fs.writeFile(this.projectPodFilePath, "use_frameworks!\n").wait();
431-
}
432433
let pluginPodFilePath = path.join(pluginPlatformsFolderPath, "Podfile");
433434
if(this.$fs.exists(pluginPodFilePath).wait()) {
435+
if(!this.$fs.exists(this.projectPodFilePath).wait()) {
436+
this.$fs.writeFile(this.projectPodFilePath, "use_frameworks!\n").wait();
437+
}
438+
434439
let pluginPodFileContent = this.$fs.readText(pluginPodFilePath).wait();
435440
let contentToWrite = this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent);
436441
this.$fs.appendFile(this.projectPodFilePath, contentToWrite).wait();
437442
}
443+
444+
if(opts && opts.executePodInstall && this.$fs.exists(pluginPodFilePath).wait()) {
445+
this.executePodInstall().wait();
446+
}
438447
}).future<void>()();
439448
}
440449

lib/services/plugins-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class PluginsService implements IPluginsService {
116116
this.$projectFilesManager.processPlatformSpecificFiles(pluginDestinationPath, platform).wait();
117117

118118
pluginData.pluginPlatformsFolderPath = (_platform: string) => path.join(pluginData.fullPath, "platforms", _platform);
119-
platformData.platformProjectService.preparePluginNativeCode(pluginData).wait();
119+
platformData.platformProjectService.preparePluginNativeCode(pluginData, {executePodInstall: true }).wait();
120120

121121
shelljs.rm("-rf", path.join(pluginDestinationPath, pluginData.name, "platforms"));
122122

0 commit comments

Comments
 (0)