11import { EOL } from "os" ;
22import * as path from "path" ;
3- import { PluginNativeDirNames , PODFILE_NAME } from "../constants" ;
3+ import { PluginNativeDirNames , PODFILE_NAME , NS_BASE_PODFILE } from "../constants" ;
44
55export 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