Skip to content

Commit

Permalink
Add framework fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
JavanPoirier committed Sep 24, 2020
1 parent fe1ce4f commit c7a385f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 31 deletions.
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

0 comments on commit c7a385f

Please sign in to comment.