Skip to content

Commit d23f7bf

Browse files
committed
fix: execute pod install and merge of pod's xcconfig file in the correct order
1 parent ce33b5f commit d23f7bf

9 files changed

+168
-108
lines changed

lib/bootstrap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $injector.require("androidPluginBuildService", "./services/android-plugin-build-
1515
$injector.require("iOSEntitlementsService", "./services/ios-entitlements-service");
1616
$injector.require("iOSProjectService", "./services/ios-project-service");
1717
$injector.require("iOSProvisionService", "./services/ios-provision-service");
18-
$injector.require("xCConfigService", "./services/xcconfig-service");
18+
$injector.require("xcconfigService", "./services/xcconfig-service");
1919

2020
$injector.require("cocoapodsService", "./services/cocoapods-service");
2121

lib/declarations.d.ts

+38
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,13 @@ interface IVerifyXcprojOptions {
844844
* Designed for getting information about xcproj.
845845
*/
846846
interface IXcprojService {
847+
/**
848+
* Returns the path to the xcodeproj file
849+
* @param projectData Information about the project.
850+
* @param platformData Information about the platform.
851+
* @return {string} The full path to the xcodeproj
852+
*/
853+
getXcodeprojPath(projectData: IProjectData, platformData: IPlatformData): string;
847854
/**
848855
* Checks whether the system needs xcproj to execute ios builds successfully.
849856
* In case the system does need xcproj but does not have it, prints an error message.
@@ -856,6 +863,11 @@ interface IXcprojService {
856863
* @return {Promise<XcprojInfo>} collected info about xcproj.
857864
*/
858865
getXcprojInfo(): Promise<IXcprojInfo>;
866+
/**
867+
* Checks if xcproj is available and throws an error in case when it is not available.
868+
* @return {Promise<boolean>}
869+
*/
870+
checkIfXcodeprojIsRequired(): Promise<boolean>;
859871
}
860872

861873
/**
@@ -880,6 +892,32 @@ interface IXcprojInfo {
880892
xcprojAvailable: boolean;
881893
}
882894

895+
interface IXcconfigService {
896+
/**
897+
* Returns the path to the xcconfig file
898+
* @param projectRoot The path to root folder of native project (platforms/ios)
899+
* @param opts
900+
* @returns {string}
901+
*/
902+
getPluginsXcconfigFilePath(projectRoot: string, opts: IRelease): string;
903+
904+
/**
905+
* Returns the value of a property from a xcconfig file.
906+
* @param xcconfigFilePath The path to the xcconfig file
907+
* @param propertyName The name of the property which value will be returned
908+
* @returns {string}
909+
*/
910+
readPropertyValue(xcconfigFilePath: string, propertyName: string): string;
911+
912+
/**
913+
* Merges the content of source file into destination file
914+
* @param sourceFile The content of thes source file
915+
* @param destinationFile The content of the destination file
916+
* @returns {Promise<void>}
917+
*/
918+
mergeFiles(sourceFile: string, destinationFile: string): Promise<void>;
919+
}
920+
883921
/**
884922
* Describes helper used during execution of deploy commands.
885923
*/

lib/definitions/project.d.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectS
402402

403403
beforePrepareAllPlugins(projectData: IProjectData, dependencies?: IDependencyData[]): Promise<void>;
404404

405-
handleNativeDependenciesChange(projectData: IProjectData): Promise<void>;
405+
handleNativeDependenciesChange(projectData: IProjectData, opts: IRelease): Promise<void>;
406406

407407
/**
408408
* Gets the path wheren App_Resources should be copied.
@@ -484,6 +484,14 @@ interface ICocoaPodsService {
484484
*/
485485
getPodfileFooter(): string;
486486

487+
/**
488+
* Merges the Podfile's content from App_Resources in the project's Podfile.
489+
* @param projectData Information about the project.
490+
* @param platformData Information about the platform.
491+
* @returns {Promise<void>}
492+
*/
493+
applyPodfileFromAppResources(projectData: IProjectData, platformData: IPlatformData): Promise<void>;
494+
487495
/**
488496
* Prepares the Podfile content of a plugin and merges it in the project's Podfile.
489497
* @param {string} moduleName The module which the Podfile is from.
@@ -525,6 +533,14 @@ interface ICocoaPodsService {
525533
* @returns {Promise<ISpawnResult>} Information about the spawned process.
526534
*/
527535
executePodInstall(projectRoot: string, xcodeProjPath: string): Promise<ISpawnResult>;
536+
537+
/**
538+
* Merges pod's xcconfig file into project's xcconfig file
539+
* @param projectData
540+
* @param platformData
541+
* @param opts
542+
*/
543+
mergePodXcconfigFile(projectData: IProjectData, platformData: IPlatformData, opts: IRelease): Promise<void>;
528544
}
529545

530546
interface IRubyFunction {

lib/services/android-project-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
605605
}
606606
}
607607

608-
public async handleNativeDependenciesChange(projectData: IProjectData): Promise<void> {
608+
public async handleNativeDependenciesChange(projectData: IProjectData, opts: IRelease): Promise<void> {
609609
return;
610610
}
611611

lib/services/cocoapods-service.ts

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EOL } from "os";
22
import * as path from "path";
3-
import { PluginNativeDirNames, PODFILE_NAME } from "../constants";
3+
import { PluginNativeDirNames, PODFILE_NAME, NS_BASE_PODFILE } from "../constants";
44

55
export class CocoaPodsService implements ICocoaPodsService {
66
private static PODFILE_POST_INSTALL_SECTION_NAME = "post_install";
@@ -11,7 +11,8 @@ export class CocoaPodsService implements ICocoaPodsService {
1111
private $errors: IErrors,
1212
private $xcprojService: IXcprojService,
1313
private $logger: ILogger,
14-
private $config: IConfiguration) { }
14+
private $config: IConfiguration,
15+
private $xcconfigService: IXcconfigService) { }
1516

1617
public getPodfileHeader(targetName: string): string {
1718
return `use_frameworks!${EOL}${EOL}target "${targetName}" do${EOL}`;
@@ -52,6 +53,26 @@ export class CocoaPodsService implements ICocoaPodsService {
5253
return podInstallResult;
5354
}
5455

56+
public async mergePodXcconfigFile(projectData: IProjectData, platformData: IPlatformData, opts: IRelease) {
57+
const podFilesRootDirName = path.join("Pods", "Target Support Files", `Pods-${projectData.projectName}`);
58+
const podFolder = path.join(platformData.projectRoot, podFilesRootDirName);
59+
if (this.$fs.exists(podFolder)) {
60+
const podXcconfigFilePath = opts && opts.release ? path.join(podFolder, `Pods-${projectData.projectName}.release.xcconfig`)
61+
: path.join(podFolder, `Pods-${projectData.projectName}.debug.xcconfig`);
62+
const pluginsXcconfigFilePath = this.$xcconfigService.getPluginsXcconfigFilePath(platformData.projectRoot, opts);
63+
await this.$xcconfigService.mergeFiles(podXcconfigFilePath, pluginsXcconfigFilePath);
64+
}
65+
}
66+
67+
public async applyPodfileFromAppResources(projectData: IProjectData, platformData: IPlatformData): Promise<void> {
68+
const { projectRoot, normalizedPlatformName } = platformData;
69+
const mainPodfilePath = path.join(projectData.appResourcesDirectoryPath, normalizedPlatformName, PODFILE_NAME);
70+
const projectPodfilePath = this.getProjectPodfilePath(projectRoot);
71+
if (this.$fs.exists(projectPodfilePath) || this.$fs.exists(mainPodfilePath)) {
72+
await this.applyPodfileToProject(NS_BASE_PODFILE, mainPodfilePath, projectData, projectRoot);
73+
}
74+
}
75+
5576
public async applyPodfileToProject(moduleName: string, podfilePath: string, projectData: IProjectData, nativeProjectPath: string): Promise<void> {
5677
if (!this.$fs.exists(podfilePath)) {
5778
this.removePodfileFromProject(moduleName, podfilePath, projectData, nativeProjectPath);

0 commit comments

Comments
 (0)