Commit 7cbc243f authored by Stephen Hayes's avatar Stephen Hayes

Merge remote-tracking branch 'CocoaPods/master'

parents 88c43965 b6143c3e
......@@ -11,8 +11,12 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
* Cache result of inhibit_warnings and include_in_build_config to speed up pod install.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#5934](https://github.com/CocoaPods/CocoaPods/pull/5934)
* Improve performance of PathList.read_file_system
* Tell users about the .swift-version file on validation failures.
[Danielle Tomlinson](https://github.com/dantoml)
[#5951](https://github.com/CocoaPods/CocoaPods/pull/5951)
* Improve performance of PathList.read_file_system
[Heath Borders](https://github.com/hborders)
[#5890](https://github.com/CocoaPods/CocoaPods/issues/5890)
......@@ -23,6 +27,21 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
* Greenify pod install success message
[Stephen Hayes](https://github.com/schayes04)
[#5713](https://github.com/CocoaPods/CocoaPods/issues/5713)
* Remove uses of `cd` in generated scripts
[Ben Asher](https://github.com/benasher44)
[#5959](https://github.com/CocoaPods/CocoaPods/pull/5959)
* Error with helpful message when integrating a pod into targets that have mismatched Swift versions.
[Ben Asher](https://github.com/benasher44)
[#5984](https://github.com/CocoaPods/CocoaPods/pull/5984)
* Allow users to share pods between Objective-C and Swift targets.
[Danielle Tomlinson](https://github.com/dantoml)
[#5984](https://github.com/CocoaPods/CocoaPods/pull/5984)
* Allow setting the linting Swift version via `--swift-version=VERSION`
[Danielle Tomlinson](https://github.com/dantoml)
[#5989](https://github.com/CocoaPods/CocoaPods/pull/5989)
##### Bug Fixes
......@@ -34,6 +53,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Ben Asher](https://github.com/benasher44)
[#5860](https://github.com/CocoaPods/CocoaPods/issues/5860)
* Fix linting of private pods when using libraries.
[Stefan Pühringer](https://github.com/b-ray)
[#5891](https://github.com/CocoaPods/CocoaPods/issues/5891)
## 1.1.0.rc.2 (2016-09-13)
##### Enhancements
......
GIT
remote: https://github.com/CocoaPods/CLAide.git
revision: 61071679fc965083b6d43fdc1aa042afbaf172d1
revision: 8106d0d779ae1c9f571404a9f38950905ad5c803
branch: master
specs:
claide (1.0.0)
GIT
remote: https://github.com/CocoaPods/Core.git
revision: fc8c258d0bce73e091f09de260a1a65bed3482a1
revision: fef34047643147b09955f8aeb1277a47d01ff1c1
branch: master
specs:
cocoapods-core (1.1.0.rc.2)
......@@ -24,7 +24,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: c8b7277072c3c2432ac99ef9b45cd1a6d181409e
revision: 4020ac913be863bdc4925fbb132aa94af71850f4
branch: master
specs:
xcodeproj (1.3.1)
......
......@@ -178,7 +178,8 @@ begin
task :rebuild => :check_for_pending_changes do
tarballs.each do |tarball|
basename = File.basename(tarball)
sh "cd #{File.dirname(tarball)} && rm #{basename} && env COPYFILE_DISABLE=1 tar -zcf #{basename} #{basename[0..-8]}"
untarred_path = File.join(File.dirname(tarball), basename[0..-8])
sh "rm #{tarball} && env COPYFILE_DISABLE=1 tar -zcf #{tarball} #{untarred_path}"
end
end
......
......@@ -21,6 +21,8 @@ module Pod
'(defaults to https://github.com/CocoaPods/Specs.git). ' \
'Multiple sources must be comma-delimited.'],
['--private', 'Lint skips checks that apply only to public specs'],
['--swift-version=VERSION', 'The SWIFT_VERSION that should be used to lint the spec. ' \
'This takes precedence over a .swift-version file.'],
].concat(super)
end
......@@ -34,6 +36,7 @@ module Pod
@use_frameworks = !argv.flag?('use-libraries')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@private = argv.flag?('private', false)
@swift_version = argv.option('swift-version', nil)
@podspecs_paths = argv.arguments!
super
end
......@@ -55,6 +58,7 @@ module Pod
validator.only_subspec = @only_subspec
validator.use_frameworks = @use_frameworks
validator.ignore_public_only_results = @private
validator.swift_version = @swift_version
validator.validate
unless @clean
......
......@@ -27,6 +27,8 @@ module Pod
'(defaults to https://github.com/CocoaPods/Specs.git). ' \
'Multiple sources must be comma-delimited.'],
['--private', 'Lint skips checks that apply only to public specs'],
['--swift-version=VERSION', 'The SWIFT_VERSION that should be used to lint the spec. ' \
'This takes precedence over a .swift-version file.'],
].concat(super)
end
......@@ -40,6 +42,7 @@ module Pod
@use_frameworks = !argv.flag?('use-libraries')
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
@private = argv.flag?('private', false)
@swift_version = argv.option('swift-version', nil)
@podspecs_paths = argv.arguments!
super
end
......@@ -57,6 +60,7 @@ module Pod
validator.only_subspec = @only_subspec
validator.use_frameworks = @use_frameworks
validator.ignore_public_only_results = @private
validator.swift_version = @swift_version
validator.validate
failure_reasons << validator.failure_reason
......
......@@ -119,12 +119,6 @@ case "${TARGETED_DEVICE_FAMILY}" in
;;
esac
realpath() {
DIRECTORY="$(cd "${1%/*}" && pwd)"
FILENAME="${1##*/}"
echo "$DIRECTORY/$FILENAME"
}
install_resource()
{
if [[ "$1" = /* ]] ; then
......@@ -166,7 +160,7 @@ EOM
xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
;;
*.xcassets)
ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH")
ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH"
XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
;;
*)
......@@ -195,7 +189,7 @@ then
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
while read line; do
if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
if [[ $line != "${PODS_ROOT}*" ]]; then
XCASSET_FILES+=("$line")
fi
done <<<"$OTHER_XCASSETS"
......
......@@ -349,6 +349,7 @@ module Pod
#
def generate_targets
specs_by_target = result.specs_by_target.reject { |td, _| td.abstract? }
check_pod_target_swift_versions(specs_by_target)
pod_targets = generate_pod_targets(specs_by_target)
aggregate_targets = specs_by_target.keys.map do |target_definition|
generate_target(target_definition, pod_targets)
......@@ -406,6 +407,39 @@ module Pod
target
end
# Verify that targets using a pod have the same swift version
#
# @param [Hash{Podfile::TargetDefinition => Array<Specification>}] specs_by_target
# the resolved specifications grouped by target.
#
# @note raises Informative if targets using a pod do not have
# the same swift version
#
def check_pod_target_swift_versions(specs_by_target)
targets_by_spec = {}
specs_by_target.each do |target, specs|
specs.each do |spec|
(targets_by_spec[spec] ||= []) << target
end
end
error_message_for_target = lambda do |target|
"#{target.name} (Swift #{target.swift_version})"
end
error_messages = targets_by_spec.map do |spec, targets|
swift_targets = targets.reject { |target| target.swift_version.blank? }
next if swift_targets.empty? || swift_targets.uniq(&:swift_version).count == 1
target_errors = swift_targets.map(&error_message_for_target).join(', ')
"- #{spec.name} required by #{target_errors}"
end.compact
unless error_messages.empty?
raise Informative, 'The following pods are integrated into targets ' \
"that do not have the same Swift version:\n\n#{error_messages.join("\n")}"
end
end
# Setup the pod targets for an aggregate target. Deduplicates resulting
# targets by grouping by platform and subspec by their root
# to create a {PodTarget} for each spec.
......@@ -420,7 +454,7 @@ module Pod
distinct_targets = specs_by_target.each_with_object({}) do |dependency, hash|
target_definition, dependent_specs = *dependency
dependent_specs.group_by(&:root).each do |root_spec, specs|
pod_variant = PodVariant.new(specs, target_definition.platform, target_definition.uses_frameworks?, target_definition.swift_version)
pod_variant = PodVariant.new(specs, target_definition.platform, target_definition.uses_frameworks?)
hash[root_spec] ||= {}
(hash[root_spec][pod_variant] ||= []) << target_definition
end
......
......@@ -16,10 +16,6 @@ module Pod
attr_accessor :requires_frameworks
alias_method :requires_frameworks?, :requires_frameworks
# @return [String] the Swift version
#
attr_accessor :swift_version
# @return [Specification] the root specification
#
def root_spec
......@@ -32,11 +28,10 @@ module Pod
# @param [Platform] platform @see #platform
# @param [Bool] requires_frameworks @see #requires_frameworks?
#
def initialize(specs, platform, requires_frameworks = false, swift_version = nil)
def initialize(specs, platform, requires_frameworks = false)
self.specs = specs
self.platform = platform
self.requires_frameworks = requires_frameworks
self.swift_version = swift_version
end
# @return [Bool] whether the {PodVariant} is equal to another taking all
......@@ -46,8 +41,7 @@ module Pod
self.class == other.class &&
specs == other.specs &&
platform == other.platform &&
requires_frameworks == other.requires_frameworks &&
swift_version == other.swift_version
requires_frameworks == other.requires_frameworks
end
alias_method :eql?, :==
......@@ -57,7 +51,7 @@ module Pod
#
# @!visibility private
def hash
[specs, platform, requires_frameworks, swift_version].hash
[specs, platform, requires_frameworks].hash
end
end
end
......
......@@ -241,9 +241,9 @@ module Pod
build_phase = native_target.new_shell_script_build_phase('Create Symlinks to Header Folders')
build_phase.shell_script = <<-eos.strip_heredoc
cd "$CONFIGURATION_BUILD_DIR/$WRAPPER_NAME"
ln -fs ${PUBLIC_HEADERS_FOLDER_PATH\#$WRAPPER_NAME/} ${PUBLIC_HEADERS_FOLDER_PATH\#\$CONTENTS_FOLDER_PATH/}
ln -fs ${PRIVATE_HEADERS_FOLDER_PATH\#\$WRAPPER_NAME/} ${PRIVATE_HEADERS_FOLDER_PATH\#\$CONTENTS_FOLDER_PATH/}
base="$CONFIGURATION_BUILD_DIR/$WRAPPER_NAME"
ln -fs $base/${PUBLIC_HEADERS_FOLDER_PATH\#$WRAPPER_NAME/} $base/${PUBLIC_HEADERS_FOLDER_PATH\#\$CONTENTS_FOLDER_PATH/}
ln -fs $base/${PRIVATE_HEADERS_FOLDER_PATH\#\$WRAPPER_NAME/} $base/${PRIVATE_HEADERS_FOLDER_PATH\#\$CONTENTS_FOLDER_PATH/}
eos
end
......
......@@ -72,11 +72,11 @@ module Pod
#
def add_files(namespace, relative_header_paths)
relative_header_paths.map do |relative_header_path|
add_file(namespace, relative_header_path, relative_header_path.basename)
add_file(namespace, relative_header_path)
end
end
# Adds a header to the directory under different name.
# Adds a header to the directory.
#
# @param [Pathname] namespace
# the path where the header file should be stored relative to the
......@@ -86,23 +86,17 @@ module Pod
# the path of the header file relative to the Pods project
# (`PODS_ROOT` variable of the xcconfigs).
#
# @param [String] final_name
# the name under which the file should be available in the
# headers directory.
#
# @note This method does _not_ add the file to the search paths.
#
# @return [Pathname]
#
def add_file(namespace, relative_header_path, final_name)
def add_file(namespace, relative_header_path)
namespaced_path = root + namespace
namespaced_path.mkpath unless File.exist?(namespaced_path)
absolute_source = (sandbox.root + relative_header_path)
source = absolute_source.relative_path_from(namespaced_path)
Dir.chdir(namespaced_path) do
FileUtils.ln_sf(source, final_name)
end
FileUtils.ln_sf(source, namespaced_path)
namespaced_path + relative_header_path.basename
end
......
......@@ -142,7 +142,15 @@ module Pod
reasons << 'all results apply only to public specs, but you can use ' \
'`--private` to ignore them if linting the specification for a private pod'
end
reasons.to_sentence
if dot_swift_version.nil?
reasons.to_sentence + ".\n[!] The validator for Swift projects uses " \
'Swift 2.3 by default, if you are using a different version of ' \
'swift you can use a `.swift-version` file to set the version for ' \
"your Pod. For example to use Swift 3.0, run: \n" \
' `echo "3.0" > .swift-version`'
else
reasons.to_sentence
end
end
#-------------------------------------------------------------------------#
......@@ -243,6 +251,10 @@ module Pod
@swift_version ||= dot_swift_version || '2.3'
end
# Set the SWIFT_VERSION that should be used to validate the pod.
#
attr_writer :swift_version
# @return [String] the SWIFT_VERSION in the .swift-version file or nil.
#
def dot_swift_version
......
Subproject commit 6efec430148b581610f82f67947f0d12ebd62ce4
Subproject commit 261c576b588e6c8d9729cdbb9c4751f7b10f4ee7
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe PodVariant = Installer::Analyzer::PodVariant do
before do
@specs = [stub('Spec'), stub('Spec/Foo')]
@platform = Platform.ios
end
class Installer
class Analyzer
describe PodVariant do
before do
@specs = [stub('Spec'), stub('Spec/Foo')]
@platform = Platform.ios
end
it 'can be initialized with specs and platform' do
variant = PodVariant.new(@specs, @platform)
variant.specs.should == @specs
variant.platform.should == @platform
variant.requires_frameworks.should == false
variant.swift_version.should.nil?
end
it 'can be initialized with specs and platform' do
variant = PodVariant.new(@specs, @platform)
variant.specs.should == @specs
variant.platform.should == @platform
variant.requires_frameworks.should == false
end
it 'can be initialized with specs, platform and whether it requires frameworks' do
variant = PodVariant.new(@specs, @platform, true)
variant.specs.should == @specs
variant.platform.should == @platform
variant.requires_frameworks.should == true
variant.swift_version.should.nil?
end
it 'can be initialized with specs, platform and whether it requires frameworks' do
variant = PodVariant.new(@specs, @platform, true)
variant.specs.should == @specs
variant.platform.should == @platform
variant.requires_frameworks.should == true
end
it 'can be initialized with specs, platform, whether it requires frameworks, and a Swift version' do
variant = PodVariant.new(@specs, @platform, true, '2.3')
variant.specs.should == @specs
variant.platform.should == @platform
variant.requires_frameworks.should == true
variant.swift_version.should == '2.3'
end
it 'can return the root spec' do
spec = fixture_spec('banana-lib/BananaLib.podspec')
variant = PodVariant.new([spec], Platform.ios)
variant.root_spec.should == spec
end
it 'can return the root spec' do
spec = fixture_spec('banana-lib/BananaLib.podspec')
variant = PodVariant.new([spec], Platform.ios)
variant.root_spec.should == spec
end
it 'can be compared for equality with another variant with the same specs, platform, value for whether it requires frameworks and Swift version' do
spec = PodVariant.new(@specs, @platform, false, '2.3')
spec.should == PodVariant.new(@specs, @platform, false, '2.3')
spec.should.not == PodVariant.new(@specs, @platform, false, '3.0')
spec.should.not == PodVariant.new([@specs.first], @platform, false)
spec.should.not == PodVariant.new(@specs, Platform.osx, false, '2.3')
spec.should.not == PodVariant.new(@specs, @platform, true)
end
it 'can be compared for equality with another variant with the same specs, platform, and whether it requires frameworks' do
spec = PodVariant.new(@specs, @platform, false)
spec.should == PodVariant.new(@specs, @platform, false)
spec.should.not == PodVariant.new([@specs.first], @platform)
spec.should.not == PodVariant.new(@specs, Platform.osx, false)
spec.should.not == PodVariant.new(@specs, @platform, true)
end
it 'can be used as hash keys' do
k0 = PodVariant.new(@specs, @platform, false)
v0 = stub('Value at index 0')
k1 = PodVariant.new(@specs, @platform, true)
v1 = stub('Value at index 1')
hash = { k0 => v0, k1 => v1 }
hash[k0].should == v0
hash[k1].should == v1
it 'can be used as hash keys' do
k0 = PodVariant.new(@specs, @platform, false)
v0 = stub('Value at index 0')
k1 = PodVariant.new(@specs, @platform, true)
v1 = stub('Value at index 1')
hash = { k0 => v0, k1 => v1 }
hash[k0].should == v0
hash[k1].should == v1
end
end
end
end
end
......@@ -88,6 +88,7 @@ module Pod
FileUtils.mkdir_p(tmp_directory)
FileUtils.cp_r(ROOT + 'spec/fixtures/spec-repos/test_repo/', tmp_directory)
non_git_repo = tmp_directory + 'test_repo'
FileUtils.rm(non_git_repo + '.git')
podfile = Podfile.new do
platform :ios, '8.0'
......@@ -661,6 +662,40 @@ module Pod
should.raise(Informative) { analyzer.analyze }
end
it 'raises when targets integrate the same swift pod but have different swift versions' do
podfile = Podfile.new do
source SpecHelper.test_repo_url
project 'SampleProject/SampleProject'
platform :ios, '8.0'
pod 'OrangeFramework'
target 'SampleProject'
target 'TestRunner'
end
podfile.target_definitions['SampleProject'].stubs(:swift_version).returns('3.0')
podfile.target_definitions['TestRunner'].stubs(:swift_version).returns('2.3')
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile)
should.raise Informative do
analyzer.analyze
end.message.should.match /The following pods are integrated into targets that do not have the same Swift version:/
end
it 'does not raise when targets integrate the same pod but only one of the targets is a swift target' do
podfile = Podfile.new do
source SpecHelper.test_repo_url
project 'SampleProject/SampleProject'
platform :ios, '8.0'
pod 'OrangeFramework'
target 'SampleProject'
target 'TestRunner'
end
podfile.target_definitions['SampleProject'].stubs(:swift_version).returns('3.0')
# when the swift version is unset at the project level, but set in one target, swift_version is nil
podfile.target_definitions['TestRunner'].stubs(:swift_version).returns(nil)
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile)
lambda { analyzer.analyze }.should.not.raise
end
#--------------------------------------#
it 'computes the state of the Sandbox respect to the resolved dependencies' do
......
......@@ -812,6 +812,21 @@ module Pod
validator.results.count.should == 0
end
it 'tells users about the .swift-version file if the validation fails' do
Specification.any_instance.stubs(:deployment_target).returns('9.0')
validator = test_swiftpod
validator.stubs(:validated?).returns(false)
result = Validator::Result.new(:error, 'attribute', 'message')
validator.stubs(:results).returns([result])
validator.failure_reason.should == "1 error.\n[!] The validator for " \
'Swift projects uses Swift 2.3 by default, if you are using a ' \
'different version of swift you can use a `.swift-version` file ' \
'to set the version for your Pod. For example to use Swift 3.0, ' \
"run: \n `echo \"3.0\" > .swift-version`"
end
describe '#swift_version' do
it 'defaults to Swift 2.3' do
validator = test_swiftpod
......@@ -819,6 +834,13 @@ module Pod
validator.swift_version.should == '2.3'
end
it 'allows the user to set the version' do
validator = test_swiftpod
validator.stubs(:dot_swift_version).returns('3.0')
validator.swift_version = '4.0'
validator.swift_version.should == '4.0'
end
it 'checks for dot_swift_version' do
validator = test_swiftpod
validator.expects(:dot_swift_version)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment