diff --git a/CHANGELOG.md b/CHANGELOG.md index 852eb84c8..f8ab2fbd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ ##### Enhancements -* None. +* Support for Xcode 11 attributes and objects. + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#687](https://github.com/CocoaPods/Xcodeproj/pull/687) ##### Bug Fixes diff --git a/lib/xcodeproj/constants.rb b/lib/xcodeproj/constants.rb index c300fda01..5f174434a 100644 --- a/lib/xcodeproj/constants.rb +++ b/lib/xcodeproj/constants.rb @@ -32,15 +32,15 @@ module Constants # @return [String] The last known object version to Xcodeproj. # - LAST_KNOWN_OBJECT_VERSION = 51 + LAST_KNOWN_OBJECT_VERSION = 52 # @return [String] The last known object version to Xcodeproj. # - LAST_UPGRADE_CHECK = '1020' + LAST_UPGRADE_CHECK = '1100' # @return [String] The last known object version to Xcodeproj. # - LAST_SWIFT_UPGRADE_CHECK = '1020' + LAST_SWIFT_UPGRADE_CHECK = '1100' # @return [String] The version of `.xcscheme` files supported by Xcodeproj # @@ -126,6 +126,7 @@ module Constants # @return [Hash] The compatibility version string for different object versions. # COMPATIBILITY_VERSION_BY_OBJECT_VERSION = { + 52 => 'Xcode 11.0', 51 => 'Xcode 10.0', 50 => 'Xcode 9.3', 48 => 'Xcode 8.0', diff --git a/lib/xcodeproj/project/object.rb b/lib/xcodeproj/project/object.rb index 777aaafe0..60ee526e6 100644 --- a/lib/xcodeproj/project/object.rb +++ b/lib/xcodeproj/project/object.rb @@ -518,6 +518,8 @@ def inspect end # Now load the concrete subclasses. +require 'xcodeproj/project/object/swift_package_remote_reference' +require 'xcodeproj/project/object/swift_package_product_dependency' require 'xcodeproj/project/object/build_configuration' require 'xcodeproj/project/object/build_file' require 'xcodeproj/project/object/build_phase' diff --git a/lib/xcodeproj/project/object/build_file.rb b/lib/xcodeproj/project/object/build_file.rb index f1e142c43..6b1009798 100644 --- a/lib/xcodeproj/project/object/build_file.rb +++ b/lib/xcodeproj/project/object/build_file.rb @@ -18,7 +18,7 @@ class PBXBuildFile < AbstractObject # attribute :settings, Hash - # @return [PBXFileReference] the file that to build. + # @return [PBXFileReference] the file to build. # # @todo I think that is possible to add any kind of group (for # example folders linked to a path). @@ -31,6 +31,14 @@ class PBXBuildFile < AbstractObject PBXReferenceProxy, ] + # @return [XCSwiftPackageProductDependency] the Swift Package file to build. + # + has_one :product_ref, XCSwiftPackageProductDependency + + # @return [String] the platform filter for this build file. + # + attribute :platform_filter, String + #---------------------------------------------------------------------# public diff --git a/lib/xcodeproj/project/object/build_rule.rb b/lib/xcodeproj/project/object/build_rule.rb index 115cc70f4..da5f5f2a6 100644 --- a/lib/xcodeproj/project/object/build_rule.rb +++ b/lib/xcodeproj/project/object/build_rule.rb @@ -41,6 +41,11 @@ class PBXBuildRule < AbstractObject # attribute :is_editable, String, '1' + # @return [ObjectList] the file references for the + # input files files. + # + attribute :input_files, Array + # @return [ObjectList] the file references for the # output files. # diff --git a/lib/xcodeproj/project/object/native_target.rb b/lib/xcodeproj/project/object/native_target.rb index b1aafcb6c..800dc5ba5 100644 --- a/lib/xcodeproj/project/object/native_target.rb +++ b/lib/xcodeproj/project/object/native_target.rb @@ -309,7 +309,7 @@ def new_shell_script_build_phase(name = nil) # Adds a file reference for one or more system framework to the project # if needed and adds them to the Frameworks build phases. # - # @param [Array, String] name + # @param [Array, String] names # The name or the list of the names of the framework. # # @note Xcode behaviour is following: if the target has the same SDK @@ -359,7 +359,7 @@ def add_system_framework(names) # Adds a file reference for one or more system dylib libraries to the project # if needed and adds them to the Frameworks build phases. # - # @param [Array, String] name + # @param [Array, String] names # The name or the list of the names of the libraries. # # @return [void] @@ -385,7 +385,7 @@ def add_system_library_extension(names, extension) # Adds a file reference for one or more system tbd libraries to the project # if needed and adds them to the Frameworks build phases. # - # @param [Array, String] name + # @param [Array, String] names # The name or the list of the names of the libraries. # # @return [void] @@ -432,6 +432,11 @@ class PBXNativeTarget < AbstractTarget # has_one :product_reference, PBXFileReference + # @return [ObjectList] the Swift package products necessary to + # build this target. + # + has_many :package_product_dependencies, XCSwiftPackageProductDependency + # @return [String] the install path of the product. # attribute :product_install_path, String @@ -622,6 +627,22 @@ def sort(_options = nil) end end end + + def to_hash_as(method = :to_hash) + hash_as = super + if !hash_as['packageProductDependencies'].nil? && hash_as['packageProductDependencies'].empty? + hash_as.delete('packageProductDependencies') + end + hash_as + end + + def to_ascii_plist + plist = super + if !plist.value['packageProductDependencies'].nil? && plist.value['packageProductDependencies'].empty? + plist.value.delete('packageProductDependencies') + end + plist + end end #-----------------------------------------------------------------------# diff --git a/lib/xcodeproj/project/object/root_object.rb b/lib/xcodeproj/project/object/root_object.rb index c17104a90..b28c77cc6 100644 --- a/lib/xcodeproj/project/object/root_object.rb +++ b/lib/xcodeproj/project/object/root_object.rb @@ -62,6 +62,10 @@ class PBXProject < AbstractObject # attribute :project_root, String, '' + # @return [Array] the list of Swift package references. + # + has_many :package_references, XCRemoteSwiftPackageReference + # @return [Array] any reference to other projects. # has_many_references_by_keys :project_references, @@ -76,9 +80,18 @@ def ascii_plist_annotation ' Project object ' end + def to_hash_as(method = :to_hash) + hash_as = super + if !hash_as['packageReferences'].nil? && hash_as['packageReferences'].empty? + hash_as.delete('packageReferences') if !hash_as['packageReferences'].nil? && hash_as['packageReferences'].empty? + end + hash_as + end + def to_ascii_plist plist = super plist.value.delete('projectReferences') if plist.value['projectReferences'].empty? + plist.value.delete('packageReferences') if !plist.value['packageReferences'].nil? && plist.value['packageReferences'].empty? plist end end diff --git a/lib/xcodeproj/project/object/swift_package_product_dependency.rb b/lib/xcodeproj/project/object/swift_package_product_dependency.rb new file mode 100644 index 000000000..cb83e2ee0 --- /dev/null +++ b/lib/xcodeproj/project/object/swift_package_product_dependency.rb @@ -0,0 +1,19 @@ +module Xcodeproj + class Project + module Object + # This class represents a Swift package product dependency. + # + class XCSwiftPackageProductDependency < AbstractObject + # @!group Attributes + + # @return [XCRemoteSwiftPackageReference] the Swift package reference. + # + has_one :package, XCRemoteSwiftPackageReference + + # @return [String] the product name of this Swift package. + # + attribute :product_name, String + end + end + end +end diff --git a/lib/xcodeproj/project/object/swift_package_remote_reference.rb b/lib/xcodeproj/project/object/swift_package_remote_reference.rb new file mode 100644 index 000000000..a70d68427 --- /dev/null +++ b/lib/xcodeproj/project/object/swift_package_remote_reference.rb @@ -0,0 +1,19 @@ +module Xcodeproj + class Project + module Object + # This class represents a Swift package reference. + # + class XCRemoteSwiftPackageReference < AbstractObject + # @!group Attributes + + # @return [String] the repository url this Swift package was installed from. + # + attribute :repositoryURL, String + + # @return [Hash] the version requirements for this Swift package. + # + attribute :requirement, Hash + end + end + end +end diff --git a/spec/fixtures/Sample Project/Cocoa Application.xcodeproj/xcshareddata/xcschemes/iOS application and static library.xcscheme b/spec/fixtures/Sample Project/Cocoa Application.xcodeproj/xcshareddata/xcschemes/iOS application and static library.xcscheme index f5151aeda..4e9d2e105 100644 --- a/spec/fixtures/Sample Project/Cocoa Application.xcodeproj/xcshareddata/xcschemes/iOS application and static library.xcscheme +++ b/spec/fixtures/Sample Project/Cocoa Application.xcodeproj/xcshareddata/xcschemes/iOS application and static library.xcscheme @@ -1,6 +1,6 @@