Skip to content

Commit e9d98ee

Browse files
author
Fatme
authored
Merge pull request #4299 from NativeScript/fatme/pod-tehnical-dept
chore: remove installPods property from platform's project interface
2 parents 4b9f1a3 + 4339a98 commit e9d98ee

17 files changed

+257
-159
lines changed

lib/bootstrap.ts

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

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

lib/declarations.d.ts

+38
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,13 @@ interface IVerifyXcprojOptions {
840840
* Designed for getting information about xcproj.
841841
*/
842842
interface IXcprojService {
843+
/**
844+
* Returns the path to the xcodeproj file
845+
* @param projectData Information about the project.
846+
* @param platformData Information about the platform.
847+
* @return {string} The full path to the xcodeproj
848+
*/
849+
getXcodeprojPath(projectData: IProjectData, platformData: IPlatformData): string;
843850
/**
844851
* Checks whether the system needs xcproj to execute ios builds successfully.
845852
* In case the system does need xcproj but does not have it, prints an error message.
@@ -852,6 +859,11 @@ interface IXcprojService {
852859
* @return {Promise<XcprojInfo>} collected info about xcproj.
853860
*/
854861
getXcprojInfo(): Promise<IXcprojInfo>;
862+
/**
863+
* Checks if xcproj is available and throws an error in case when it is not available.
864+
* @return {Promise<boolean>}
865+
*/
866+
checkIfXcodeprojIsRequired(): Promise<boolean>;
855867
}
856868

857869
/**
@@ -876,6 +888,32 @@ interface IXcprojInfo {
876888
xcprojAvailable: boolean;
877889
}
878890

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

lib/definitions/project.d.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,18 @@ interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectS
400400
*/
401401
removePluginNativeCode(pluginData: IPluginData, projectData: IProjectData): Promise<void>;
402402

403-
afterPrepareAllPlugins(projectData: IProjectData): Promise<void>;
404403
beforePrepareAllPlugins(projectData: IProjectData, dependencies?: IDependencyData[]): Promise<void>;
405404

405+
handleNativeDependenciesChange(projectData: IProjectData, opts: IRelease): Promise<void>;
406+
406407
/**
407408
* Gets the path wheren App_Resources should be copied.
408409
* @returns {string} Path to native project, where App_Resources should be copied.
409410
*/
410411
getAppResourcesDestinationDirectoryPath(projectData: IProjectData): string;
411412

412413
cleanDeviceTempFolder(deviceIdentifier: string, projectData: IProjectData): Promise<void>;
413-
processConfigurationFilesFromAppResources(projectData: IProjectData, opts: { release: boolean, installPods: boolean }): Promise<void>;
414+
processConfigurationFilesFromAppResources(projectData: IProjectData, opts: { release: boolean }): Promise<void>;
414415

415416
/**
416417
* Ensures there is configuration file (AndroidManifest.xml, Info.plist) in app/App_Resources.
@@ -482,6 +483,14 @@ interface ICocoaPodsService {
482483
*/
483484
getPodfileFooter(): string;
484485

486+
/**
487+
* Merges the Podfile's content from App_Resources in the project's Podfile.
488+
* @param projectData Information about the project.
489+
* @param platformData Information about the platform.
490+
* @returns {Promise<void>}
491+
*/
492+
applyPodfileFromAppResources(projectData: IProjectData, platformData: IPlatformData): Promise<void>;
493+
485494
/**
486495
* Prepares the Podfile content of a plugin and merges it in the project's Podfile.
487496
* @param {string} moduleName The module which the Podfile is from.
@@ -523,6 +532,14 @@ interface ICocoaPodsService {
523532
* @returns {Promise<ISpawnResult>} Information about the spawned process.
524533
*/
525534
executePodInstall(projectRoot: string, xcodeProjPath: string): Promise<ISpawnResult>;
535+
536+
/**
537+
* Merges pod's xcconfig file into project's xcconfig file
538+
* @param projectData
539+
* @param platformData
540+
* @param opts
541+
*/
542+
mergePodXcconfigFile(projectData: IProjectData, platformData: IPlatformData, opts: IRelease): Promise<void>;
526543
}
527544

528545
interface IRubyFunction {

lib/services/android-project-service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
577577
}
578578
}
579579

580-
public async afterPrepareAllPlugins(projectData: IProjectData): Promise<void> {
581-
return;
582-
}
583-
584580
public async beforePrepareAllPlugins(projectData: IProjectData, dependencies?: IDependencyData[]): Promise<void> {
585581
const shouldUseNewRoutine = this.runtimeVersionIsGreaterThanOrEquals(projectData, "3.3.0");
586582

@@ -609,6 +605,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
609605
}
610606
}
611607

608+
public async handleNativeDependenciesChange(projectData: IProjectData, opts: IRelease): Promise<void> {
609+
return;
610+
}
611+
612612
private filterUniqueDependencies(dependencies: IDependencyData[]): IDependencyData[] {
613613
const depsDictionary = dependencies.reduce((dict, dep) => {
614614
const collision = dict[dep.name];

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)