From c7a385fe14d914304926623ccb99c25ef27b2570 Mon Sep 17 00:00:00 2001 From: Javan Poirier Date: Thu, 24 Sep 2020 13:02:03 -0400 Subject: [PATCH] Add framework fixes. --- README.md | 6 +++++- lib/xcodeproj/constants.rb | 16 ---------------- lib/xcodeproj/project/object/native_target.rb | 15 ++++++++++----- lib/xcodeproj/project/project_helper.rb | 6 ------ spec/project/object/native_target_spec.rb | 3 --- 5 files changed, 15 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 60412a9f8..795d172f3 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,11 @@ use to generate project diffs, target diffs, output all configurations and show For more information consult `xcodeproj --help`. +## Building/Installing Locally + +To build locally run `gem build xcodeproj.gemspec`. You can then install the gem locally replacing +`*` with your specific gem's version `gem install xcodeproj-*.gem` + ## Collaborate All Xcodeproj development happens on [GitHub][xcodeproj]. Contributing patches @@ -81,7 +86,6 @@ is really easy and gratifying. Follow [@CocoaPods][twitter] to get up to date information about what's going on in the CocoaPods world. - ## LICENSE These works are available under the MIT license. See the [LICENSE][license] file diff --git a/lib/xcodeproj/constants.rb b/lib/xcodeproj/constants.rb index 7eacbb234..2da7cfd20 100644 --- a/lib/xcodeproj/constants.rb +++ b/lib/xcodeproj/constants.rb @@ -2,22 +2,6 @@ module Xcodeproj # This modules groups all the constants known to Xcodeproj. # module Constants - # @return [String] The last known iOS SDK (stable). - # - LAST_KNOWN_IOS_SDK = '12.2' - - # @return [String] The last known OS X SDK (stable). - # - LAST_KNOWN_OSX_SDK = '10.14' - - # @return [String] The last known tvOS SDK (stable). - # - LAST_KNOWN_TVOS_SDK = '12.2' - - # @return [String] The last known watchOS SDK (stable). - # - LAST_KNOWN_WATCHOS_SDK = '5.2' - # @return [String] The last known archive version to Xcodeproj. # LAST_KNOWN_ARCHIVE_VERSION = 1 diff --git a/lib/xcodeproj/project/object/native_target.rb b/lib/xcodeproj/project/object/native_target.rb index b9d36641f..5e2a79ee7 100644 --- a/lib/xcodeproj/project/object/native_target.rb +++ b/lib/xcodeproj/project/object/native_target.rb @@ -316,6 +316,11 @@ def new_shell_script_build_phase(name = nil) # @param [Array, String] names # The name or the list of the names of the framework. # + # @param [String] sdk + # Optional version of the sdk you are adding the SDK for. If + # left empty the path will not include the SDK version as + # newer version of xcode use a symbolic link. + # # @note Xcode behaviour is following: if the target has the same SDK # of the project it adds the reference relative to the SDK root # otherwise the reference is added relative to the Developer @@ -327,29 +332,29 @@ def new_shell_script_build_phase(name = nil) # @return [Array] An array of the newly created file # references. # - def add_system_framework(names) + def add_system_framework(names, sdk = "") Array(names).map do |name| case platform_name when :ios group = project.frameworks_group['iOS'] || project.frameworks_group.new_group('iOS') path_sdk_name = 'iPhoneOS' - path_sdk_version = sdk_version || Constants::LAST_KNOWN_IOS_SDK when :osx group = project.frameworks_group['OS X'] || project.frameworks_group.new_group('OS X') path_sdk_name = 'MacOSX' - path_sdk_version = sdk_version || Constants::LAST_KNOWN_OSX_SDK when :tvos group = project.frameworks_group['tvOS'] || project.frameworks_group.new_group('tvOS') path_sdk_name = 'AppleTVOS' - path_sdk_version = sdk_version || Constants::LAST_KNOWN_TVOS_SDK when :watchos group = project.frameworks_group['watchOS'] || project.frameworks_group.new_group('watchOS') path_sdk_name = 'WatchOS' - path_sdk_version = sdk_version || Constants::LAST_KNOWN_WATCHOS_SDK else raise 'Unknown platform for target' end + if (sdk != "") + path_sdk_version = sdk + end + path = "Platforms/#{path_sdk_name}.platform/Developer/SDKs/#{path_sdk_name}#{path_sdk_version}.sdk/System/Library/Frameworks/#{name}.framework" unless ref = group.find_file_by_path(path) ref = group.new_file(path, :developer_dir) diff --git a/lib/xcodeproj/project/project_helper.rb b/lib/xcodeproj/project/project_helper.rb index 77eac8e64..1fe4420f9 100644 --- a/lib/xcodeproj/project/project_helper.rb +++ b/lib/xcodeproj/project/project_helper.rb @@ -57,12 +57,6 @@ def self.new_target(project, type, name, platform, deployment_target, product_gr # Build phases build_phases_for_target_type(type).each { |phase| target.build_phases << project.new(phase) } - # Frameworks - unless type == :static_library - framework_name = (platform == :osx) ? 'Cocoa' : 'Foundation' - target.add_system_framework(framework_name) - end - target end diff --git a/spec/project/object/native_target_spec.rb b/spec/project/object/native_target_spec.rb index b30d2e827..1bea8544f 100644 --- a/spec/project/object/native_target_spec.rb +++ b/spec/project/object/native_target_spec.rb @@ -602,21 +602,18 @@ module ProjectSpecs @target.build_configuration_list.set_setting('SDKROOT', 'iphoneos') @target.add_system_framework('QuartzCore') file = @project['Frameworks/iOS'].files.first - file.path.scan(/\d\d\.\d/).first.should == Xcodeproj::Constants::LAST_KNOWN_IOS_SDK end it 'uses the last known tvOS SDK version if none is specified in the target' do @target.build_configuration_list.set_setting('SDKROOT', 'appletvos') @target.add_system_framework('TVServices') file = @project['Frameworks/tvOS'].files.first - file.path.scan(/\d\d\.\d/).first.should == Xcodeproj::Constants::LAST_KNOWN_TVOS_SDK end it 'uses the last known watchOS SDK version if none is specified in the target' do @target.build_configuration_list.set_setting('SDKROOT', 'watchos') @target.add_system_framework('WatchConnectivity') file = @project['Frameworks/watchOS'].files.first - file.path.scan(/\d\.\d/).first.should == Xcodeproj::Constants::LAST_KNOWN_WATCHOS_SDK end it "doesn't duplicate references to a frameworks if one already exists" do