Skip to content

Commit fecbac5

Browse files
authored
Merge pull request #985 from gui17aume/feature/xcode16-synchronized-groups
Add support for Xcode 16 and synchronized groups
2 parents a01324e + b75ec85 commit fecbac5

10 files changed

Lines changed: 187 additions & 7 deletions

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
##### Enhancements
66

7-
* None.
7+
* Add support for file system synchronized groups introduced in Xcode 16.
8+
[Brett-Best](https://github.com/Brett-Best), [gui17aume](https://github.com/gui17aume)
9+
[#985](https://github.com/CocoaPods/Xcodeproj/pull/985)
810

911
##### Bug Fixes
1012

lib/xcodeproj/constants.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module Constants
3636

3737
# @return [String] The last known object version to Xcodeproj.
3838
#
39-
LAST_KNOWN_OBJECT_VERSION = 63
39+
LAST_KNOWN_OBJECT_VERSION = 70
4040

4141
# @return [String] The last known Xcode version to Xcodeproj.
4242
#
@@ -132,6 +132,7 @@ module Constants
132132
# @return [Hash] The compatibility version string for different object versions.
133133
#
134134
COMPATIBILITY_VERSION_BY_OBJECT_VERSION = {
135+
70 => 'Xcode 16.0',
135136
63 => 'Xcode 15.3',
136137
60 => 'Xcode 15.0',
137138
56 => 'Xcode 14.0',

lib/xcodeproj/project/object.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,5 @@ def inspect
533533
require 'xcodeproj/project/object/root_object'
534534
require 'xcodeproj/project/object/target_dependency'
535535
require 'xcodeproj/project/object/reference_proxy'
536+
require 'xcodeproj/project/object/file_system_synchronized_root_group'
537+
require 'xcodeproj/project/object/file_system_synchronized_exception_set'

lib/xcodeproj/project/object/build_configuration.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'xcodeproj/project/object/file_system_synchronized_root_group'
2+
13
module Xcodeproj
24
class Project
35
module Object
@@ -25,6 +27,20 @@ class XCBuildConfiguration < AbstractObject
2527
#
2628
has_one :base_configuration_reference, PBXFileReference
2729

30+
# @return [PBXFileSystemSynchronizedRootGroup] an optional reference to a group
31+
# synchronized with the file system that contains a configuration file (`.xcconfig`).
32+
#
33+
# @note the configuration file relative path must be provided in `base_configuration_reference_relative_path`
34+
#
35+
has_one :base_configuration_reference_anchor, PBXFileSystemSynchronizedRootGroup
36+
37+
# @return [String] the relative path of a configuration file (`.xcconfig`)
38+
# inside a group synchronized with the file system.
39+
#
40+
# @note the configuration file group must be provided in `base_configuration_reference_anchor`
41+
#
42+
attribute :base_configuration_reference_relative_path, String
43+
2844
public
2945

3046
# @!group AbstractObject Hooks
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
require 'xcodeproj/project/object_attributes'
2+
require 'xcodeproj/project/object/helpers/groupable_helper'
3+
4+
module Xcodeproj
5+
class Project
6+
module Object
7+
# This class represents a file system synchronized build file exception set.
8+
class PBXFileSystemSynchronizedBuildFileExceptionSet < AbstractObject
9+
# @return [AbstractTarget] The target to which this exception set applies.
10+
#
11+
has_one :target, AbstractTarget
12+
13+
# @return [Array<String>] The list of files in the group that are excluded from the target.
14+
#
15+
attribute :membership_exceptions, Array
16+
17+
# @return [Array<String>] The list of public headers.
18+
#
19+
attribute :public_headers, Array
20+
21+
# @return [Array<String>] The list of private headers.
22+
#
23+
attribute :private_headers, Array
24+
25+
# @return [Hash] The files with specific compiler flags.
26+
#
27+
attribute :additional_compiler_flags_by_relative_path, Hash
28+
29+
# @return [Hash] The files with specific attributes.
30+
#
31+
attribute :attributes_by_relative_path, Hash
32+
33+
# @return [Hash] The files with a platform filter.
34+
#
35+
attribute :platform_filters_by_relative_path, Hash
36+
37+
def display_name
38+
"Exceptions for \"#{GroupableHelper.parent(self).display_name}\" folder in \"#{target.name}\" target"
39+
end
40+
end
41+
42+
# This class represents a file system synchronized group build phase membership exception set.
43+
class PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet < AbstractObject
44+
# @return [PBXSourcesBuildPhase] The build phase to which this exception set applies.
45+
#
46+
has_one :build_phase, PBXSourcesBuildPhase
47+
48+
# @return [Array<String>] The list of files in the group that are excluded from the build phase.
49+
#
50+
attribute :membership_exceptions, Array
51+
52+
# @return [Hash] The files with a platform filter.
53+
#
54+
attribute :platform_filters_by_relative_path, Hash
55+
56+
def display_name
57+
"Exceptions for \"#{GroupableHelper.parent(self).display_name}\" folder in \"#{build_phase.name}\" build phase"
58+
end
59+
end
60+
end
61+
end
62+
end
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
require 'xcodeproj/project/object/file_system_synchronized_exception_set'
2+
3+
module Xcodeproj
4+
class Project
5+
module Object
6+
# This class represents a file system synchronized root group.
7+
class PBXFileSystemSynchronizedRootGroup < AbstractObject
8+
# @return [String] the directory to which the path is relative.
9+
#
10+
# @note The accepted values are:
11+
# - `<absolute>` for absolute paths
12+
# - `<group>` for paths relative to the group
13+
# - `SOURCE_ROOT` for paths relative to the project
14+
# - `DEVELOPER_DIR` for paths relative to the developer
15+
# directory.
16+
# - `BUILT_PRODUCTS_DIR` for paths relative to the build
17+
# products directory.
18+
# - `SDKROOT` for paths relative to the SDK directory.
19+
#
20+
attribute :source_tree, String, '<group>'
21+
22+
# @return [String] the path to a folder in the file system.
23+
#
24+
attribute :path, String
25+
26+
# @return [String] Whether Xcode should use tabs for text alignment.
27+
#
28+
# @example
29+
# `1`
30+
#
31+
attribute :uses_tabs, String
32+
33+
# @return [String] The width of the indent.
34+
#
35+
# @example
36+
# `2`
37+
#
38+
attribute :indent_width, String
39+
40+
# @return [String] The width of the tabs.
41+
#
42+
# @example
43+
# `2`
44+
#
45+
attribute :tab_width, String
46+
47+
# @return [String] Whether Xcode should wrap lines.
48+
#
49+
# @example
50+
# `1`
51+
#
52+
attribute :wraps_lines, String
53+
54+
# @return [Array<PBXFileSystemSynchronizedBuildFileExceptionSet, PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet>]
55+
# The list of exceptions applying to this group.
56+
#
57+
has_many :exceptions, [PBXFileSystemSynchronizedBuildFileExceptionSet, PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet]
58+
59+
# @return [Hash] The files in the group that have a file type defined explicitly.
60+
#
61+
attribute :explicit_file_types, Hash
62+
63+
# @return [Array] The folders in the group that are defined explicitly.
64+
#
65+
attribute :explicit_folders, Array
66+
67+
def display_name
68+
return path if path
69+
super
70+
end
71+
end
72+
end
73+
end
74+
end

lib/xcodeproj/project/object/group.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'xcodeproj/project/object/helpers/groupable_helper'
22
require 'xcodeproj/project/object/helpers/file_references_factory'
3+
require 'xcodeproj/project/object/file_system_synchronized_root_group'
34

45
module Xcodeproj
56
class Project
@@ -13,7 +14,7 @@ class PBXGroup < AbstractObject
1314
# @return [ObjectList<PBXGroup, PBXFileReference>]
1415
# the objects contained by the group.
1516
#
16-
has_many :children, [PBXGroup, PBXFileReference, PBXReferenceProxy]
17+
has_many :children, [PBXGroup, PBXFileReference, PBXReferenceProxy, PBXFileSystemSynchronizedRootGroup]
1718

1819
# @return [String] the directory to which the path is relative.
1920
#

lib/xcodeproj/project/object/native_target.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,11 @@ class PBXNativeTarget < AbstractTarget
461461
#
462462
has_many :build_phases, AbstractBuildPhase
463463

464+
# @return [ObjectList<PBXFileSystemSynchronizedRootGroup>] the file system synchronized
465+
# groups containing files to include to build this target.
466+
#
467+
has_many :file_system_synchronized_groups, PBXFileSystemSynchronizedRootGroup
468+
464469
public
465470

466471
# @!group Helpers
@@ -684,19 +689,28 @@ def sort(_options = nil)
684689

685690
def to_hash_as(method = :to_hash)
686691
hash_as = super
687-
if !hash_as['packageProductDependencies'].nil? && hash_as['packageProductDependencies'].empty?
688-
hash_as.delete('packageProductDependencies')
692+
excluded_keys_for_serialization_when_empty.each do |key|
693+
if !hash_as[key].nil? && hash_as[key].empty?
694+
hash_as.delete(key)
695+
end
689696
end
690697
hash_as
691698
end
692699

693700
def to_ascii_plist
694701
plist = super
695-
if !plist.value['packageProductDependencies'].nil? && plist.value['packageProductDependencies'].empty?
696-
plist.value.delete('packageProductDependencies')
702+
excluded_keys_for_serialization_when_empty.each do |key|
703+
if !plist.value[key].nil? && plist.value[key].empty?
704+
plist.value.delete(key)
705+
end
697706
end
698707
plist
699708
end
709+
710+
# @return [Array<String>] array of keys to exclude from serialization when the value is empty
711+
def excluded_keys_for_serialization_when_empty
712+
%w(packageProductDependencies fileSystemSynchronizedGroups)
713+
end
700714
end
701715

702716
#-----------------------------------------------------------------------#

lib/xcodeproj/project/object/root_object.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class PBXProject < AbstractObject
5353
#
5454
attribute :minimized_project_reference_proxies, String, '0'
5555

56+
# @return [String] preferred project object version
57+
#
58+
attribute :preferred_project_object_version, String, '70'
59+
5660
# @return [PBXGroup] the group containing the references to products of
5761
# the project.
5862
#

spec/project/object/root_object_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ module ProjectSpecs
4343
@root_object.minimized_project_reference_proxies.should == '0'
4444
end
4545

46+
it 'returns the preferred project object version' do
47+
@root_object.preferred_project_object_version.should == '70'
48+
end
49+
4650
it 'returns the products group' do
4751
@root_object.product_ref_group.class.should == PBXGroup
4852
end

0 commit comments

Comments
 (0)