truebit / xUnique

merge Xcode project file is so easy
https://fclef.wordpress.com
Other
1.5k stars 120 forks source link

Handling missing files on PBXVariantGroup #13

Closed pbartolome closed 10 years ago

pbartolome commented 10 years ago

I found out that my project file had some references to old files on the PBXVariantGroup. Those files are not in the project anymore. The script is removing the ID and file name instead of leaving or removing the whole entry. The output is a corrupted project that xcode is unable to open

Original:

/* Begin PBXVariantGroup section */
        92F3CD7618DC7D9E004F2CC6 /* InfoPlist.strings */ = {
            isa = PBXVariantGroup;
            children = (
                92F3CD7718DC7D9E004F2CC6 /* en */,
            );
            name = InfoPlist.strings;
            sourceTree = "<group>";
        };
        92F3CD7F18DC7D9E004F2CC6 /* Main_iPhone.storyboard */ = {
            isa = PBXVariantGroup;
            children = (
                92F3CD8018DC7D9E004F2CC6 /* Base */,
            );
            name = Main_iPhone.storyboard;
            sourceTree = "<group>";
        };
        92F3CD8218DC7D9E004F2CC6 /* Main_iPad.storyboard */ = {
            isa = PBXVariantGroup;
            children = (
                92F3CD8318DC7D9E004F2CC6 /* Base */,
            );
            name = Main_iPad.storyboard;
            sourceTree = "<group>";
        };
/* End PBXVariantGroup section */

Script Output:

/* Begin PBXVariantGroup section */
            isa = PBXVariantGroup;
            children = (
            );
            name = InfoPlist.strings;
            sourceTree = "<group>";
        };
            isa = PBXVariantGroup;
            children = (
            );
            name = Main_iPhone.storyboard;
            sourceTree = "<group>";
        };
            isa = PBXVariantGroup;
            children = (
            );
            name = Main_iPad.storyboard;
            sourceTree = "<group>";
        };
/* End PBXVariantGroup section */
truebit commented 10 years ago

This is expected in the design. As I do not know how to convert back from json to binary format (a.k.a the format you posted ) of the project file, the script just scan the binary format file line to line to do the replacement and delete operation.So that's the result you got. Adding the support to the entire section in binary format is too complicated, and I have no plans for the moment.

But why the entire group is not deleted by Xcode if they do not exist any more? PBXVariantGroup describes a group of files that act like one. How would it exist without any contents inside?

pbartolome commented 10 years ago

I don't know why xcode is not deleting those files, but InfoPlist.strings, Main_iPhone.storyboard and Main_iPad.storyboard are not there anymore on the project. I tried deleting manually the whole section, the project works fine as well as the script.

I was using on the project for the first time the options xUnique.py -s -p -u. On this case, If it's going line by line to modify or delete, probably it will need to delete the whole multi line entry

        92F3CD8218DC7D9E004F2CC6 /* Main_iPad.storyboard */ = {
            isa = PBXVariantGroup;
            children = (
                92F3CD8318DC7D9E004F2CC6 /* Base */,
            );
            name = Main_iPad.storyboard;
            sourceTree = "<group>";
        };

Instead of just removing one line with an opening bracket XXXX /* entry */ = { and not removing the rest of the entry up to the closing bracket };

            isa = PBXVariantGroup;
            children = (
            );
            name = Main_iPad.storyboard;
            sourceTree = "<group>";
        };

I know that this will probably require parsing the binary, and maybe a huge effort, on this case I was expecting a warning, the whole entry deleted or the entry left untouched. Just a suggestion, but anyway, the script is really good! great job.

truebit commented 10 years ago

OK,I will add messages when removing lines in normal mode.

— Sent from my mobile phone

On Sat, Oct 18, 2014 at 12:54 AM, Pablo Bartolome notifications@github.com wrote:

I don't know why xcode is not deleting those files, but InfoPlist.strings, Main_iPhone.storyboard and Main_iPad.storyboard are not there anymore on the project. I tried deleting manually the whole section, the project works fine as well as the script. I was using on the project for the first time the options xUnique.py -s -p -u. On this case, If it's going line by line to modify or delete, probably it will need to delete the whole multi line entry

        92F3CD8218DC7D9E004F2CC6 /* Main_iPad.storyboard */ = {
            isa = PBXVariantGroup;
            children = (
                92F3CD8318DC7D9E004F2CC6 /* Base */,
            );
            name = Main_iPad.storyboard;
            sourceTree = "<group>";
        };

Instead of just removing one line with an opening bracket XXXX /* entry */ = { and not removing the rest of the entry up to the closing bracket };

            isa = PBXVariantGroup;
            children = (
            );
            name = Main_iPad.storyboard;
            sourceTree = "<group>";
        };

I know that this will probably require parsing the binary, and maybe a huge effort, on this case I was expecting a warning, the whole entry deleted or the entry left untouched. Just a suggestion, but anyway, the script is really good! great job.

Reply to this email directly or view it on GitHub: https://github.com/truebit/xUnique/issues/13#issuecomment-59542255