truebit / xUnique

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

It doesn't sort PBXGroup section some times #17

Open edhub opened 9 years ago

edhub commented 9 years ago

When I use it for our project, I noticed that, it doesn't sort PBXGroup until I change something in the project file (for example, add a empty group). Otherwise, it works great so far. It happens when we first apply it for our project. I'm not sure whether it'll happen in the future.

truebit commented 9 years ago

could you please provide the diff project.pbxproj before and after adding the empty group?

— Sent from my mobile phone

On Thu, Feb 12, 2015 at 11:16 AM, edhub notifications@github.com wrote:

When I use it for our project, I noticed that, it doesn't sort PBXGroup until I change something in the project file (for example, add a empty group). Otherwise, it works great so far. It happens when we first apply it for our project. I'm not sure whether it'll happen in the future.

Reply to this email directly or view it on GitHub: https://github.com/truebit/xUnique/issues/17

edhub commented 9 years ago

it's a business project so I couldn't do that. But once i got some time (not sure when), I can look into it.

edhub commented 9 years ago

but I did manage to find a exercise project file with PBXGroup section not sorted correctly. It doesn't support file uploading, so I just copy & paste the PBXGroup part. If you need the whole project file, please let me know how can I send it to you.

check this line: FE01095F654E29E4669FD59051BF4A79

/* Begin PBXGroup section / 1C8BAAD40D3B5F927C6DC0A762A820BF / Supporting Files / = { isa = PBXGroup; children = ( 7AB7B18155E2D756C57AD67E3DE5D5A7 / Info.plist /, EBF0396F918D5ED54FC59C803080400E / main.m /, ); name = "Supporting Files"; sourceTree = ""; }; 304EE41ED71EA2205AC642471F07B575 / vcproject / = { isa = PBXGroup; children = ( 1C8BAAD40D3B5F927C6DC0A762A820BF / Supporting Files /, FE01095F654E29E4669FD59051BF4A79 / login /, B96C9F610970F8CF3E0BCCB41EFA9178 / nav xibs /, 55F65BF1DF0D0D51AD7F9D4F02567D55 / AppDelegate.h /, DC5DAD08E08AA82D3CCD97C6C5817593 / AppDelegate.m /, 638BBD9F9483E77C61604E4447BD5B5A / Images.xcassets /, 4545E029013F47D478AD3E2350C7E995 / LaunchScreen.xib /, 04C3104D63060826C7FD07A082CC4887 / Main.storyboard /, 1C0373E446C58D7B88A4E529C2539D8E / ViewController.h /, 7A4E408247BB90D5897E87505A7DFFCD / ViewController.m /, ); path = vcproject; sourceTree = ""; }; 38585E645596D3E1FB84EEC2D5B221CA / vcprojectTests / = { isa = PBXGroup; children = ( 88592D313A25A82215458E7B82554F6C / Supporting Files /, 10D2C4D9F826BFED19FB0F9D5F8F9CE3 / vcprojectTests.m /, ); path = vcprojectTests; sourceTree = ""; }; FE01095F654E29E4669FD59051BF4A79 / login / = { isa = PBXGroup; children = ( E237CB6A3187D7D3F653F196A0A7273F / LoginState.h /, 4155547A3FA1C427FF74C73319C03E99 / LoginState.m /, E2200F9387C7D7E3ACE29F6D9203E909 / LoginViewController.h /, 02CD46DD35B87A9EB159E11E70461E4B / LoginViewController.m /, D0C3E787681A0F13852B7116EB629323 / LoginViewController.xib /, ); path = login; sourceTree = ""; }; 88592D313A25A82215458E7B82554F6C / Supporting Files / = { isa = PBXGroup; children = ( B469DD62CF1BF879F989E91E75D50B69 / Info.plist /, ); name = "Supporting Files"; sourceTree = ""; }; B96C9F610970F8CF3E0BCCB41EFA9178 / nav xibs / = { isa = PBXGroup; children = ( FA256945FD94BCE957FBB8E0A30B289F / Tier1ViewController.h /, 2C3BDEA6335D293232CA22C7A945419A / Tier1ViewController.m /, 18906F410DE23C9449BA7597CADEDBA9 / Tier1ViewController.xib /, 5DD643C87B7B22E2F2864AB2780E265F / Tier2ViewController.h /, A5AC728535B19B3281D3BBA6684670D2 / Tier2ViewController.m /, 21BB40856DE6B55A58E1BBBB34C69944 / Tier2ViewController.xib /, DE933B89FE2D233DF042643A507567F3 / Tier3ViewController.h /, 8FBA5805AB7DD519CC775079CB7066C3 / Tier3ViewController.m /, 081B1E64EB95AC7FDD3EC5EB9114CB16 / Tier3ViewController.xib /, ); path = "nav xibs"; sourceTree = ""; }; D640E569C0F0419DD5B042F6FE2C45CE / Products / = { isa = PBXGroup; children = ( F1CBBCD2C102E1D4A6C3DC4DF69C68FC / vcproject.app /, 04F573292FD3F4F4296248E759FE90EC / vcprojectTests.xctest /, ); name = Products; sourceTree = ""; }; E5EF063CFBDB072E436C9F57DCD4EA35 = { isa = PBXGroup; children = ( D640E569C0F0419DD5B042F6FE2C45CE / Products /, 304EE41ED71EA2205AC642471F07B575 / vcproject /, 38585E645596D3E1FB84EEC2D5B221CA / vcprojectTests /, CC39A572ED7657CE5B27C217660E91A0 / MainTabs.storyboard /, ); sourceTree = ""; }; / End PBXGroup section */

truebit commented 9 years ago

Hi, Could you send the problematic original project file via replying github notification email? Thanks

edhub commented 9 years ago

here it is.

On Sat, Feb 14, 2015 at 11:26 AM, Sean Wang notifications@github.com wrote:

Hi, Could you send the problematic original project file via replying github notification email? Thanks

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

edhub commented 9 years ago

i've replied the email with the file as attachment, but I didn't see it in the web page.

truebit commented 9 years ago

It should not display on web page. But I also did not see it in email. Did you " reply all"?

— Sent from my mobile phone

On Sun, Feb 15, 2015 at 10:32 AM, edhub notifications@github.com wrote:

i've replied the email with the file as attachment, but I didn't see it in the web page.

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

edhub commented 9 years ago

this time i reply all. Hope it's ok now.

On Sun, Feb 15, 2015 at 10:34 AM, Sean Wang notifications@github.com wrote:

It should not display on web page. But I also did not see it in email. Did you " reply all"?

— Sent from my mobile phone

On Sun, Feb 15, 2015 at 10:32 AM, edhub notifications@github.com wrote:

i've replied the email with the file as attachment, but I didn't see it

in the web page.

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

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

truebit commented 9 years ago

Still not got it... Could you put the project file content on somewhere public? Thanks a lot.

edhub commented 9 years ago

I've uploaded the project to git hub :) https://github.com/edhub/vcproject

truebit commented 9 years ago

@edhub Thanks a lot:) But I found the project file has already been uniquified and sorted? Could you push the problematic one?

edhub commented 9 years ago

please checkout haha branch. and it's not sorted well at this line:

B96C9F610970F8CF3E0BCCB41EFA9178 /* nav xibs */ = {

/* Begin PBXGroup section / 1C8BAAD40D3B5F927C6DC0A762A820BF / Supporting Files / = { isa = PBXGroup; children = ( 7AB7B18155E2D756C57AD67E3DE5D5A7 / Info.plist /, EBF0396F918D5ED54FC59C803080400E / main.m /, ); name = "Supporting Files"; sourceTree = ""; }; 304EE41ED71EA2205AC642471F07B575 / vcproject / = { isa = PBXGroup; children = ( 1C8BAAD40D3B5F927C6DC0A762A820BF / Supporting Files /, B96C9F610970F8CF3E0BCCB41EFA9178 / nav xibs /, 55F65BF1DF0D0D51AD7F9D4F02567D55 / AppDelegate.h /, DC5DAD08E08AA82D3CCD97C6C5817593 / AppDelegate.m /, 638BBD9F9483E77C61604E4447BD5B5A / Images.xcassets /, 4545E029013F47D478AD3E2350C7E995 / LaunchScreen.xib /, 04C3104D63060826C7FD07A082CC4887 / Main.storyboard /, 1C0373E446C58D7B88A4E529C2539D8E / ViewController.h /, 7A4E408247BB90D5897E87505A7DFFCD / ViewController.m /, ); path = vcproject; sourceTree = ""; }; 38585E645596D3E1FB84EEC2D5B221CA / vcprojectTests / = { isa = PBXGroup; children = ( 88592D313A25A82215458E7B82554F6C / Supporting Files /, 10D2C4D9F826BFED19FB0F9D5F8F9CE3 / vcprojectTests.m /, ); path = vcprojectTests; sourceTree = ""; }; B96C9F610970F8CF3E0BCCB41EFA9178 / nav xibs / = { isa = PBXGroup; children = ( FA256945FD94BCE957FBB8E0A30B289F / Tier1ViewController.h /, 2C3BDEA6335D293232CA22C7A945419A / Tier1ViewController.m /, 18906F410DE23C9449BA7597CADEDBA9 / Tier1ViewController.xib /, 5DD643C87B7B22E2F2864AB2780E265F / Tier2ViewController.h /, A5AC728535B19B3281D3BBA6684670D2 / Tier2ViewController.m /, 21BB40856DE6B55A58E1BBBB34C69944 / Tier2ViewController.xib /, DE933B89FE2D233DF042643A507567F3 / Tier3ViewController.h /, 8FBA5805AB7DD519CC775079CB7066C3 / Tier3ViewController.m /, 081B1E64EB95AC7FDD3EC5EB9114CB16 / Tier3ViewController.xib /, ); path = "nav xibs"; sourceTree = ""; }; 88592D313A25A82215458E7B82554F6C / Supporting Files / = { isa = PBXGroup; children = ( B469DD62CF1BF879F989E91E75D50B69 / Info.plist /, ); name = "Supporting Files"; sourceTree = ""; }; D640E569C0F0419DD5B042F6FE2C45CE / Products / = { isa = PBXGroup; children = ( F1CBBCD2C102E1D4A6C3DC4DF69C68FC / vcproject.app /, 04F573292FD3F4F4296248E759FE90EC / vcprojectTests.xctest /, ); name = Products; sourceTree = ""; }; E5EF063CFBDB072E436C9F57DCD4EA35 = { isa = PBXGroup; children = ( D640E569C0F0419DD5B042F6FE2C45CE / Products /, 304EE41ED71EA2205AC642471F07B575 / vcproject /, 38585E645596D3E1FB84EEC2D5B221CA / vcprojectTests /, CC39A572ED7657CE5B27C217660E91A0 / MainTabs.storyboard /, ); sourceTree = ""; };/ End PBXGroup section */

On Wed, Feb 25, 2015 at 11:47 PM, Sean Wang notifications@github.com wrote:

@edhub https://github.com/edhub Thanks a lot:) But I found the project file has already been uniquified and sorted? Could you push the problematic one?

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

truebit commented 9 years ago

I still not understand, there's only a haha branch in the project file, and I used that one. concerning "it's not sorted well", could you explain more?

Do you mean that it is not sorted by lower letters? That's the default action of str.sort in Python. I did not change it. And I also added a rule that placing folders ( without . in name) before any files. If that's not you mean, I will reopen this issue.

BTW, to save both our time, you should just say what's the issue. just saying "not sort well" and pasting the long content is too confused...

edhub commented 9 years ago

sorry, i replied it in email, and the result is a mess. Here, take a look at current orders in PBXGroup: 1C8BAAD40D3B5F927C6DC0A762A820BF /* Supporting Files / 304EE41ED71EA2205AC642471F07B575 / vcproject / 38585E645596D3E1FB84EEC2D5B221CA / vcprojectTests -> B96C9F610970F8CF3E0BCCB41EFA9178 /* nav xibs / 88592D313A25A82215458E7B82554F6C / Supporting / D640E569C0F0419DD5B042F6FE2C45CE / Products */ E5EF063CFBDB072E436C9F57DCD4EA35 = {

shouldn't it be: 1C8BAAD40D3B5F927C6DC0A762A820BF /* Supporting Files / 304EE41ED71EA2205AC642471F07B575 / vcproject / 38585E645596D3E1FB84EEC2D5B221CA / vcprojectTests 88592D313A25A82215458E7B82554F6C /* Supporting / ->B96C9F610970F8CF3E0BCCB41EFA9178 / nav xibs / D640E569C0F0419DD5B042F6FE2C45CE / Products */ E5EF063CFBDB072E436C9F57DCD4EA35 = {

truebit commented 9 years ago

Still cannot understand what you say. The vcproject PBXGroup is already in that order, see line 93

edhub commented 9 years ago

please check line 114 https://github.com/edhub/vcproject/blob/haha/vcproject.xcodeproj/project.pbxproj#L114. If you still don't think it's a problem, please just close the issue. thanks

On Sat, Feb 28, 2015 at 12:27 PM, Sean Wang notifications@github.com wrote:

Still cannot understand what you say. The vcproject PBXGroup is already in that order, see line 93 https://github.com/edhub/vcproject/blob/haha/vcproject.xcodeproj/project.pbxproj#L93

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

truebit commented 9 years ago

You mean the whole PBXGroup section order in project file? I did not sort that, I just sort the parts which it will affect what it looks in xcode, e.g. children and files

edhub commented 9 years ago

Yes, I mean the order of group section. I concern about it, because it's important: If the order is not consistent, horrible project file conflict of will happen between merges.

Then why it get sorted sometimes? Is the sort done by Xcode? Maybe Xcode will sort it according to your sort results. I made some test, and confirmed it's Xcode made the sorting. It'll sort the group section when you updated something in the project (add/remove a group/file, etc).

So, in order to keep the order consistent, I should add a empty group, run xUnique, remove the group. Anyway, the issue is addressed and I found a solution to it. Or maybe you are interested in making the sort in xUnique, later :)

Thanks for the help, and the tool, of cause.

truebit commented 9 years ago

There is very huge work to do if dealing with all types of pbx sections and sub-sections in project file unless someone got a new thought. Currently I have no plans for that.

About the order problem you concerned, in my experience, only if the content of the section is different, it will get conflicts in Git; if the order is different but the content is the same, it should not get conflicts; and that's why I made this tool:)

edhub commented 9 years ago

since Xcode can do the sort trick, maybe you can trigger the feature from xcode when you got plans for it.

On Mon, Mar 2, 2015 at 5:00 PM, Sean Wang notifications@github.com wrote:

There is very huge work to do if dealing with all types of pbx sections and sub-sections in project file unless someone got a new thought. Sorry, currently I have no plans for that.

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

truebit commented 9 years ago

xUnique is just a simple pure python script, trigger from Xcode is not elegant and will be very complex imho.

ou2s commented 8 years ago

Hello, just wanted to confirm that the fact that PBXGroup sections are not ordered makes xUnique unable to resolve my merge conflicts.

Anyway, thanks for the work!

truebit commented 8 years ago

Sorry the inconvenience. Maybe you could run in Xcode before committing the project file? According to the discussion above, this would trigger Xcode sorting PBXGroup.

ou2s commented 8 years ago

XCode did not sort the PBXGroup section... However I managed to find a script that does the job: https://github.com/neciu/SOCK

xUnique + SOCK = perfectly sorted my pbxproj :)

truebit commented 8 years ago

So you mean sorting the items under pbxgroup instead of pbxgroup themselves? If so, I could add that :)

— Sent from my mobile phone

On Sat, Jan 23, 2016 at 2:07 AM, Ouss Ghalbz notifications@github.com wrote:

XCode did not sort the PBXGroup section... However I managed to find a script that does the job: https://github.com/neciu/SOCK

xUnique + SOCK = perfectly sorted my pbxproj :)

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

ou2s commented 8 years ago

Yes, I meant items them by UUID. And it was not only in pbxgroup section, but in nearly every section.

I had to add more sections into the SOCK script, because it only supported the "critical" ones according to the developer.

It would be a great feature to add to xUnique, because it helps to reduce the number of conflicts.

truebit commented 8 years ago

Could you make a list of these sections? I will look into it.

— Sent from my mobile phone

On Sat, Jan 23, 2016 at 2:24 AM, Ouss Ghalbz notifications@github.com wrote:

Yes, I meant sorting them by UUID. And it was not only in pbxgroup, but in nearly every section. I had to add more sections into the SOCK script, because it only supported the "critical" one from the develop POV.

It would be a great feature to add to xUnique, because it helps to reduce the number of conflicts.

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

ou2s commented 8 years ago

It is every section except PBXBuildFile and PBXFileReference.

PBXBuildFile
PBXFrameworksBuildPhase
PBXGroup
PBXResourcesBuildPhase
PBXSourcesBuildPhase
PBXContainerItemProxy
PBXCopyFilesBuildPhase
PBXShellScriptBuildPhase
PBXNativeTarget
PBXProject
PBXShellScriptBuildPhase
PBXTargetDependency
PBXVariantGroup
XCBuildConfiguration
XCConfigurationList
XCVersionGroup

IMHO, the best sorting method for a .pbxproj file is:

truebit commented 8 years ago

PBXBuildFile and PBXFileReference can be sorted by its names, Actually that's what I did in the beginning, Now you could switch it on by adding -p in command line. I turned it off because Xcode would sort them by UUID, that would cause lots of changes when you commit almost EVERYTIME. It is too annoying.

truebit commented 8 years ago

open this enhancement issue to make me not being lazy..