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
2574fba9
Unverified
Commit
2574fba9
authored
Oct 10, 2016
by
Danielle Tomlinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AggregateXcconfig] Only use EMBEDDED_CONTENT_CONTAINS_SWIFT on Swift < 2.3
parent
b1094a8a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
16 deletions
+57
-16
aggregate_xcconfig.rb
lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb
+37
-14
aggregate_xcconfig_spec.rb
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
+20
-2
No files found.
lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb
View file @
2574fba9
...
...
@@ -60,20 +60,8 @@ module Pod
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'$(inherited) COCOAPODS=1'
,
'FRAMEWORK_SEARCH_PATHS'
=>
'$(inherited) '
,
'LIBRARY_SEARCH_PATHS'
=>
'$(inherited) '
,
}
# For embedded targets, which live in a host target, CocoaPods
# copies all of the embedded target's pod_targets its host
# target. Therefore, this check will properly require the Swift
# libs in the host target, if the embedded target has any pod targets
# that use Swift. Setting this for the embedded target would
# cause an App Store rejection because frameworks cannot be embedded
# in embedded targets.
if
!
target
.
requires_host_target?
&&
pod_targets
.
any?
(
&
:uses_swift?
)
config
[
'EMBEDDED_CONTENT_CONTAINS_SWIFT'
]
=
'YES'
config
[
'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'
]
=
'YES'
else
config
[
'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'
]
=
'NO'
end
}.
merge
(
embedded_content_settings
)
@xcconfig
=
Xcodeproj
::
Config
.
new
(
config
)
@xcconfig
.
merge!
(
merged_user_target_xcconfigs
)
...
...
@@ -100,6 +88,41 @@ module Pod
protected
def
target_swift_version
settings
=
target
.
native_target
.
resolved_build_setting
(
'SWIFT_VERSION'
)
unless
target
.
native_target
.
nil?
settings
.
values
.
compact
.
uniq
.
first
unless
settings
.
nil?
end
EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
=
Gem
::
Version
.
new
(
'2.3'
)
# @return [Hash<String, String>] the build settings necessary for Swift
# targets to be correctly embedded in their host.
#
def
embedded_content_settings
# For embedded targets, which live in a host target, CocoaPods
# copies all of the embedded target's pod_targets its host
# target. Therefore, this check will properly require the Swift
# libs in the host target, if the embedded target has any pod targets
# that use Swift. Setting this for the embedded target would
# cause an App Store rejection because frameworks cannot be embedded
# in embedded targets.
swift_version
=
Gem
::
Version
.
new
(
target_swift_version
)
should_embed
=
!
target
.
requires_host_target?
&&
pod_targets
.
any?
(
&
:uses_swift?
)
embed_value
=
should_embed
?
'YES'
:
'NO'
config
=
{
'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'
=>
embed_value
,
'EMBEDDED_CONTENT_CONTAINS_SWIFT'
=>
embed_value
,
}
if
swift_version
>=
EMBED_STANDARD_LIBRARIES_MINIMUM_VERSION
||
!
should_embed
config
.
delete
(
'EMBEDDED_CONTENT_CONTAINS_SWIFT'
)
end
config
end
# @return [Hash<String, String>] the build settings necessary to import
# the pod targets.
#
...
...
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
View file @
2574fba9
...
...
@@ -241,37 +241,55 @@ module Pod
@xcconfig
.
to_hash
[
'OTHER_SWIFT_FLAGS'
].
should
.
include
'$(inherited) "-D" "COCOAPODS"'
end
it
'sets EMBEDDED_CONTENT_CONTAINS_SWIFT when the
re is swift
'
do
it
'sets EMBEDDED_CONTENT_CONTAINS_SWIFT when the
target_swift_version is < 2.3
'
do
@generator
.
send
(
:pod_targets
).
first
.
stubs
(
:uses_swift?
).
returns
(
true
)
@generator
.
stubs
(
:target_swift_version
).
returns
(
'2.2'
)
@generator
.
generate
.
to_hash
[
'EMBEDDED_CONTENT_CONTAINS_SWIFT'
].
should
==
'YES'
end
it
'does not set EMBEDDED_CONTENT_CONTAINS_SWIFT when there is no swift'
do
@generator
.
send
(
:pod_targets
).
each
{
|
pt
|
pt
.
stubs
(
:uses_swift?
).
returns
(
false
)
}
@generator
.
stubs
(
:target_swift_version
).
returns
(
'2.2'
)
@generator
.
generate
.
to_hash
[
'EMBEDDED_CONTENT_CONTAINS_SWIFT'
].
should
.
be
.
nil
end
it
'does not set EMBEDDED_CONTENT_CONTAINS_SWIFT when there is swift, but the target is an extension'
do
@target
.
stubs
(
:requires_host_target?
).
returns
(
true
)
@generator
.
stubs
(
:target_swift_version
).
returns
(
'2.2'
)
@generator
.
send
(
:pod_targets
).
first
.
stubs
(
:uses_swift?
).
returns
(
true
)
@generator
.
generate
.
to_hash
[
'EMBEDDED_CONTENT_CONTAINS_SWIFT'
].
should
.
be
.
nil
end
it
'sets
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES when there is swift
'
do
it
'sets
EMBEDDED_CONTENT_CONTAINS_SWIFT when the target_swift_version is nil
'
do
@generator
.
send
(
:pod_targets
).
first
.
stubs
(
:uses_swift?
).
returns
(
true
)
@generator
.
stubs
(
:target_swift_version
).
returns
(
nil
)
@generator
.
generate
.
to_hash
[
'EMBEDDED_CONTENT_CONTAINS_SWIFT'
].
should
==
'YES'
end
it
'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES when there is swift >= 2.3'
do
@generator
.
send
(
:pod_targets
).
first
.
stubs
(
:uses_swift?
).
returns
(
true
)
@generator
.
stubs
(
:target_swift_version
).
returns
(
'2.3'
)
@generator
.
generate
.
to_hash
[
'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'
].
should
==
'YES'
end
it
'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO when there is no swift'
do
@generator
.
send
(
:pod_targets
).
first
.
stubs
(
:uses_swift?
).
returns
(
false
)
@generator
.
stubs
(
:target_swift_version
).
returns
(
nil
)
@generator
.
generate
.
to_hash
[
'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'
].
should
==
'NO'
end
it
'sets ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO when there is swift, but the target is an extension'
do
@target
.
stubs
(
:requires_host_target?
).
returns
(
true
)
@generator
.
stubs
(
:target_swift_version
).
returns
(
'2.3'
)
@generator
.
send
(
:pod_targets
).
first
.
stubs
(
:uses_swift?
).
returns
(
true
)
@generator
.
generate
.
to_hash
[
'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'
].
should
==
'NO'
end
it
'does not set EMBEDDED_CONTENT_CONTAINS_SWIFT when there is swift 2.3 or higher'
do
@generator
.
send
(
:pod_targets
).
first
.
stubs
(
:uses_swift?
).
returns
(
true
)
@generator
.
stubs
(
:target_swift_version
).
returns
(
'2.3'
)
@generator
.
generate
.
to_hash
.
key?
(
'EMBEDDED_CONTENT_CONTAINS_SWIFT'
).
should
==
false
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