-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test to ensure Xcodeproj can save a project after removing a subproject #161
Conversation
Thanks! So to be clear, your patch fixes the exception that would be raised, but does not yet properly clean-up all related objects? |
That's right. I populated the list of UUID's by removing the subproject by hand and identifying which UUID's were removed. I haven't been able to find a way to automatically find all of them and add them as referrers. |
@alloy anything I can change in here to get this merged? |
@jpsim I’d like to fix this properly, so I’m gonna be taking a look at your test and see if I can find a way to make it work without manually removing the other objects. If you have any details about what those objects are and possibly rough ideas of how to identify them as being related to the subproject then please do share those. |
@neonichu May be able to shed some light onto this, or figure out how Xcode keeps reference. I think we need to correctly track references of things in the subproject. Things like the targets from the submodule have references in the parent. |
For reference, the way I found all these UUID's was to do a diff before and after removing the subproject manually. |
I have been working on this and have pushed my almost completed work to https://github.com/CocoaPods/Xcodeproj/compare/jpsim-jp-remove-subproject-test. The relevant commit is f4747d2. Currently the external project’s products group is still left behind. I have no idea why that’s even included, but it is and should probably be removed by checking from PBXFileReference#remove_from_project if an entry for itself exists in the project’s root object
|
(So this should be simple to finish, I simply have to go :) More tomorrow.) |
@alloy In my tests I didn't find the external project’s products group and your patch behaved exactly as Xcode 5.1.1. Folders:
$ diff Test\ expected/Test.xcodeproj/project.pbxproj Test/Test.xcodeproj/project.pbxproj
// Nothing $ diff Test\ expected/Test.xcodeproj/project.pbxproj Test\ copy/Test.xcodeproj/project.pbxproj diff --git 1/Test expected/Test.xcodeproj/project.pbxproj 2/Test copy/Test.xcodeproj/project.pbxproj
index 45f6635..603f21e 100644
--- 1/Test expected/Test.xcodeproj/project.pbxproj
+++ 2/Test copy/Test.xcodeproj/project.pbxproj
@@ -33,6 +33,20 @@
remoteGlobalIDString = E536F1BE197ACB0800509E0E;
remoteInfo = Test;
};
+ E536F249197ACBA100509E0E /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = E536F244197ACBA100509E0E /* Test2.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = E536F206197ACB9A00509E0E;
+ remoteInfo = Test2;
+ };
+ E536F24B197ACBA100509E0E /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = E536F244197ACBA100509E0E /* Test2.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = E536F22D197ACB9A00509E0E;
+ remoteInfo = Test2Tests;
+ };
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@@ -58,6 +72,7 @@
E536F1EF197ACB0800509E0E /* TestTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TestTests-Info.plist"; sourceTree = "<group>"; };
E536F1F1197ACB0800509E0E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
E536F1F3197ACB0800509E0E /* TestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestTests.m; sourceTree = "<group>"; };
+ E536F244197ACBA100509E0E /* Test2.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Test2.xcodeproj; path = ../../Test2/Test2.xcodeproj; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -117,6 +132,7 @@
E536F1C8197ACB0800509E0E /* Test */ = {
isa = PBXGroup;
children = (
+ E536F244197ACBA100509E0E /* Test2.xcodeproj */,
E536F1D1197ACB0800509E0E /* AppDelegate.h */,
E536F1D2197ACB0800509E0E /* AppDelegate.m */,
E536F1D4197ACB0800509E0E /* Main_iPhone.storyboard */,
@@ -160,6 +176,15 @@
name = "Supporting Files";
sourceTree = "<group>";
};
+ E536F245197ACBA100509E0E /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ E536F24A197ACBA100509E0E /* Test2.app */,
+ E536F24C197ACBA100509E0E /* Test2Tests.xctest */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -223,6 +248,12 @@
mainGroup = E536F1B6197ACB0800509E0E;
productRefGroup = E536F1C0197ACB0800509E0E /* Products */;
projectDirPath = "";
+ projectReferences = (
+ {
+ ProductGroup = E536F245197ACBA100509E0E /* Products */;
+ ProjectRef = E536F244197ACBA100509E0E /* Test2.xcodeproj */;
+ },
+ );
projectRoot = "";
targets = (
E536F1BE197ACB0800509E0E /* Test */,
@@ -231,6 +262,23 @@
};
/* End PBXProject section */
+/* Begin PBXReferenceProxy section */
+ E536F24A197ACBA100509E0E /* Test2.app */ = {
+ isa = PBXReferenceProxy;
+ fileType = wrapper.application;
+ path = Test2.app;
+ remoteRef = E536F249197ACBA100509E0E /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+ E536F24C197ACBA100509E0E /* Test2Tests.xctest */ = {
+ isa = PBXReferenceProxy;
+ fileType = wrapper.cfbundle;
+ path = Test2Tests.xctest;
+ remoteRef = E536F24B197ACBA100509E0E /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+/* End PBXReferenceProxy section */
+
/* Begin PBXResourcesBuildPhase section */
E536F1BD197ACB0800509E0E /* Resources */ = {
isa = PBXResourcesBuildPhase; |
@irrationalfab But did you open the project with Xcode to convert it to an ASCII plist first? Because I think that Xcode might strip it out to ‘fix’ the project. If I check the dump of what Xcodeproj creates, then it definitely contains:
|
Yeah it’s definitely Xcode that’s stripping it out, so that means that technically we’re not yet producing a valid project if we omit the group. |
@alloy the project was originally created by Xcode. Then I compared the version edited by hand via Xcode to the one edited by Xcodeproj and the diff was null. |
Ok, this is done. I will rebase, squash and merge it. |
Closed by 9ce8ac2 |
This is a small step in fixing #158. For the time being, if you know all the UUID's relevant to a subproject you want to delete, this PR allows you to manually remove all those objects.
Of course, I'd rather all these UUID's be detected as the subproject's referrers, but I haven't found a way to do this comprehensively yet.