xUnique icon indicating copy to clipboard operation
xUnique copied to clipboard

It doesn't sort PBXGroup section some times

Open edhub opened this issue 10 years ago • 30 comments

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.

edhub avatar Feb 12 '15 03:02 edhub

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 [email protected] 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

truebit avatar Feb 12 '15 07:02 truebit

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 avatar Feb 13 '15 09:02 edhub

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 */

edhub avatar Feb 13 '15 09:02 edhub

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

truebit avatar Feb 14 '15 03:02 truebit

here it is.

On Sat, Feb 14, 2015 at 11:26 AM, Sean Wang [email protected] 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 avatar Feb 15 '15 02:02 edhub

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

edhub avatar Feb 15 '15 02:02 edhub

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 [email protected] 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

truebit avatar Feb 15 '15 02:02 truebit

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

On Sun, Feb 15, 2015 at 10:34 AM, Sean Wang [email protected] 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 [email protected] 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.

edhub avatar Feb 16 '15 14:02 edhub

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

truebit avatar Feb 19 '15 04:02 truebit

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

edhub avatar Feb 25 '15 00:02 edhub

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

truebit avatar Feb 25 '15 15:02 truebit

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 [email protected] 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.

edhub avatar Feb 26 '15 00:02 edhub

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...

truebit avatar Feb 26 '15 08:02 truebit

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 = {

edhub avatar Feb 27 '15 00:02 edhub

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

truebit avatar Feb 28 '15 04:02 truebit

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 [email protected] 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.

edhub avatar Feb 28 '15 08:02 edhub

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

truebit avatar Mar 02 '15 05:03 truebit

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.

edhub avatar Mar 02 '15 08:03 edhub

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:)

truebit avatar Mar 02 '15 09:03 truebit

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 [email protected] 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.

edhub avatar Mar 02 '15 10:03 edhub

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

truebit avatar Mar 02 '15 12:03 truebit

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!

ou2s avatar Jan 21 '16 11:01 ou2s

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.

truebit avatar Jan 22 '16 13:01 truebit

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 :)

ou2s avatar Jan 22 '16 18:01 ou2s

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 [email protected] 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

truebit avatar Jan 22 '16 18:01 truebit

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.

ou2s avatar Jan 22 '16 18:01 ou2s

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 [email protected] 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

truebit avatar Jan 22 '16 18:01 truebit

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:

  • PBXBuildFile and PBXFileReference objects sorted by name in comments
  • other sections objects sorted by UUID
  • objects in files sorted by name in comments

ou2s avatar Jan 22 '16 20:01 ou2s

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 avatar Feb 03 '16 08:02 truebit

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

truebit avatar Feb 03 '16 08:02 truebit