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
37b51075
Commit
37b51075
authored
May 11, 2018
by
Dimitris Koutsogiorgas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to parse `SWIFT_VERSION` from xcconfig during target inspection
parent
738c5712
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
1 deletion
+56
-1
CHANGELOG.md
CHANGELOG.md
+4
-0
target_inspector.rb
lib/cocoapods/installer/analyzer/target_inspector.rb
+8
-1
target_inspector_spec.rb
spec/unit/installer/analyzer/target_inspector_spec.rb
+44
-0
No files found.
CHANGELOG.md
View file @
37b51075
...
@@ -32,6 +32,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -32,6 +32,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#7394
](
https://github.com/CocoaPods/CocoaPods/issues/7394
)
[
#7394
](
https://github.com/CocoaPods/CocoaPods/issues/7394
)
*
Attempt to parse
`SWIFT_VERSION`
from xcconfig during target inspection
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#7731
](
https://github.com/CocoaPods/CocoaPods/issues/7731
)
*
Do not crash when creating build settings for a missing user build configuration
*
Do not crash when creating build settings for a missing user build configuration
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#7698
](
https://github.com/CocoaPods/CocoaPods/pull/7698
)
[
#7698
](
https://github.com/CocoaPods/CocoaPods/pull/7698
)
...
...
lib/cocoapods/installer/analyzer/target_inspector.rb
View file @
37b51075
...
@@ -218,7 +218,14 @@ module Pod
...
@@ -218,7 +218,14 @@ module Pod
#
#
def
compute_swift_version_from_targets
(
targets
)
def
compute_swift_version_from_targets
(
targets
)
versions_to_targets
=
targets
.
inject
({})
do
|
memo
,
target
|
versions_to_targets
=
targets
.
inject
({})
do
|
memo
,
target
|
versions
=
target
.
resolved_build_setting
(
'SWIFT_VERSION'
).
values
# User project may have an xcconfig that specifies the `SWIFT_VERSION`. We first check if that is true and
# that the xcconfig file actually exists. After the first integration the xcconfig set is most probably
# the one that was generated from CocoaPods. See https://github.com/CocoaPods/CocoaPods/issues/7731 for
# more details.
resolve_against_xcconfig
=
target
.
build_configuration_list
.
build_configurations
.
all?
do
|
bc
|
!
bc
.
base_configuration_reference
.
nil?
&&
File
.
exist?
(
bc
.
base_configuration_reference
.
real_path
)
end
versions
=
target
.
resolved_build_setting
(
'SWIFT_VERSION'
,
resolve_against_xcconfig
).
values
versions
.
each
do
|
version
|
versions
.
each
do
|
version
|
memo
[
version
]
=
[]
if
memo
[
version
].
nil?
memo
[
version
]
=
[]
if
memo
[
version
].
nil?
memo
[
version
]
<<
target
.
name
unless
memo
[
version
].
include?
target
.
name
memo
[
version
]
<<
target
.
name
unless
memo
[
version
].
include?
target
.
name
...
...
spec/unit/installer/analyzer/target_inspector_spec.rb
View file @
37b51075
...
@@ -363,6 +363,50 @@ module Pod
...
@@ -363,6 +363,50 @@ module Pod
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
target_inspector
.
send
(
:compute_swift_version_from_targets
,
user_targets
).
should
.
equal
'2.3'
target_inspector
.
send
(
:compute_swift_version_from_targets
,
user_targets
).
should
.
equal
'2.3'
end
end
describe
'with user xcconfig set'
do
before
do
@user_xcconfig
=
'User.xcconfig'
end
after
do
FileUtils
.
rm_f
(
@user_xcconfig
)
if
File
.
exist?
(
@user_xcconfig
)
end
it
'returns the xcconfig-level SWIFT_VERSION if the target has an existing user xcconfig set'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
.
build_configuration_list
.
set_setting
(
'SWIFT_VERSION'
,
'2.3'
)
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
sample_config
=
user_project
.
new_file
(
@user_xcconfig
)
File
.
write
(
sample_config
.
real_path
,
'SWIFT_VERSION=3.0'
)
target
.
build_configurations
.
each
do
|
config
|
config
.
base_configuration_reference
=
sample_config
end
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target
]
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
target_inspector
.
send
(
:compute_swift_version_from_targets
,
user_targets
).
should
.
equal
'3.0'
end
it
'skips the xcconfig-level SWIFT_VERSION if the target has an existing user xcconfig set but without it'
do
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
user_project
.
build_configuration_list
.
set_setting
(
'SWIFT_VERSION'
,
'2.3'
)
target
=
user_project
.
new_target
(
:application
,
'Target'
,
:ios
)
sample_config
=
user_project
.
new_file
(
@user_xcconfig
)
File
.
write
(
sample_config
.
real_path
,
'SOMETHING_ELSE=3.0'
)
target
.
build_configurations
.
each
do
|
config
|
config
.
base_configuration_reference
=
sample_config
end
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target
]
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
target_inspector
.
send
(
:compute_swift_version_from_targets
,
user_targets
).
should
.
equal
'2.3'
end
end
end
end
end
end
end
end
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