Comments (20)
Please, read the method signature. remove_group
uses an id to remove the group.
remove_group_by_name
removes the group based on the name.
BTW, You are not passing either of them to the method you are calling, you are passing an object group.
from mod-pbxproj.
Sorry, doesn't get_or_create_group
return an id too?
from mod-pbxproj.
It returns a group object, those objects are required by other methods for instance to add_file, you may want to specify that the file goes under a specific group (object)
from mod-pbxproj.
I see. Then what's the way to remove a group? I don't seem to succeed with remove_group_by_name
either.
This leaves the project with the group named "Hola":
group = project.get_or_create_group("Hola")
project.remove_group(group)
project.remove_group(group.id)
project.remove_group_by_name("Hola")
project.save()
Thanks
from mod-pbxproj.
i also ask this question , please
from mod-pbxproj.
I checked it. It was a bug, and it's fixed already in the master branch. Pull request #57 if you are curious about the changes.
from mod-pbxproj.
Thanks @kronenthaler, The group is removed now.
Anyway I have one more question about this:
If the group contains source files, these are not removed from the Compile Sources build phase.
What would be the approach to take regarding this?
from mod-pbxproj.
try with the recursive flag of the method.
remove_group_by_name('name', True)
from mod-pbxproj.
With the recursive flag it fails with this error:
Traceback (most recent call last):
File "./BuildFromWorkspaceUsingBundles.py", line 108, in <module>
project.remove_group_by_name(adapterName, True)
File "/Users/damian.troncoso/Desktop/workspace/LIMA-docs/Tools/AutomatedBuilding/mod_pbxproj/mod_pbxproj/mod_pbxproj.py", line 1002, in remove_group_by_name
self.remove_group(group.id, recursive)
File "/Users/damian.troncoso/Desktop/workspace/LIMA-docs/Tools/AutomatedBuilding/mod_pbxproj/mod_pbxproj/mod_pbxproj.py", line 983, in remove_group
name = self.objects.get(id).get('path')
AttributeError: 'NoneType' object has no attribute 'get'
This seems to happen when there is a group within the group I'm removing with the same name
from mod-pbxproj.
I will check it over the weekend
On Fri, May 29, 2015 at 9:36 PM, Damian [email protected] wrote:
With the recursive flag it fails with this error:
Traceback (most recent call last):
File "./BuildFromWorkspaceUsingBundles.py", line 108, in
project.remove_group_by_name(adapterName, True)
File "/Users/damian.troncoso/Desktop/workspace/LIMA-docs/Tools/AutomatedBuilding/mod_pbxproj/mod_pbxproj/mod_pbxproj.py", line 1002, in remove_group_by_name
self.remove_group(group.id, recursive)
File "/Users/damian.troncoso/Desktop/workspace/LIMA-docs/Tools/AutomatedBuilding/mod_pbxproj/mod_pbxproj/mod_pbxproj.py", line 983, in remove_group
name = self.objects.get(id).get('path')
AttributeError: 'NoneType' object has no attribute 'get'—
Reply to this email directly or view it on GitHub
#53 (comment)
.
.: Kronenthaler :.
[email protected] | yahoo.com
from mod-pbxproj.
Thanks a lot!
from mod-pbxproj.
DELETED: unrelated input to the issue.
from mod-pbxproj.
I couldn't reproduce your error. Neither with the remove_group_by_name
or remove_group
. Here is the script i used to test.
#!/bin/python
from mod_pbxproj import XcodeProject
project = XcodeProject.Load('test/test.xcodeproj/project.pbxproj')
# create Hola/bye/source.m
group = project.get_or_create_group("Hola")
groupB = project.get_or_create_group(name="bye", parent=group)
project.add_file_if_doesnt_exist("source.m", parent=groupB)
# remove recursively using the string name
project.remove_group_by_name("Hola", True)
# create Hola/bye/source.m
group2 = project.get_or_create_group("Hola")
groupB2 = project.get_or_create_group(name="bye", parent=group2)
project.add_file_if_doesnt_exist("source.m", parent=groupB2)
# remove recursively using the group2 instance + id
project.remove_group(group2.id, True)
project.save()
from mod-pbxproj.
I meant when there's a group within a group, both with the same name.
So for example this:
group = project.get_or_create_group("Hola")
groupB = project.get_or_create_group(name="Hola", parent=group)
project.remove_group_by_name("Hola", True)
project.save()
It fails with this log:
Traceback (most recent call last):
File "./BuildFromWorkspaceUsingBundles.py", line 112, in <module>
project.remove_group_by_name("Hola", True)
File "/Users/damian.troncoso/Desktop/workspace/LIMA-docs/Tools/AutomatedBuilding/mod_pbxproj/mod_pbxproj/mod_pbxproj.py", line 1002, in remove_group_by_name
self.remove_group(group.id, recursive)
File "/Users/damian.troncoso/Desktop/workspace/LIMA-docs/Tools/AutomatedBuilding/mod_pbxproj/mod_pbxproj/mod_pbxproj.py", line 991, in remove_group
if childValue.get('isa') == 'PBXGroup':
AttributeError: 'NoneType' object has no attribute 'get'
from mod-pbxproj.
True, but that operation is ambiguous.
Both groups have the same name, there is no way to ensure which one was deleted first (the parent or the child).
In such cases use the id
to resolve the ambiguity yourself.
from mod-pbxproj.
But if I use the id (project.remove_group(group.id))
, the source files are not removed from the Compile Sources build phase.
from mod-pbxproj.
I fixed that issue on pull request #57 give it a try
from mod-pbxproj.
I just checked it. It's not fixed :/
project.remove_group(group.id)
still leaves the source files in the Compile Sources build phase, which leads to compiler errors.
from mod-pbxproj.
This is the code i have been using to test the feature:
#!/bin/python
from mod_pbxproj import XcodeProject
project = XcodeProject.Load('test/test.xcodeproj/project.pbxproj')
# add a file to the sources
group = project.get_or_create_group("Hola")
groupB = project.get_or_create_group(name="Hola", parent=group)
project.add_file_if_doesnt_exist("source.m", parent=groupB)
# comment out to actually remove the file
# project.remove_group(group.id, True) # note the True to make it recursive.
project.save()
Create an empty project and run over that project. It will create: Hola/Hola/source.m
Check that the file is in the sources section of the target.
Un-comment the remove_group and run again.
Check again the sources section of the target. It should be gone.
If this works, the problem is in your script.
from mod-pbxproj.
Sorry, I didn't realize I could use remove_group
with the recursive option :)
It's working now.
Thanks a lot!
from mod-pbxproj.
Related Issues (20)
- again How to add one framework just want to build it output as a framework with my main proj HOT 2
- [BUG]When I use setup.py to install pbxproj module syntax error occured. HOT 1
- conda forge package HOT 2
- [FEAT] How to add sub-project into current project, but sub-project has two kinds of target type
- [BUG] This one project loads but doesn't save HOT 2
- Moving an existing group to another group HOT 2
- update flag HOT 1
- [BUG] Update multible Flags HOT 2
- [FEAT] Can I change setting on Build Settings > Signing HOT 1
- [FEAT] How do you get a flag value ? HOT 1
- [FEAT]Can I find my favorite books at will?
- Referencing files into UnityFramework
- File or folder association settings
- add_package [BUG]
- remove a file with fileID HOT 1
- [BUG] Local package XCLocalSwiftPackageReference is not getting parsed properly HOT 1
- [BUG] Build steps that have shell commands lose formatting when project is saved
- [FEAT] add flag with null value
- Cannot create subfolders HOT 2
- [BUG] Exception is thrown when finding `productRef` instead of `fileRef`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mod-pbxproj.