cordova-node-xcode icon indicating copy to clipboard operation
cordova-node-xcode copied to clipboard

[Question] How to add file to PBXNativeTarget

Open JulianKingman opened this issue 7 years ago • 3 comments

I'm trying to add a file (GoogleServices-Info.plist) to my main project folder, but can't figure out what function to use. I've tried every one, and the best I can do is get it into my Plugins folder. Anyone know?

I thought these might work, but they didn't:

project.addToPbxGroupType(file, targetKey, 'PBXNativeTarget');
project.addToPbxFileReferenceSection(file);

// this one gives an error; sources is undefined
project.addToPbxCopyfilesBuildPhase(file);

JulianKingman avatar Dec 04 '18 18:12 JulianKingman

@jukka You mean like this?

bildschirmfoto 2018-12-09 um 21 53 33
  const groupName = 'RNCameraExample';
  const [hash] = Object.entries(project.hash.project.objects['PBXGroup']).find(
    ([, group]) => group.name === groupName,
  );
  project.addFile('RNCameraExample/Foo.plist', hash, {});

n1ru4l avatar Dec 09 '18 20:12 n1ru4l

Can you post your full script? I want to achieve the same thing but the file gets copied only to the root folder of my project.

Nikostito avatar Jan 15 '21 16:01 Nikostito

Any idea if is possible to do this?

gusgard avatar Apr 20 '23 19:04 gusgard