File tree Expand file tree Collapse file tree
packages/react-native-legal/bare-plugin/src/ios Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,9 +12,21 @@ export function addSettingsBundle(iosProjectPath: string) {
1212 const projectName = getIOSProjectName ( iosProjectPath ) ;
1313 const { pbxproj, pbxprojPath } = getIOSPbxProj ( iosProjectPath ) ;
1414
15- pbxproj . removeFile ( settingsBundleFilename , pbxproj . findPBXGroupKey ( { name : projectName } ) ) ;
15+ let group : string | undefined = pbxproj . findPBXGroupKey ( { name : projectName } ) ;
1616
17- const settingsBundleFile = pbxproj . addFile ( settingsBundleFilename , pbxproj . findPBXGroupKey ( { name : projectName } ) ) ;
17+ if ( ! group ) {
18+ // https://github.com/callstackincubator/react-native-legal/issues/81
19+ // If the project name is wrapped in quotes inside pbxproj file, let's try to grab it
20+ group = pbxproj . findPBXGroupKey ( { name : `"${ projectName } "` } ) ;
21+ }
22+
23+ if ( ! group ) {
24+ throw new Error ( `Could not find group named: ${ projectName } in the pbxproj` ) ;
25+ }
26+
27+ pbxproj . removeFile ( settingsBundleFilename , group ) ;
28+
29+ const settingsBundleFile = pbxproj . addFile ( settingsBundleFilename , group ) ;
1830
1931 if ( ! settingsBundleFile ) {
2032 throw new Error ( 'Could not add Settings.bundle file reference to xcode project' ) ;
You can’t perform that action at this time.
0 commit comments