1
1
import path from 'path' ;
2
- import { getConfigProp , fsWriteFileSync , getAppFolder , doResolve , logError } from '@rnv/core' ;
2
+ import { getConfigProp , fsWriteFileSync , getAppFolder , doResolve , logError , fsExistsSync } from '@rnv/core' ;
3
3
import { getAppFolderName } from './common' ;
4
4
5
5
export const parsePrivacyManifest = ( ) => {
@@ -27,7 +27,7 @@ export const parsePrivacyManifest = () => {
27
27
return `<string>${ reason } </string>` ;
28
28
} ) . join ( '\n' ) }
29
29
</array>
30
- <dict>
30
+ </ dict>
31
31
` ;
32
32
} )
33
33
. join ( '' ) }
@@ -39,25 +39,34 @@ export const parsePrivacyManifest = () => {
39
39
const appFolder = getAppFolder ( ) ;
40
40
const appFolderName = getAppFolderName ( ) ;
41
41
42
- const filePath = path . join ( appFolder , ` ${ appFolderName } / PrivacyInfo.xcprivacy` ) ;
43
- fsWriteFileSync ( filePath , output ) ;
42
+ const primaryPath = path . join ( appFolder , ' PrivacyInfo.xcprivacy' ) ;
43
+ const secondaryPath = path . join ( appFolder , ` ${ appFolderName } /PrivacyInfo.xcprivacy` ) ;
44
44
45
- const xcodePath = doResolve ( 'xcode' ) ;
46
- if ( ! xcodePath ) {
47
- logError ( `Cannot resolve xcode path` ) ;
45
+ if ( fsExistsSync ( primaryPath ) || fsExistsSync ( secondaryPath ) ) {
46
+ const existingFilePath = fsExistsSync ( primaryPath ) ? primaryPath : secondaryPath ;
47
+ fsWriteFileSync ( existingFilePath , output ) ;
48
48
resolve ( ) ;
49
- return ;
50
- }
49
+ } else {
50
+ const filePath = secondaryPath ;
51
+ fsWriteFileSync ( filePath , output ) ;
51
52
52
- const xcode = require ( xcodePath ) ;
53
- const projectPath = path . join ( appFolder , `${ appFolderName } .xcodeproj/project.pbxproj` ) ;
54
- const xcodeProj = xcode . project ( projectPath ) ;
53
+ const xcodePath = doResolve ( 'xcode' ) ;
54
+ if ( ! xcodePath ) {
55
+ logError ( `Cannot resolve xcode path` ) ;
56
+ resolve ( ) ;
57
+ return ;
58
+ }
55
59
56
- xcodeProj . parse ( ( ) => {
57
- xcodeProj . addResourceFile ( filePath ) ;
58
- fsWriteFileSync ( projectPath , xcodeProj . writeSync ( ) ) ;
59
- resolve ( ) ;
60
- } ) ;
60
+ const xcode = require ( xcodePath ) ;
61
+ const projectPath = path . join ( appFolder , `${ appFolderName } .xcodeproj/project.pbxproj` ) ;
62
+ const xcodeProj = xcode . project ( projectPath ) ;
63
+
64
+ xcodeProj . parse ( ( ) => {
65
+ xcodeProj . addResourceFile ( filePath ) ;
66
+ fsWriteFileSync ( projectPath , xcodeProj . writeSync ( ) ) ;
67
+ resolve ( ) ;
68
+ } ) ;
69
+ }
61
70
} else {
62
71
resolve ( ) ;
63
72
}
0 commit comments