1
1
import { EOL } from "os" ;
2
2
import * as path from "path" ;
3
- import { PluginNativeDirNames , PODFILE_NAME } from "../constants" ;
3
+ import { PluginNativeDirNames , PODFILE_NAME , NS_BASE_PODFILE } from "../constants" ;
4
4
5
5
export class CocoaPodsService implements ICocoaPodsService {
6
6
private static PODFILE_POST_INSTALL_SECTION_NAME = "post_install" ;
@@ -11,7 +11,8 @@ export class CocoaPodsService implements ICocoaPodsService {
11
11
private $errors : IErrors ,
12
12
private $xcprojService : IXcprojService ,
13
13
private $logger : ILogger ,
14
- private $config : IConfiguration ) { }
14
+ private $config : IConfiguration ,
15
+ private $xcconfigService : IXcconfigService ) { }
15
16
16
17
public getPodfileHeader ( targetName : string ) : string {
17
18
return `use_frameworks!${ EOL } ${ EOL } target "${ targetName } " do${ EOL } ` ;
@@ -52,6 +53,26 @@ export class CocoaPodsService implements ICocoaPodsService {
52
53
return podInstallResult ;
53
54
}
54
55
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
+
55
76
public async applyPodfileToProject ( moduleName : string , podfilePath : string , projectData : IProjectData , nativeProjectPath : string ) : Promise < void > {
56
77
if ( ! this . $fs . exists ( podfilePath ) ) {
57
78
this . removePodfileFromProject ( moduleName , podfilePath , projectData , nativeProjectPath ) ;
0 commit comments