Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved issues with add_system_framework and SDK version #786

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

##### Bug Fixes

* None.

* Resolved issues with `add_system_framework` and SDK version
[JavanPoirier](https://github.com/JavanPoirier)
[#786](https://github.com/CocoaPods/Xcodeproj/pull/786)

## 1.18.0 (2020-08-12)

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 0 additions & 16 deletions lib/xcodeproj/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions lib/xcodeproj/project/object/native_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ def new_shell_script_build_phase(name = nil)
# @param [Array<String>, 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
Expand All @@ -327,29 +332,29 @@ def new_shell_script_build_phase(name = nil)
# @return [Array<PBXFileReference>] 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)
Expand Down
6 changes: 0 additions & 6 deletions lib/xcodeproj/project/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions spec/project/object/native_target_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down