Closed draveness closed 9 years ago
I might need to do some research about this one. Couple of questions:
Pod
project, some of the code there cannot be executed.can you provide a pod's xcode project?
Through email?
share it in a gist. https://gist.github.com/
This is the correct project https://gist.github.com/Draveness/0c0ced9fb54bd30b8ce9
This is a wrong proj https://gist.github.com/Draveness/2e913c74c7f24878da1f which is added through this:
project = XcodeProject.Load(pbxproj_file_path)
project.remove_group_by_name('UIKit', True)
project.save()
main_group = project.get_groups_by_name('DKNightVersion')[0]
uikit_group = project.get_or_create_group('UIKit', None, main_group)
groups = json.load(open(json_file_path))
for group, files in groups.iteritems():
new_group = project.get_or_create_group(group, None, uikit_group)
for f in files:
project.add_file(f, new_group)
project.save()
I tested the following script
#!/usr/bin/python
import sys
from mod_pbxproj import XcodeProject
pathToProjectFile = 'test/test.xcodeproj/project.pbxproj'
project = XcodeProject.Load( pathToProjectFile )
framework_path = 'System/Library/Frameworks/WebKit.framework'
framework_group = project.get_or_create_group('Frameworks')
project.add_file(framework_path, parent=framework_group)
project.add_file('source.m', framework_group)
project.add_file('source.h', framework_group)
project.save()
The files were added properly to ALL targets (see images below, note the black letters instead of red ones.)
My suggestion though, is not to use add_file
directly, but use add_file_if_doesnt_exist
instead, it adds some validations and avoid duplications.
Do you means I are supposed I should use add_file_if_doesnt_exist
instead of all all_file
methods?
wait, i didn't see the second gist. I'm rechecking...
OK, I am trying now..
I found something. Can you:
project.remove_group_by_name('UIKit', True)
I suspect there was an exception during the remove process that aborted the execution of the rest.
I tried, but not work.... I am really confused with this...
I committed a change regarding the remove_group_by_name. please update and try again. If still fails i have to dig deeper in the issue, it will take a while.
I have already use xcodeproj instead, I think it is a problem this doesnot adding files to correct target.
Thx for your help :+1:
How can I get the project target. because when I use this script to add files to Pods project, the code seems not work, But if I drag the folder to Pods project, it can works. This is my code