Skip to content

Commit 441a280

Browse files
FatmeFatme
authored andcommitted
Merge pull request #870 from NativeScript/fatme/fix-cocoapods
Execute pod install when a plugin containing only Podfile is added after the ios platform
2 parents 96bc691 + 2578ae7 commit 441a280

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
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: 13 additions & 5 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,13 +417,18 @@ 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 (() => {
429433
let pluginPodFilePath = path.join(pluginPlatformsFolderPath, "Podfile");
430434
if(this.$fs.exists(pluginPodFilePath).wait()) {
@@ -436,6 +440,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
436440
let contentToWrite = this.buildPodfileContent(pluginPodFilePath, pluginPodFileContent);
437441
this.$fs.appendFile(this.projectPodFilePath, contentToWrite).wait();
438442
}
443+
444+
if(opts && opts.executePodInstall && this.$fs.exists(pluginPodFilePath).wait()) {
445+
this.executePodInstall().wait();
446+
}
439447
}).future<void>()();
440448
}
441449

lib/services/plugins-service.ts

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

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

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

0 commit comments

Comments
 (0)