lib/xcake/xcode/project.rb in xcake-0.6.25 vs lib/xcake/xcode/project.rb in xcake-0.7.0
- old
+ new
@@ -112,68 +112,60 @@
#
def new_configuration(_configuration)
new(Xcodeproj::Project::Object::XCBuildConfiguration)
end
- # Creates a new xcode group from the node
+ # Creates a new xcode file reference from the node
#
- # @param [Node] node
- # configuration DSL to create target from
+ # @param [Pathname] path
+ # => path of the file reference from the source root
#
- # @return [Group] new xcode group
+ # @return [PBXFileReference] new xcode file refrence
#
- #
- # TODO: Simplify this method figure out more reliable rules for group
- # generation - maybe part of the new file installer in 0.7.
- #
- # As well as variant groups and other types of groups.
- #
- def new_group(node)
+ def file_reference_for_path(path)
+ group = group_for_file_reference_path(path)
+ group_path = Pathname.new group.dirname
- parent = node.parent
- return main_group unless parent
+ file_path = path.cleanpath.relative_path_from group_path
+ group.new_reference(file_path.to_s)
+ end
- if parent.component.include?(".lproj")
+ def group_for_file_reference_path(path)
+ clean_path = path.cleanpath
+ group = variant_group_for_path(path)
+ group = group_for_path(path) unless group
+ group
+ end
- group = main_group.find_subpath(parent.parent.path, true) unless group
+ private
- variant_group = group[node.component]
+ def variant_group_for_path(path)
+ group_path = path.dirname.cleanpath
+ base_name = group_path.basename
- unless variant_group
- variant_group = group.project.new(PBXVariantGroup)
- variant_group.name = node.component
- variant_group.set_source_tree(:group)
- group.children << variant_group
- end
+ return nil unless base_name.to_s.include?('.lproj')
+ parent_group = group_for_path(group_path)
- ensure_parent_path(group, parent.parent)
- group = variant_group
- else
- group = main_group.find_subpath(parent.path, true) unless group
- ensure_parent_path(group, parent)
+ group = parent_group[path.basename.to_s]
+
+ unless group
+ group = new(PBXVariantGroup)
+ group.name = path.basename.to_s
+ group.set_source_tree(:group)
+ parent_group.children << group
end
group
end
- # Creates a new xcode file reference from the node
- #
- # @param [String] path
- # => path of the file reference from the source root
- #
- # @return [PBXFileReference] new xcode file refrence
- #
- def new_file_reference(path)
- path_object = Pathname.new(path)
- group = main_group.find_subpath(path_object.dirname.to_s, true)
- group[path_object.basename.to_s] ||
- group.new_reference(path_object.to_s)
- end
+ def group_for_path(path)
+ group_path = path.dirname.cleanpath
- def ensure_parent_path(group, node)
- group.path = node.component
- ensure_parent_path(group.parent, node.parent) unless node.parent.nil?
+ return main_group unless group_path.to_s != '.'
+ main_group.child_for_path(group_path.to_s)
end
+
+ public
# Finds a unit test target for a xcode target
#
# @param [Target] target
# target to find a xcode target for.