Hi All,
I have a requirement for my App to support English and French. We have an automated build process that I must follow. My problem is that I have to add the localization files to the XCode project when I add the platform. I want to copy the new files in the configure the XCode project using a Cordova hook.
Using https://github.com/alunny/node-xcode
Problem is that the NodeJS xcode project does not add the proper group for this. It should look like this in
/* Begin PBXVariantGroup section /
431B8CD01B77C6EC00AFEDAE / InfoPlist.strings / = {
isa = PBXVariantGroup;
children = (
431B8CCF1B77C6EC00AFEDAE / en /,
431B8CD11B77C6EE00AFEDAE / fr /,
);
name = InfoPlist.strings;
sourceTree = “”;
};
/ End PBXVariantGroup section */
I added a method to XCode NodeJS called:
pbxProject.prototype.addPbxVariantGroup = function (filePathsArray, name, path, sourceTree) {
console.log('addPbxVariantGroup');
var groups = this.hash.project.objects['PBXGroup'],
pbxGroupUuid = this.generateUuid(),
commentKey = f("%s_comment", pbxGroupUuid),
pbxGroup = {
isa: 'PBXVariantGroup',
children: [],
name: name,
//path: path,
sourceTree: sourceTree ? sourceTree : '"<group>"'
},
fileReferenceSection = this.pbxFileReferenceSection(),
filePathToReference = {};
console.log(groups);
/*for (var key in fileReferenceSection) {
// only look for comments
if (!COMMENT_KEY.test(key)) continue;
var fileReferenceKey = key.split(COMMENT_KEY)[0],
fileReference = fileReferenceSection[fileReferenceKey];
filePathToReference[fileReference.path] = {fileRef: fileReferenceKey, basename: fileReferenceSection[key]};
}*/
for (var index = 0; index < filePathsArray.length; index++) {
var filePath = filePathsArray[index],
filePathQuoted = "\"" + filePath + "\"";
if (filePathToReference[filePath]) {
pbxGroup.children.push(pbxGroupChild(filePathToReference[filePath]));
continue;
} else if (filePathToReference[filePathQuoted]) {
pbxGroup.children.push(pbxGroupChild(filePathToReference[filePathQuoted]));
continue;
}
var file = new pbxFile(filePath);
file.uuid = this.generateUuid();
file.fileRef = this.generateUuid();
this.addToPbxFileReferenceSection(file); // PBXFileReference
//this.addToPbxBuildFileSection(file); // PBXBuildFile
pbxGroup.children.push(pbxGroupChild(file));
}
if (groups) {
console.log('Adding Groups...')
groups[pbxGroupUuid] = pbxGroup;
groups[commentKey] = name;
}
return {uuid: pbxGroupUuid, pbxGroup: pbxGroup};
}
But it does not add it. The group I need does not exist, therefore it does not add it.
Maybe I am overthinking this or missed an easier way to do this. Anyone have a way to add a hook that lets the App Name be displayed in the language of the device???
Thanks,
Chris