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
18abf36f
Commit
18abf36f
authored
Jun 28, 2014
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add methods to check if a target uses swift
parent
c81a7b27
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
0 deletions
+71
-0
aggregate_target.rb
lib/cocoapods/target/aggregate_target.rb
+6
-0
pod_target.rb
lib/cocoapods/target/pod_target.rb
+8
-0
spec_helper.rb
spec/spec_helper.rb
+9
-0
aggregate_target_spec.rb
spec/unit/target/aggregate_target_spec.rb
+26
-0
pod_target_spec.rb
spec/unit/target/pod_target_spec.rb
+22
-0
No files found.
lib/cocoapods/target/aggregate_target.rb
View file @
18abf36f
...
...
@@ -96,6 +96,12 @@ module Pod
specs
.
map
{
|
spec
|
spec
.
consumer
(
platform
)
}
end
# @return [Boolean] Whether the target uses Swift code
#
def
uses_swift?
pod_targets
.
any?
(
&
:uses_swift?
)
end
#-------------------------------------------------------------------------#
# @!group Support files
...
...
lib/cocoapods/target/pod_target.rb
View file @
18abf36f
...
...
@@ -54,6 +54,14 @@ module Pod
specs
.
map
{
|
spec
|
spec
.
consumer
(
platform
)
}
end
# @return [Boolean] Whether the target uses Swift code
#
def
uses_swift?
file_accessors
.
any?
do
|
file_accessor
|
file_accessor
.
source_files
.
any?
{
|
sf
|
sf
.
extname
==
".swift"
}
end
end
# @return [Specification] The root specification for the target.
#
def
root_spec
...
...
spec/spec_helper.rb
View file @
18abf36f
...
...
@@ -118,6 +118,15 @@ def fixture_file_accessor(name, platform = :ios)
Pod
::
Sandbox
::
FileAccessor
.
new
(
path_list
,
spec
.
consumer
(
platform
))
end
def
fixture_pod_target
(
name
,
platform
=
:ios
)
spec
=
fixture_spec
(
name
)
target_definition
=
Pod
::
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
Pod
::
PodTarget
.
new
([
spec
],
target_definition
,
config
.
sandbox
).
tap
do
|
pod_target
|
pod_target
.
stubs
(
:platform
).
returns
(
platform
)
pod_target
.
file_accessors
<<
fixture_file_accessor
(
name
,
platform
)
end
end
#-----------------------------------------------------------------------------#
SpecHelper
::
Fixture
.
fixture
(
'banana-lib'
)
# ensure it exists
...
...
spec/unit/target/aggregate_target_spec.rb
View file @
18abf36f
...
...
@@ -115,5 +115,31 @@ module Pod
consumer_reps
.
should
==
[[
'BananaLib'
,
:ios
]]
end
end
describe
'Product type dependent helpers'
do
describe
'With libraries'
do
before
do
@pod_target
=
fixture_pod_target
(
'banana-lib/BananaLib.podspec'
)
@target
=
AggregateTarget
.
new
(
@pod_target
.
target_definition
,
config
.
sandbox
)
@target
.
pod_targets
=
[
@pod_target
]
end
it
'returns that it does not use swift'
do
@target
.
uses_swift?
.
should
==
false
end
end
describe
'With frameworks'
do
before
do
@pod_target
=
fixture_pod_target
(
'orange-framework/OrangeFramework.podspec'
)
@target
=
AggregateTarget
.
new
(
@pod_target
.
target_definition
,
config
.
sandbox
)
@target
.
pod_targets
=
[
@pod_target
]
end
it
'returns that it uses swift'
do
@target
.
uses_swift?
.
should
==
true
end
end
end
end
end
spec/unit/target/pod_target_spec.rb
View file @
18abf36f
...
...
@@ -102,5 +102,27 @@ module Pod
end
end
describe
'Product type dependent helpers'
do
describe
'With libraries'
do
before
do
@pod_target
=
fixture_pod_target
(
'banana-lib/BananaLib.podspec'
)
end
it
'returns that it does not use swift'
do
@pod_target
.
uses_swift?
.
should
==
false
end
end
describe
'With frameworks'
do
before
do
@pod_target
=
fixture_pod_target
(
'orange-framework/OrangeFramework.podspec'
)
end
it
'returns that it uses swift'
do
@pod_target
.
uses_swift?
.
should
==
true
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