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
000ca1fe
Commit
000ca1fe
authored
Sep 01, 2017
by
Dimitris Koutsogiorgas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude test resource and framework paths from aggregate targets
parent
38391fc7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
36 deletions
+125
-36
CHANGELOG.md
CHANGELOG.md
+4
-0
aggregate_target.rb
lib/cocoapods/target/aggregate_target.rb
+2
-2
pod_target.rb
lib/cocoapods/target/pod_target.rb
+56
-34
pod_target_spec.rb
spec/unit/target/pod_target_spec.rb
+63
-0
No files found.
CHANGELOG.md
View file @
000ca1fe
...
@@ -43,6 +43,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -43,6 +43,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[
Justin Martin
](
https://github.com/justinseanmartin
)
[
Justin Martin
](
https://github.com/justinseanmartin
)
[
#7013
](
https://github.com/CocoaPods/CocoaPods/pull/7013
)
[
#7013
](
https://github.com/CocoaPods/CocoaPods/pull/7013
)
*
Exclude test resource and framework paths from aggregate targets
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#7000
](
https://github.com/CocoaPods/CocoaPods/pull/7000
)
*
Wrap platform warning message with quotes
*
Wrap platform warning message with quotes
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6968
](
https://github.com/CocoaPods/CocoaPods/pull/6968
)
[
#6968
](
https://github.com/CocoaPods/CocoaPods/pull/6968
)
...
...
lib/cocoapods/target/aggregate_target.rb
View file @
000ca1fe
...
@@ -194,7 +194,7 @@ module Pod
...
@@ -194,7 +194,7 @@ module Pod
relevant_pod_targets
=
pod_targets
.
select
do
|
pod_target
|
relevant_pod_targets
=
pod_targets
.
select
do
|
pod_target
|
pod_target
.
include_in_build_config?
(
target_definition
,
config
)
pod_target
.
include_in_build_config?
(
target_definition
,
config
)
end
end
framework_paths_by_config
[
config
]
=
relevant_pod_targets
.
flat_map
(
&
:framework_paths
)
framework_paths_by_config
[
config
]
=
relevant_pod_targets
.
flat_map
{
|
pt
|
pt
.
framework_paths
(
false
)
}
end
end
framework_paths_by_config
framework_paths_by_config
end
end
...
@@ -210,7 +210,7 @@ module Pod
...
@@ -210,7 +210,7 @@ module Pod
user_build_configurations
.
keys
.
each_with_object
({})
do
|
config
,
resources_by_config
|
user_build_configurations
.
keys
.
each_with_object
({})
do
|
config
,
resources_by_config
|
resources_by_config
[
config
]
=
relevant_pod_targets
.
flat_map
do
|
pod_target
|
resources_by_config
[
config
]
=
relevant_pod_targets
.
flat_map
do
|
pod_target
|
next
[]
unless
pod_target
.
include_in_build_config?
(
target_definition
,
config
)
next
[]
unless
pod_target
.
include_in_build_config?
(
target_definition
,
config
)
(
pod_target
.
resource_paths
+
[
bridge_support_file
].
compact
).
uniq
(
pod_target
.
resource_paths
(
false
)
+
[
bridge_support_file
].
compact
).
uniq
end
end
end
end
end
end
...
...
lib/cocoapods/target/pod_target.rb
View file @
000ca1fe
...
@@ -197,51 +197,73 @@ module Pod
...
@@ -197,51 +197,73 @@ module Pod
specs
.
select
(
&
:test_specification?
).
map
(
&
:test_type
).
uniq
specs
.
select
(
&
:test_specification?
).
map
(
&
:test_type
).
uniq
end
end
# Returns the framework paths associated with this target. By default all paths include the framework paths
# that are part of test specifications.
#
# @param [Boolean] include_test_spec_paths
# Whether to include framework paths from test specifications or not.
#
# @return [Array<Hash{Symbol => [String]}>] The vendored and non vendored framework paths
# @return [Array<Hash{Symbol => [String]}>] The vendored and non vendored framework paths
# this target depends upon.
# this target depends upon.
#
#
def
framework_paths
def
framework_paths
(
include_test_spec_paths
=
true
)
@framework_paths
||=
begin
@framework_paths
||=
Hash
.
new
do
|
h
,
key
|
frameworks
=
[]
h
[
key
]
=
begin
file_accessors
.
flat_map
(
&
:vendored_dynamic_artifacts
).
map
do
|
framework_path
|
accessors
=
file_accessors
relative_path_to_sandbox
=
framework_path
.
relative_path_from
(
sandbox
.
root
)
accessors
=
accessors
.
reject
{
|
a
|
a
.
spec
.
test_specification?
}
unless
include_test_spec_paths
framework
=
{
:name
=>
framework_path
.
basename
.
to_s
,
frameworks
=
[]
:input_path
=>
"${PODS_ROOT}/
#{
relative_path_to_sandbox
}
"
,
accessors
.
flat_map
(
&
:vendored_dynamic_artifacts
).
map
do
|
framework_path
|
:output_path
=>
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/
#{
framework_path
.
basename
}
"
}
relative_path_to_sandbox
=
framework_path
.
relative_path_from
(
sandbox
.
root
)
# Until this can be configured, assume the dSYM file uses the file name as the framework.
framework
=
{
:name
=>
framework_path
.
basename
.
to_s
,
# See https://github.com/CocoaPods/CocoaPods/issues/1698
:input_path
=>
"${PODS_ROOT}/
#{
relative_path_to_sandbox
}
"
,
dsym_name
=
"
#{
framework_path
.
basename
}
.dSYM"
:output_path
=>
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/
#{
framework_path
.
basename
}
"
}
dsym_path
=
Pathname
.
new
(
"
#{
framework_path
.
dirname
}
/
#{
dsym_name
}
"
)
# Until this can be configured, assume the dSYM file uses the file name as the framework.
if
dsym_path
.
exist?
# See https://github.com/CocoaPods/CocoaPods/issues/1698
framework
[
:dsym_name
]
=
dsym_name
dsym_name
=
"
#{
framework_path
.
basename
}
.dSYM"
framework
[
:dsym_input_path
]
=
"${PODS_ROOT}/
#{
relative_path_to_sandbox
}
.dSYM"
dsym_path
=
Pathname
.
new
(
"
#{
framework_path
.
dirname
}
/
#{
dsym_name
}
"
)
framework
[
:dsym_output_path
]
=
"${DWARF_DSYM_FOLDER_PATH}/
#{
dsym_name
}
"
if
dsym_path
.
exist?
framework
[
:dsym_name
]
=
dsym_name
framework
[
:dsym_input_path
]
=
"${PODS_ROOT}/
#{
relative_path_to_sandbox
}
.dSYM"
framework
[
:dsym_output_path
]
=
"${DWARF_DSYM_FOLDER_PATH}/
#{
dsym_name
}
"
end
frameworks
<<
framework
end
end
frameworks
<<
framework
if
should_build?
&&
requires_frameworks?
&&
!
static_framework?
end
frameworks
<<
{
:name
=>
product_name
,
if
should_build?
&&
requires_frameworks?
&&
!
static_framework?
:input_path
=>
build_product_path
(
'${BUILT_PRODUCTS_DIR}'
),
frameworks
<<
{
:name
=>
product_name
,
:output_path
=>
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/
#{
product_name
}
"
}
:input_path
=>
build_product_path
(
'${BUILT_PRODUCTS_DIR}'
),
end
:output_path
=>
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/
#{
product_name
}
"
}
frameworks
end
end
frameworks
end
end
@framework_paths
[
include_test_spec_paths
]
end
end
# Returns the resource paths associated with this target. By default all paths include the resource paths
# that are part of test specifications.
#
# @param [Boolean] include_test_spec_paths
# Whether to include resource paths from test specifications or not.
#
# @return [Array<String>] The resource and resource bundle paths this target depends upon.
# @return [Array<String>] The resource and resource bundle paths this target depends upon.
#
#
def
resource_paths
def
resource_paths
(
include_test_spec_paths
=
true
)
@resource_paths
||=
begin
@resource_paths
||=
Hash
.
new
do
|
h
,
key
|
resource_paths
=
file_accessors
.
flat_map
do
|
accessor
|
h
[
key
]
=
begin
accessor
.
resources
.
flat_map
{
|
res
|
"${PODS_ROOT}/
#{
res
.
relative_path_from
(
sandbox
.
project
.
path
.
dirname
)
}
"
}
accessors
=
file_accessors
end
accessors
=
accessors
.
reject
{
|
a
|
a
.
spec
.
test_specification?
}
unless
include_test_spec_paths
resource_bundles
=
file_accessors
.
flat_map
do
|
accessor
|
resource_paths
=
accessors
.
flat_map
do
|
accessor
|
prefix
=
Generator
::
XCConfig
::
XCConfigHelper
::
CONFIGURATION_BUILD_DIR_VARIABLE
accessor
.
resources
.
flat_map
{
|
res
|
"${PODS_ROOT}/
#{
res
.
relative_path_from
(
sandbox
.
project
.
path
.
dirname
)
}
"
}
prefix
=
configuration_build_dir
unless
accessor
.
spec
.
test_specification?
end
accessor
.
resource_bundles
.
keys
.
map
{
|
name
|
"
#{
prefix
}
/
#{
name
.
shellescape
}
.bundle"
}
resource_bundles
=
accessors
.
flat_map
do
|
accessor
|
prefix
=
Generator
::
XCConfig
::
XCConfigHelper
::
CONFIGURATION_BUILD_DIR_VARIABLE
prefix
=
configuration_build_dir
unless
accessor
.
spec
.
test_specification?
accessor
.
resource_bundles
.
keys
.
map
{
|
name
|
"
#{
prefix
}
/
#{
name
.
shellescape
}
.bundle"
}
end
resource_paths
+
resource_bundles
end
end
resource_paths
+
resource_bundles
end
end
@resource_paths
[
include_test_spec_paths
]
end
end
# Returns the corresponding native target to use based on the provided specification.
# Returns the corresponding native target to use based on the provided specification.
...
@@ -249,7 +271,7 @@ module Pod
...
@@ -249,7 +271,7 @@ module Pod
# test native targets.
# test native targets.
#
#
# @param [Specification] spec
# @param [Specification] spec
# The specifcation to base from in order to find the native target.
# The specif
i
cation to base from in order to find the native target.
#
#
# @return [PBXNativeTarget] the native target to use or `nil` if none is found.
# @return [PBXNativeTarget] the native target to use or `nil` if none is found.
#
#
...
...
spec/unit/target/pod_target_spec.rb
View file @
000ca1fe
...
@@ -375,6 +375,69 @@ module Pod
...
@@ -375,6 +375,69 @@ module Pod
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
])
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
])
@test_pod_target
.
resource_paths
.
should
==
[
'$PODS_CONFIGURATION_BUILD_DIR/TestResourceBundle.bundle'
]
@test_pod_target
.
resource_paths
.
should
==
[
'$PODS_CONFIGURATION_BUILD_DIR/TestResourceBundle.bundle'
]
end
end
it
'includes framework paths from test specifications'
do
fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
fa
.
stubs
(
:vendored_dynamic_artifacts
).
returns
([
config
.
sandbox
.
root
+
Pathname
.
new
(
'Vendored/Vendored.framework'
)])
fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
false
))
test_fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
test_fa
.
stubs
(
:vendored_dynamic_artifacts
).
returns
([
config
.
sandbox
.
root
+
Pathname
.
new
(
'Vendored/TestVendored.framework'
)])
test_fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
true
))
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
,
test_fa
])
@test_pod_target
.
stubs
(
:should_build?
).
returns
(
true
)
@test_pod_target
.
framework_paths
.
should
==
[
{
:name
=>
'Vendored.framework'
,
:input_path
=>
'${PODS_ROOT}/Vendored/Vendored.framework'
,
:output_path
=>
'${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Vendored.framework'
},
{
:name
=>
'TestVendored.framework'
,
:input_path
=>
'${PODS_ROOT}/Vendored/TestVendored.framework'
,
:output_path
=>
'${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TestVendored.framework'
},
]
end
it
'excludes framework paths from test specifications when not requested'
do
fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
fa
.
stubs
(
:vendored_dynamic_artifacts
).
returns
([
config
.
sandbox
.
root
+
Pathname
.
new
(
'Vendored/Vendored.framework'
)])
fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
false
))
test_fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
test_fa
.
stubs
(
:vendored_dynamic_artifacts
).
returns
([
config
.
sandbox
.
root
+
Pathname
.
new
(
'Vendored/TestVendored.framework'
)])
test_fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
true
))
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
,
test_fa
])
@test_pod_target
.
stubs
(
:should_build?
).
returns
(
true
)
@test_pod_target
.
framework_paths
(
false
).
should
==
[
{
:name
=>
'Vendored.framework'
,
:input_path
=>
'${PODS_ROOT}/Vendored/Vendored.framework'
,
:output_path
=>
'${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Vendored.framework'
},
]
end
it
'includes resource paths from test specifications'
do
config
.
sandbox
.
stubs
(
:project
=>
stub
(
:path
=>
Pathname
.
new
(
'ProjectPath'
)))
fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
fa
.
stubs
(
:resource_bundles
).
returns
({})
fa
.
stubs
(
:resources
).
returns
([
Pathname
.
new
(
'Model.xcdatamodeld'
)])
fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
false
))
test_fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
test_fa
.
stubs
(
:resource_bundles
).
returns
({})
test_fa
.
stubs
(
:resources
).
returns
([
Pathname
.
new
(
'TestModel.xcdatamodeld'
)])
test_fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
true
))
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
,
test_fa
])
@test_pod_target
.
resource_paths
.
should
==
[
'${PODS_ROOT}/Model.xcdatamodeld'
,
'${PODS_ROOT}/TestModel.xcdatamodeld'
]
end
it
'excludes resource paths from test specifications when not requested'
do
config
.
sandbox
.
stubs
(
:project
=>
stub
(
:path
=>
Pathname
.
new
(
'ProjectPath'
)))
fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
fa
.
stubs
(
:resource_bundles
).
returns
({})
fa
.
stubs
(
:resources
).
returns
([
Pathname
.
new
(
'Model.xcdatamodeld'
)])
fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
false
))
test_fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
test_fa
.
stubs
(
:resource_bundles
).
returns
({})
test_fa
.
stubs
(
:resources
).
returns
([
Pathname
.
new
(
'TestModel.xcdatamodeld'
)])
test_fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
true
))
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
,
test_fa
])
@test_pod_target
.
resource_paths
(
false
).
should
==
[
'${PODS_ROOT}/Model.xcdatamodeld'
]
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