Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
f97d247c
Commit
f97d247c
authored
May 22, 2017
by
Dimitris Koutsogiorgas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only check for valid Swift version for pod targets that use Swift
parent
80334c51
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
68 deletions
+103
-68
CHANGELOG.md
CHANGELOG.md
+4
-0
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+0
-34
target_validator.rb
lib/cocoapods/installer/xcode/target_validator.rb
+19
-0
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+0
-34
target_validator_spec.rb
spec/unit/installer/xcode/target_validator_spec.rb
+80
-0
No files found.
CHANGELOG.md
View file @
f97d247c
...
@@ -18,6 +18,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -18,6 +18,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
##### Bug Fixes
*
Only check for valid Swift version for pod targets that use Swift
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6733
](
https://github.com/CocoaPods/CocoaPods/pull/6733
)
*
Fix pod install error from 1.2.1 when working with static lib-only projects.
*
Fix pod install error from 1.2.1 when working with static lib-only projects.
[
Ben Asher
](
https://github.com/benasher44
)
[
Ben Asher
](
https://github.com/benasher44
)
[
#6673
](
https://github.com/CocoaPods/CocoaPods/issues/6673
)
[
#6673
](
https://github.com/CocoaPods/CocoaPods/issues/6673
)
...
...
lib/cocoapods/installer/analyzer.rb
View file @
f97d247c
...
@@ -367,7 +367,6 @@ module Pod
...
@@ -367,7 +367,6 @@ module Pod
#
#
def
generate_targets
def
generate_targets
specs_by_target
=
result
.
specs_by_target
.
reject
{
|
td
,
_
|
td
.
abstract?
}
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
)
pod_targets
=
generate_pod_targets
(
specs_by_target
)
aggregate_targets
=
specs_by_target
.
keys
.
map
do
|
target_definition
|
aggregate_targets
=
specs_by_target
.
keys
.
map
do
|
target_definition
|
generate_target
(
target_definition
,
pod_targets
)
generate_target
(
target_definition
,
pod_targets
)
...
@@ -435,39 +434,6 @@ module Pod
...
@@ -435,39 +434,6 @@ module Pod
target
target
end
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
# Setup the pod targets for an aggregate target. Deduplicates resulting
# targets by grouping by platform and subspec by their root
# targets by grouping by platform and subspec by their root
# to create a {PodTarget} for each spec.
# to create a {PodTarget} for each spec.
...
...
lib/cocoapods/installer/xcode/target_validator.rb
View file @
f97d247c
...
@@ -34,6 +34,7 @@ module Pod
...
@@ -34,6 +34,7 @@ module Pod
def
validate!
def
validate!
verify_no_duplicate_framework_and_library_names
verify_no_duplicate_framework_and_library_names
verify_no_static_framework_transitive_dependencies
verify_no_static_framework_transitive_dependencies
verify_no_pods_used_with_multiple_swift_versions
verify_framework_usage
verify_framework_usage
end
end
...
@@ -84,6 +85,24 @@ module Pod
...
@@ -84,6 +85,24 @@ module Pod
end
end
end
end
def
verify_no_pods_used_with_multiple_swift_versions
error_message_for_target
=
lambda
do
|
target
|
"
#{
target
.
name
}
(Swift
#{
target
.
swift_version
}
)"
end
swift_pod_targets
=
pod_targets
.
select
(
&
:uses_swift?
)
error_messages
=
swift_pod_targets
.
map
do
|
pod_target
|
swift_target_definitions
=
pod_target
.
target_definitions
.
reject
{
|
target
|
target
.
swift_version
.
blank?
}
next
if
swift_target_definitions
.
empty?
||
swift_target_definitions
.
uniq
(
&
:swift_version
).
count
==
1
target_errors
=
swift_target_definitions
.
map
(
&
error_message_for_target
).
join
(
', '
)
"-
#{
pod_target
.
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
def
verify_framework_usage
def
verify_framework_usage
aggregate_targets
.
each
do
|
aggregate_target
|
aggregate_targets
.
each
do
|
aggregate_target
|
next
if
aggregate_target
.
requires_frameworks?
next
if
aggregate_target
.
requires_frameworks?
...
...
spec/unit/installer/analyzer_spec.rb
View file @
f97d247c
...
@@ -662,40 +662,6 @@ module Pod
...
@@ -662,40 +662,6 @@ module Pod
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
should
.
raise
(
Informative
)
{
analyzer
.
analyze
}
end
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
it
'computes the state of the Sandbox respect to the resolved dependencies'
do
...
...
spec/unit/installer/xcode/target_validator_spec.rb
View file @
f97d247c
...
@@ -143,6 +143,86 @@ module Pod
...
@@ -143,6 +143,86 @@ module Pod
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
describe
'#verify_no_pods_used_with_multiple_swift_versions'
do
it
'raises when targets integrate the same swift pod but have different swift versions'
do
fixture_path
=
ROOT
+
'spec/fixtures'
config
.
repos_dir
=
fixture_path
+
'spec-repos'
podfile
=
Podfile
.
new
do
project
'SampleProject/SampleProject'
platform
:ios
,
'8.0'
use_frameworks!
pod
'OrangeFramework'
,
:path
=>
(
fixture_path
+
'orange-framework'
).
to_s
pod
'matryoshka'
,
:path
=>
(
fixture_path
+
'matryoshka'
).
to_s
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'
)
orangeframework_pod_target
=
stub
(
:name
=>
'OrangeFramework'
,
:uses_swift?
=>
true
,
:target_definitions
=>
[
podfile
.
target_definitions
[
'SampleProject'
],
podfile
.
target_definitions
[
'TestRunner'
]])
matryoshka_pod_target
=
stub
(
:name
=>
'matryoshka'
,
:uses_swift?
=>
false
,
:target_definitions
=>
[
podfile
.
target_definitions
[
'SampleProject'
],
podfile
.
target_definitions
[
'TestRunner'
]])
@validator
=
TargetValidator
.
new
([],
[
orangeframework_pod_target
,
matryoshka_pod_target
])
e
=
should
.
raise
Informative
do
@validator
.
validate!
end
e
.
message
.
should
.
match
/The following pods are integrated into targets that do not have the same Swift version:/
e
.
message
.
should
.
include
'OrangeFramework required by SampleProject (Swift 3.0), TestRunner (Swift 2.3)'
e
.
message
.
should
.
not
.
include
'matryoshka required by SampleProject (Swift 3.0), TestRunner (Swift 2.3)'
end
it
'does not raise when targets integrate the same pod but only one of the targets is a swift target'
do
fixture_path
=
ROOT
+
'spec/fixtures'
config
.
repos_dir
=
fixture_path
+
'spec-repos'
podfile
=
Podfile
.
new
do
project
'SampleProject/SampleProject'
use_frameworks!
platform
:ios
,
'8.0'
pod
'OrangeFramework'
,
:path
=>
(
fixture_path
+
'orange-framework'
).
to_s
pod
'matryoshka'
,
:path
=>
(
fixture_path
+
'matryoshka'
).
to_s
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
)
orangeframework_pod_target
=
stub
(
:name
=>
'OrangeFramework'
,
:uses_swift?
=>
true
,
:target_definitions
=>
[
podfile
.
target_definitions
[
'SampleProject'
],
podfile
.
target_definitions
[
'TestRunner'
]])
matryoshka_pod_target
=
stub
(
:name
=>
'matryoshka'
,
:uses_swift?
=>
true
,
:target_definitions
=>
[
podfile
.
target_definitions
[
'SampleProject'
],
podfile
.
target_definitions
[
'TestRunner'
]])
@validator
=
TargetValidator
.
new
([],
[
orangeframework_pod_target
,
matryoshka_pod_target
])
lambda
{
@validator
.
validate!
}.
should
.
not
.
raise
end
it
'does not raise when targets integrate the same pod but none of the pod targets use swift'
do
fixture_path
=
ROOT
+
'spec/fixtures'
config
.
repos_dir
=
fixture_path
+
'spec-repos'
podfile
=
Podfile
.
new
do
project
'SampleProject/SampleProject'
use_frameworks!
platform
:ios
,
'8.0'
pod
'OrangeFramework'
,
:path
=>
(
fixture_path
+
'orange-framework'
).
to_s
pod
'matryoshka'
,
:path
=>
(
fixture_path
+
'matryoshka'
).
to_s
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'
)
# Pretend none of the pod targets use swift, even if the target definitions they are linked with do have different Swift versions.
orangeframework_pod_target
=
stub
(
:name
=>
'OrangeFramework'
,
:uses_swift?
=>
false
,
:target_definitions
=>
[
podfile
.
target_definitions
[
'SampleProject'
],
podfile
.
target_definitions
[
'TestRunner'
]])
matryoshka_pod_target
=
stub
(
:name
=>
'matryoshka'
,
:uses_swift?
=>
false
,
:target_definitions
=>
[
podfile
.
target_definitions
[
'SampleProject'
],
podfile
.
target_definitions
[
'TestRunner'
]])
@validator
=
TargetValidator
.
new
([],
[
orangeframework_pod_target
,
matryoshka_pod_target
])
lambda
{
@validator
.
validate!
}.
should
.
not
.
raise
end
end
#-------------------------------------------------------------------------#
describe
'#verify_framework_usage'
do
describe
'#verify_framework_usage'
do
it
'raises when Swift pods are used without explicit `use_frameworks!`'
do
it
'raises when Swift pods are used without explicit `use_frameworks!`'
do
fixture_path
=
ROOT
+
'spec/fixtures'
fixture_path
=
ROOT
+
'spec/fixtures'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment