diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a3f6d10..4d479814 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ ##### Enhancements -* None. +* Add support for file system synchronized groups introduced in Xcode 16. + [Brett-Best](https://github.com/Brett-Best), [gui17aume](https://github.com/gui17aume) + [#985](https://github.com/CocoaPods/Xcodeproj/pull/985) ##### Bug Fixes diff --git a/lib/xcodeproj/constants.rb b/lib/xcodeproj/constants.rb index 543a7b2f..f613f3af 100644 --- a/lib/xcodeproj/constants.rb +++ b/lib/xcodeproj/constants.rb @@ -36,7 +36,7 @@ module Constants # @return [String] The last known object version to Xcodeproj. # - LAST_KNOWN_OBJECT_VERSION = 63 + LAST_KNOWN_OBJECT_VERSION = 70 # @return [String] The last known Xcode version to Xcodeproj. # @@ -132,6 +132,7 @@ module Constants # @return [Hash] The compatibility version string for different object versions. # COMPATIBILITY_VERSION_BY_OBJECT_VERSION = { + 70 => 'Xcode 16.0', 63 => 'Xcode 15.3', 60 => 'Xcode 15.0', 56 => 'Xcode 14.0', diff --git a/lib/xcodeproj/project/object.rb b/lib/xcodeproj/project/object.rb index 8d2ecf0e..ce582c0a 100644 --- a/lib/xcodeproj/project/object.rb +++ b/lib/xcodeproj/project/object.rb @@ -533,3 +533,5 @@ def inspect require 'xcodeproj/project/object/root_object' require 'xcodeproj/project/object/target_dependency' require 'xcodeproj/project/object/reference_proxy' +require 'xcodeproj/project/object/file_system_synchronized_root_group' +require 'xcodeproj/project/object/file_system_synchronized_exception_set' diff --git a/lib/xcodeproj/project/object/build_configuration.rb b/lib/xcodeproj/project/object/build_configuration.rb index 9c5b8d69..624e8c8b 100644 --- a/lib/xcodeproj/project/object/build_configuration.rb +++ b/lib/xcodeproj/project/object/build_configuration.rb @@ -1,3 +1,5 @@ +require 'xcodeproj/project/object/file_system_synchronized_root_group' + module Xcodeproj class Project module Object @@ -25,6 +27,20 @@ class XCBuildConfiguration < AbstractObject # has_one :base_configuration_reference, PBXFileReference + # @return [PBXFileSystemSynchronizedRootGroup] an optional reference to a group + # synchronized with the file system that contains a configuration file (`.xcconfig`). + # + # @note the configuration file relative path must be provided in `base_configuration_reference_relative_path` + # + has_one :base_configuration_reference_anchor, PBXFileSystemSynchronizedRootGroup + + # @return [String] the relative path of a configuration file (`.xcconfig`) + # inside a group synchronized with the file system. + # + # @note the configuration file group must be provided in `base_configuration_reference_anchor` + # + attribute :base_configuration_reference_relative_path, String + public # @!group AbstractObject Hooks diff --git a/lib/xcodeproj/project/object/file_system_synchronized_exception_set.rb b/lib/xcodeproj/project/object/file_system_synchronized_exception_set.rb new file mode 100644 index 00000000..b23dca01 --- /dev/null +++ b/lib/xcodeproj/project/object/file_system_synchronized_exception_set.rb @@ -0,0 +1,62 @@ +require 'xcodeproj/project/object_attributes' +require 'xcodeproj/project/object/helpers/groupable_helper' + +module Xcodeproj + class Project + module Object + # This class represents a file system synchronized build file exception set. + class PBXFileSystemSynchronizedBuildFileExceptionSet < AbstractObject + # @return [AbstractTarget] The target to which this exception set applies. + # + has_one :target, AbstractTarget + + # @return [Array] The list of files in the group that are excluded from the target. + # + attribute :membership_exceptions, Array + + # @return [Array] The list of public headers. + # + attribute :public_headers, Array + + # @return [Array] The list of private headers. + # + attribute :private_headers, Array + + # @return [Hash] The files with specific compiler flags. + # + attribute :additional_compiler_flags_by_relative_path, Hash + + # @return [Hash] The files with specific attributes. + # + attribute :attributes_by_relative_path, Hash + + # @return [Hash] The files with a platform filter. + # + attribute :platform_filters_by_relative_path, Hash + + def display_name + "Exceptions for \"#{GroupableHelper.parent(self).display_name}\" folder in \"#{target.name}\" target" + end + end + + # This class represents a file system synchronized group build phase membership exception set. + class PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet < AbstractObject + # @return [PBXSourcesBuildPhase] The build phase to which this exception set applies. + # + has_one :build_phase, PBXSourcesBuildPhase + + # @return [Array] The list of files in the group that are excluded from the build phase. + # + attribute :membership_exceptions, Array + + # @return [Hash] The files with a platform filter. + # + attribute :platform_filters_by_relative_path, Hash + + def display_name + "Exceptions for \"#{GroupableHelper.parent(self).display_name}\" folder in \"#{build_phase.name}\" build phase" + end + end + end + end +end diff --git a/lib/xcodeproj/project/object/file_system_synchronized_root_group.rb b/lib/xcodeproj/project/object/file_system_synchronized_root_group.rb new file mode 100644 index 00000000..4a26bc6a --- /dev/null +++ b/lib/xcodeproj/project/object/file_system_synchronized_root_group.rb @@ -0,0 +1,74 @@ +require 'xcodeproj/project/object/file_system_synchronized_exception_set' + +module Xcodeproj + class Project + module Object + # This class represents a file system synchronized root group. + class PBXFileSystemSynchronizedRootGroup < AbstractObject + # @return [String] the directory to which the path is relative. + # + # @note The accepted values are: + # - `` for absolute paths + # - `` for paths relative to the group + # - `SOURCE_ROOT` for paths relative to the project + # - `DEVELOPER_DIR` for paths relative to the developer + # directory. + # - `BUILT_PRODUCTS_DIR` for paths relative to the build + # products directory. + # - `SDKROOT` for paths relative to the SDK directory. + # + attribute :source_tree, String, '' + + # @return [String] the path to a folder in the file system. + # + attribute :path, String + + # @return [String] Whether Xcode should use tabs for text alignment. + # + # @example + # `1` + # + attribute :uses_tabs, String + + # @return [String] The width of the indent. + # + # @example + # `2` + # + attribute :indent_width, String + + # @return [String] The width of the tabs. + # + # @example + # `2` + # + attribute :tab_width, String + + # @return [String] Whether Xcode should wrap lines. + # + # @example + # `1` + # + attribute :wraps_lines, String + + # @return [Array] + # The list of exceptions applying to this group. + # + has_many :exceptions, [PBXFileSystemSynchronizedBuildFileExceptionSet, PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet] + + # @return [Hash] The files in the group that have a file type defined explicitly. + # + attribute :explicit_file_types, Hash + + # @return [Array] The folders in the group that are defined explicitly. + # + attribute :explicit_folders, Array + + def display_name + return path if path + super + end + end + end + end +end diff --git a/lib/xcodeproj/project/object/group.rb b/lib/xcodeproj/project/object/group.rb index 7571eadd..51902dd3 100644 --- a/lib/xcodeproj/project/object/group.rb +++ b/lib/xcodeproj/project/object/group.rb @@ -1,5 +1,6 @@ require 'xcodeproj/project/object/helpers/groupable_helper' require 'xcodeproj/project/object/helpers/file_references_factory' +require 'xcodeproj/project/object/file_system_synchronized_root_group' module Xcodeproj class Project @@ -13,7 +14,7 @@ class PBXGroup < AbstractObject # @return [ObjectList] # the objects contained by the group. # - has_many :children, [PBXGroup, PBXFileReference, PBXReferenceProxy] + has_many :children, [PBXGroup, PBXFileReference, PBXReferenceProxy, PBXFileSystemSynchronizedRootGroup] # @return [String] the directory to which the path is relative. # diff --git a/lib/xcodeproj/project/object/native_target.rb b/lib/xcodeproj/project/object/native_target.rb index 87294ae2..42b008c9 100644 --- a/lib/xcodeproj/project/object/native_target.rb +++ b/lib/xcodeproj/project/object/native_target.rb @@ -461,6 +461,11 @@ class PBXNativeTarget < AbstractTarget # has_many :build_phases, AbstractBuildPhase + # @return [ObjectList] the file system synchronized + # groups containing files to include to build this target. + # + has_many :file_system_synchronized_groups, PBXFileSystemSynchronizedRootGroup + public # @!group Helpers @@ -684,19 +689,28 @@ def sort(_options = nil) def to_hash_as(method = :to_hash) hash_as = super - if !hash_as['packageProductDependencies'].nil? && hash_as['packageProductDependencies'].empty? - hash_as.delete('packageProductDependencies') + excluded_keys_for_serialization_when_empty.each do |key| + if !hash_as[key].nil? && hash_as[key].empty? + hash_as.delete(key) + end end hash_as end def to_ascii_plist plist = super - if !plist.value['packageProductDependencies'].nil? && plist.value['packageProductDependencies'].empty? - plist.value.delete('packageProductDependencies') + excluded_keys_for_serialization_when_empty.each do |key| + if !plist.value[key].nil? && plist.value[key].empty? + plist.value.delete(key) + end end plist end + + # @return [Array] array of keys to exclude from serialization when the value is empty + def excluded_keys_for_serialization_when_empty + %w(packageProductDependencies fileSystemSynchronizedGroups) + end end #-----------------------------------------------------------------------# diff --git a/lib/xcodeproj/project/object/root_object.rb b/lib/xcodeproj/project/object/root_object.rb index 8737400f..3c48f903 100644 --- a/lib/xcodeproj/project/object/root_object.rb +++ b/lib/xcodeproj/project/object/root_object.rb @@ -53,6 +53,10 @@ class PBXProject < AbstractObject # attribute :minimized_project_reference_proxies, String, '0' + # @return [String] preferred project object version + # + attribute :preferred_project_object_version, String, '70' + # @return [PBXGroup] the group containing the references to products of # the project. # diff --git a/spec/project/object/root_object_spec.rb b/spec/project/object/root_object_spec.rb index 45493fda..ec2e01ad 100644 --- a/spec/project/object/root_object_spec.rb +++ b/spec/project/object/root_object_spec.rb @@ -43,6 +43,10 @@ module ProjectSpecs @root_object.minimized_project_reference_proxies.should == '0' end + it 'returns the preferred project object version' do + @root_object.preferred_project_object_version.should == '70' + end + it 'returns the products group' do @root_object.product_ref_group.class.should == PBXGroup end