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
c31b4b76
Commit
c31b4b76
authored
Jun 28, 2014
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support framework as type for generated target
parent
18abf36f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
1 deletion
+84
-1
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+18
-0
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+2
-1
target.rb
lib/cocoapods/target.rb
+20
-0
aggregate_target_spec.rb
spec/unit/target/aggregate_target_spec.rb
+24
-0
pod_target_spec.rb
spec/unit/target/pod_target_spec.rb
+20
-0
No files found.
lib/cocoapods/installer/analyzer.rb
View file @
c31b4b76
...
@@ -189,6 +189,7 @@ module Pod
...
@@ -189,6 +189,7 @@ module Pod
user_project
=
Xcodeproj
::
Project
.
open
(
project_path
)
user_project
=
Xcodeproj
::
Project
.
open
(
project_path
)
native_targets
=
compute_user_project_targets
(
target_definition
,
user_project
)
native_targets
=
compute_user_project_targets
(
target_definition
,
user_project
)
target
.
host_requires_framework
|=
compute_user_project_targets_require_framework
(
native_targets
)
target
.
user_project_path
=
project_path
target
.
user_project_path
=
project_path
target
.
client_root
=
project_path
.
dirname
target
.
client_root
=
project_path
.
dirname
target
.
user_target_uuids
=
native_targets
.
map
(
&
:uuid
)
target
.
user_target_uuids
=
native_targets
.
map
(
&
:uuid
)
...
@@ -211,6 +212,7 @@ module Pod
...
@@ -211,6 +212,7 @@ module Pod
# Create a target for each spec group and add it to the aggregate target
# Create a target for each spec group and add it to the aggregate target
grouped_specs
.
each
do
|
pod_specs
|
grouped_specs
.
each
do
|
pod_specs
|
pod_target
=
PodTarget
.
new
(
pod_specs
,
target_definition
,
sandbox
)
pod_target
=
PodTarget
.
new
(
pod_specs
,
target_definition
,
sandbox
)
pod_target
.
host_requires_framework
|=
target
.
host_requires_framework
if
config
.
integrate_targets?
if
config
.
integrate_targets?
pod_target
.
user_build_configurations
=
target
.
user_build_configurations
pod_target
.
user_build_configurations
=
target
.
user_build_configurations
pod_target
.
archs
=
@archs_by_target_def
[
target_definition
]
pod_target
.
archs
=
@archs_by_target_def
[
target_definition
]
...
@@ -518,6 +520,22 @@ module Pod
...
@@ -518,6 +520,22 @@ module Pod
end
end
end
end
# Checks if any of the targets for the {TargetDefinition} computed before
# by #compute_user_project_targets require to be build as a framework due
# the presence of Swift source code in any of the source build phases.
#
# @param [Array<PBXNativeTarget>] native_targets
# the targets which are checked for presence of Swift source code
#
# @return [Boolean] Whether the user project targets to integrate into
# uses Swift
#
def
compute_user_project_targets_require_framework
(
native_targets
)
native_targets
.
any?
do
|
target
|
target
.
source_build_phase
.
files
.
any?
{
|
f
|
f
.
file_ref
.
last_known_file_type
==
'sourcecode.swift'
}
end
end
# @return [Hash{String=>Symbol}] A hash representing the user build
# @return [Hash{String=>Symbol}] A hash representing the user build
# configurations where each key corresponds to the name of a
# configurations where each key corresponds to the name of a
# configuration and its value to its type (`:debug` or `:release`).
# configuration and its value to its type (`:debug` or `:release`).
...
...
lib/cocoapods/installer/target_installer.rb
View file @
c31b4b76
...
@@ -36,10 +36,11 @@ module Pod
...
@@ -36,10 +36,11 @@ module Pod
# @return [void]
# @return [void]
#
#
def
add_target
def
add_target
product_type
=
target
.
requires_framework?
?
:
framework
:
:static_library
name
=
target
.
label
name
=
target
.
label
platform
=
target
.
platform
.
name
platform
=
target
.
platform
.
name
deployment_target
=
target
.
platform
.
deployment_target
.
to_s
deployment_target
=
target
.
platform
.
deployment_target
.
to_s
@native_target
=
project
.
new_target
(
:static_library
,
name
,
platform
,
deployment_target
)
@native_target
=
project
.
new_target
(
product_type
,
name
,
platform
,
deployment_target
)
target
.
user_build_configurations
.
each
do
|
bc_name
,
type
|
target
.
user_build_configurations
.
each
do
|
bc_name
,
type
|
configuration
=
@native_target
.
add_build_configuration
(
bc_name
,
type
)
configuration
=
@native_target
.
add_build_configuration
(
bc_name
,
type
)
...
...
lib/cocoapods/target.rb
View file @
c31b4b76
...
@@ -15,6 +15,12 @@ module Pod
...
@@ -15,6 +15,12 @@ module Pod
#
#
attr_reader
:sandbox
attr_reader
:sandbox
# @return [Boolean] Whether the target needs to be implemented as a framework.
# Computed by analyzer.
#
attr_accessor
:host_requires_framework
alias_method
:host_requires_framework?
,
:host_requires_framework
# @return [String] the name of the library.
# @return [String] the name of the library.
#
#
def
name
def
name
...
@@ -41,6 +47,20 @@ module Pod
...
@@ -41,6 +47,20 @@ module Pod
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
# @return [Boolean] whether the generated target need to be implemented
# as a framework
#
# @note This applies either if Swift was used by the host, which was checked
# eagerly by the analyzer before, or in the given target or its
# dependents, which can only be checked after the specs were been
# fetched.
#
def
requires_framework?
host_requires_framework?
||
uses_swift?
end
#-------------------------------------------------------------------------#
# @!group Information storage
# @!group Information storage
# @return [Hash{String=>Symbol}] A hash representing the user build
# @return [Hash{String=>Symbol}] A hash representing the user build
...
...
spec/unit/target/aggregate_target_spec.rb
View file @
c31b4b76
...
@@ -127,6 +127,26 @@ module Pod
...
@@ -127,6 +127,26 @@ module Pod
it
'returns that it does not use swift'
do
it
'returns that it does not use swift'
do
@target
.
uses_swift?
.
should
==
false
@target
.
uses_swift?
.
should
==
false
end
end
describe
'Host requires frameworks'
do
before
do
@target
.
host_requires_framework
=
true
end
it
'returns that it requires being built as framework'
do
@target
.
requires_framework?
.
should
==
true
end
end
describe
'Host does not requires frameworks'
do
it
'returns :static_library as product type'
do
@target
.
product_type
.
should
==
:static_library
end
it
'returns that it does not require being built as framework'
do
@target
.
requires_framework?
.
should
==
false
end
end
end
end
describe
'With frameworks'
do
describe
'With frameworks'
do
...
@@ -139,6 +159,10 @@ module Pod
...
@@ -139,6 +159,10 @@ module Pod
it
'returns that it uses swift'
do
it
'returns that it uses swift'
do
@target
.
uses_swift?
.
should
==
true
@target
.
uses_swift?
.
should
==
true
end
end
it
'returns that it requires being built as framework'
do
@target
.
requires_framework?
.
should
==
true
end
end
end
end
end
end
end
...
...
spec/unit/target/pod_target_spec.rb
View file @
c31b4b76
...
@@ -111,6 +111,22 @@ module Pod
...
@@ -111,6 +111,22 @@ module Pod
it
'returns that it does not use swift'
do
it
'returns that it does not use swift'
do
@pod_target
.
uses_swift?
.
should
==
false
@pod_target
.
uses_swift?
.
should
==
false
end
end
describe
'Host requires frameworks'
do
before
do
@pod_target
.
host_requires_framework
=
true
end
it
'returns that it requires being built as framework'
do
@pod_target
.
requires_framework?
.
should
==
true
end
end
describe
'Host does not requires frameworks'
do
it
'returns that it does not require being built as framework'
do
@pod_target
.
requires_framework?
.
should
==
false
end
end
end
end
describe
'With frameworks'
do
describe
'With frameworks'
do
...
@@ -121,6 +137,10 @@ module Pod
...
@@ -121,6 +137,10 @@ module Pod
it
'returns that it uses swift'
do
it
'returns that it uses swift'
do
@pod_target
.
uses_swift?
.
should
==
true
@pod_target
.
uses_swift?
.
should
==
true
end
end
it
'returns that it requires being built as framework'
do
@pod_target
.
requires_framework?
.
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