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
06a6b77c
Commit
06a6b77c
authored
Jan 12, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CopyResourcesScript] Copy only the resources required for the current build configuration.
parent
dfa52754
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
15 deletions
+26
-15
CHANGELOG.md
CHANGELOG.md
+4
-0
copy_resources_script.rb
lib/cocoapods/generator/copy_resources_script.rb
+12
-7
aggregate_target_installer.rb
.../installer/target_installer/aggregate_target_installer.rb
+7
-5
target_integrator.rb
...ds/installer/user_project_integrator/target_integrator.rb
+1
-1
copy_resources_script_spec.rb
spec/unit/generator/copy_resources_script_spec.rb
+2
-2
No files found.
CHANGELOG.md
View file @
06a6b77c
...
...
@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
instead of
`note`
.
[
Hugo Tunius
](
https://github.com/K0nserv
)
*
Copy only the resources required for the current build configuration.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
#2391
](
https://github.com/CocoaPods/CocoaPods/issues/2391
)
##### Bug Fixes
*
Ensure that linting fails if xcodebuild doesn't successfully build your Pod.
...
...
lib/cocoapods/generator/copy_resources_script.rb
View file @
06a6b77c
module
Pod
module
Generator
class
CopyResourcesScript
# @return [
Array<#to_s>] A list of files relative to the project pods
#
root
.
# @return [
Hash{String, Array{String}] A list of files relative to the
#
project pods root, keyed by build configuration
.
#
attr_reader
:resources
attr_reader
:resources
_by_config
# @return [Platform] The platform of the library for which the copy
# resources script is needed.
#
attr_reader
:platform
# @param [Array<#to_s>] resources @see resources
# @param [Hash{String, Array{String}]
# resources_by_config @see resources_by_config
# @param [Platform] platform @see platform
#
def
initialize
(
resources
,
platform
)
@resources
=
resources
def
initialize
(
resources
_by_config
,
platform
)
@resources
_by_config
=
resources_by_config
@platform
=
platform
end
...
...
@@ -68,8 +69,12 @@ module Pod
#
def
script
script
=
install_resources_function
resources_by_config
.
each
do
|
config
,
resources
|
script
+=
%(if [[ "$CONFIGURATION" == "#{config}" ]]; then\n)
resources
.
each
do
|
resource
|
script
+=
%( install_resource "#{resource}"\n )
script
+=
" install_resource '
#{
resource
}
'
\n
"
end
script
+=
"fi
\n
"
end
script
+=
RSYNC_CALL
script
+=
XCASSETS_COMPILE
...
...
lib/cocoapods/installer/target_installer/aggregate_target_installer.rb
View file @
06a6b77c
...
...
@@ -115,13 +115,15 @@ module Pod
pod_target
.
should_build?
&&
pod_target
.
requires_frameworks?
end
file_accessors
=
library_targets
.
flat_map
(
&
:file_accessors
)
resources_by_config
=
{}
target
.
user_build_configurations
.
keys
.
each
do
|
config
|
file_accessors
=
library_targets
.
select
{
|
t
|
t
.
include_in_build_config?
(
config
)
}.
flat_map
(
&
:file_accessors
)
resource_paths
=
file_accessors
.
flat_map
{
|
accessor
|
accessor
.
resources
.
flat_map
{
|
res
|
res
.
relative_path_from
(
project
.
path
.
dirname
)
}
}
resource_bundles
=
file_accessors
.
flat_map
{
|
accessor
|
accessor
.
resource_bundles
.
keys
.
map
{
|
name
|
"${BUILT_PRODUCTS_DIR}/
#{
name
}
.bundle"
}
}
resources
=
[]
resources
.
concat
(
resource_paths
)
resources
.
concat
(
resource_bundles
)
resources
<<
bridge_support_file
if
bridge_support_file
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources
,
target
.
platform
)
resources_by_config
[
config
]
=
resource_paths
+
resource_bundles
resources_by_config
[
config
]
<<
bridge_support_file
if
bridge_support_file
end
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources_by_config
,
target
.
platform
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
...
...
lib/cocoapods/installer/user_project_integrator/target_integrator.rb
View file @
06a6b77c
...
...
@@ -179,7 +179,7 @@ module Pod
def
add_copy_resources_script_phase
phase_name
=
'Copy Pods Resources'
native_targets_to_integrate
.
each
do
|
native_target
|
phase
=
native_target
.
shell_script_build_phases
.
select
{
|
bp
|
bp
.
name
==
phase_name
}.
first
phase
=
native_target
.
shell_script_build_phases
.
find
{
|
bp
|
bp
.
name
==
phase_name
}
phase
||=
native_target
.
new_shell_script_build_phase
(
phase_name
)
script_path
=
target
.
copy_resources_script_relative_path
phase
.
shell_script
=
%("#{script_path}"\n)
...
...
spec/unit/generator/copy_resources_script_spec.rb
View file @
06a6b77c
...
...
@@ -3,14 +3,14 @@ require File.expand_path('../../../spec_helper', __FILE__)
module
Pod
describe
Generator
::
CopyResourcesScript
do
it
'returns the copy resources script'
do
resources
=
[
'path/to/resource.png'
]
resources
=
{
'Release'
=>
[
'path/to/resource.png'
]
}
generator
=
Pod
::
Generator
::
CopyResourcesScript
.
new
(
resources
,
Platform
.
new
(
:ios
,
'6.0'
))
generator
.
send
(
:script
).
should
.
include
'path/to/resource.png'
generator
.
send
(
:script
).
should
.
include
'storyboard'
end
it
'instructs ibtool to use the --reference-external-strings-file if set to do so'
do
resources
=
[
'path/to/resource.png'
]
resources
=
{
'Release'
=>
[
'path/to/resource.png'
]
}
generator_1
=
Pod
::
Generator
::
CopyResourcesScript
.
new
(
resources
,
Platform
.
new
(
:ios
,
'4.0'
))
generator_2
=
Pod
::
Generator
::
CopyResourcesScript
.
new
(
resources
,
Platform
.
new
(
:ios
,
'6.0'
))
...
...
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