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
779412f7
Commit
779412f7
authored
May 17, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Generator::CopyResourcesScript] Clean-up
See #1030
parent
23857165
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
26 deletions
+102
-26
CHANGELOG.md
CHANGELOG.md
+2
-1
copy_resources_script.rb
lib/cocoapods/generator/copy_resources_script.rb
+76
-18
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+1
-7
copy_resources_script_spec.rb
spec/unit/generator/copy_resources_script_spec.rb
+23
-0
No files found.
CHANGELOG.md
View file @
779412f7
...
...
@@ -20,7 +20,8 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
*
Inheriting
`inhibit_warnings`
per pod is now working
[
#1032
](
https://github.com/CocoaPods/CocoaPods/issues/1032
)
*
Fix copy resources script for iOS < 6 and OS X < 10.8 by removing the
`--reference-external-strings-file`
*
Fix copy resources script for iOS < 6 and OS X < 10.8 by removing the
`--reference-external-strings-file`
flag.
[
#1030
](
https://github.com/CocoaPods/CocoaPods/pull/1030
)
## 0.19.1
...
...
lib/cocoapods/generator/copy_resources_script.rb
View file @
779412f7
module
Pod
module
Generator
class
CopyResourcesScript
require
'fileutils'
# @return [Array<#to_s>] A list of files relative to the project pods
# root.
#
attr_reader
:resources
# @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 [Platform] platform @see platform
#
def
initialize
(
resources
,
platform
)
@resources
=
resources
@platform
=
platform
end
# Saves the resource script to the given pathname.
#
# @param [Pathname] pathname
# The path where the copy resources script should be saved.
#
# @return [void]
#
def
save_as
(
pathname
)
pathname
.
open
(
'w'
)
do
|
file
|
file
.
puts
(
script
)
end
FileUtils
.
chmod
(
'+x'
,
pathname
.
to_s
)
end
private
# @!group Private Helpers
# @return [Hash{Symbol=>Version}] The minimum deployment target which
# supports the `--reference-external-strings-file` option for
# the `ibtool` command.
#
EXTERNAL_STRINGS_FILE_MIMINUM_DEPLOYMENT_TARGET
=
{
:ios
=>
Version
.
new
(
'6.0'
),
:osx
=>
Version
.
new
(
'10.8'
)
}
# @return [Bool] Whether the external strings file is supported by the
# `ibtool` according to the deployment target of the platform.
#
def
use_external_strings_file?
minimum_deployment_target
=
EXTERNAL_STRINGS_FILE_MIMINUM_DEPLOYMENT_TARGET
[
platform
.
name
]
platform
.
deployment_target
>=
minimum_deployment_target
end
# @return [String] The install resources shell function.
#
def
install_resources_function
if
use_external_strings_file?
CONTENT
else
CONTENT
.
gsub
(
' --reference-external-strings-file'
,
''
)
end
end
# @return [String] The contents of the copy resources script.
#
def
script
script
=
install_resources_function
resources
.
each
do
|
resource
|
script
+=
"install_resource '
#{
resource
}
'"
end
script
end
CONTENT
=
<<
EOS
#!/bin/sh
...
...
@@ -31,24 +107,6 @@ install_resource()
}
EOS
attr_reader
:resources
# A list of files relative to the project pods root.
def
initialize
(
resources
=
[],
reference_external_strings_file
=
false
)
@resources
=
resources
@reference_external_strings_file
=
reference_external_strings_file
end
def
save_as
(
pathname
)
pathname
.
open
(
'w'
)
do
|
script
|
script
.
puts
@reference_external_strings_file
?
CONTENT
:
CONTENT
.
gsub
(
' --reference-external-strings-file'
,
''
)
@resources
.
each
do
|
resource
|
script
.
puts
"install_resource '
#{
resource
}
'"
end
end
# @todo use File api
system
(
"chmod +x '
#{
pathname
}
'"
)
end
end
end
end
lib/cocoapods/installer/target_installer.rb
View file @
779412f7
...
...
@@ -204,10 +204,6 @@ module Pod
end
end
ENABLE_EXTERNAL_STRINGS_FILE_FLAG
=
{
:ios
=>
Version
.
new
(
'6'
),
:osx
=>
Version
.
new
(
'10.8'
)
}
# Creates a script that copies the resources to the bundle of the client
# target.
#
...
...
@@ -221,9 +217,7 @@ module Pod
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
path
)
}
"
do
resources
=
library
.
file_accessors
.
map
{
|
accessor
|
accessor
.
resources
.
flatten
.
map
{
|
res
|
project
.
relativize
(
res
)}
}.
flatten
resources
<<
bridge_support_file
if
bridge_support_file
platform_name
=
library
.
platform
.
name
reference_external_strings_file
=
library
.
platform
.
deployment_target
>=
ENABLE_EXTERNAL_STRINGS_FILE_FLAG
[
platform_name
]
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources
,
reference_external_strings_file
)
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources
,
library
.
platform
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
...
...
spec/unit/generator/copy_resources_script_spec.rb
0 → 100644
View file @
779412f7
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'
]
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'
]
generator_1
=
Pod
::
Generator
::
CopyResourcesScript
.
new
(
resources
,
Platform
.
new
(
:ios
,
'4.0'
))
generator_2
=
Pod
::
Generator
::
CopyResourcesScript
.
new
(
resources
,
Platform
.
new
(
:ios
,
'6.0'
))
generator_1
.
send
(
:script
).
should
.
not
.
include
'--reference-external-strings-file'
generator_2
.
send
(
:script
).
should
.
include
'--reference-external-strings-file'
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