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
21af2670
Commit
21af2670
authored
Nov 14, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Core Extraction] Adapted Target Installer (with clean up).
parent
39f80935
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
277 additions
and
151 deletions
+277
-151
copy_resources_script.rb
lib/cocoapods/generator/copy_resources_script.rb
+1
-1
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+184
-101
spec_helper.rb
spec/spec_helper.rb
+2
-1
target_installer_spec.rb
spec/unit/installer/target_installer_spec.rb
+90
-48
No files found.
lib/cocoapods/generator/copy_resources_script.rb
View file @
21af2670
...
@@ -26,7 +26,7 @@ EOS
...
@@ -26,7 +26,7 @@ EOS
attr_reader
:resources
attr_reader
:resources
# A list of files relative to the project pods root.
# A list of files relative to the project pods root.
def
initialize
(
resources
)
def
initialize
(
resources
=
[]
)
@resources
=
resources
@resources
=
resources
end
end
...
...
lib/cocoapods/installer/target_installer.rb
View file @
21af2670
module
Pod
module
Pod
class
Installer
class
Installer
# This class is reponsible of creating and configuring the static library
# This class is re
s
ponsible of creating and configuring the static library
# target in Pods project. Every target is generated from a target
# target in Pods project. Every target is generated from a target
# definition of the Podfile.
# definition of the Podfile.
#
#
class
TargetInstaller
class
TargetInstaller
include
Config
::
Mixin
# @return [Podfile]
#
# TODO: is really needed to pass the podfile?
#
attr_reader
:podfile
# @return [Project] The Pods project.
# @return [Project] The Pods project.
#
#
attr_reader
:project
attr_reader
:project
# @return [TargetDefinition] The target definition who
o
se target needs to
# @return [TargetDefinition] The target definition whose target needs to
# be generated.
# be generated.
#
#
attr_reader
:target_definition
attr_reader
:target_definition
def
initialize
(
podfile
,
project
,
target_definition
)
# @param [Array<LocalPod>] pods the pods are required by the target
@podfile
=
podfile
# definition of this installer.
#
attr_reader
:pods
# @param [Project] project @see project
# @param [TargetDefinition] target_definition @see target_definition
# @param [Array<LocalPod>] pods @see pods
#
def
initialize
(
project
,
target_definition
,
pods
)
@project
=
project
@project
=
project
@target_definition
=
target_definition
@target_definition
=
target_definition
@pods
=
pods
end
end
# @return [void] Creates the target in the Pods project and its support
# Creates the target in the Pods project and its support files.
# files.
#
#
# @param [Array<LocalPod>] pods The pods are required by the target
# @return [void]
# definition of this installer.
#
#
# @param [Sandbox] sandbox The sanbox where the support files
def
install
# should be generated.
add_target
add_build_files_to_target
add_file_reference_for_support_files
configure_target
create_xcconfig_file
create_prefix_header
create_bridge_support_file
create_copy_resources_script
end
# TODO This has to be removed, but this means the specs have to be
# updated if they need a reference to the prefix header.
#
#
def
install!
(
pods
,
sandbox
)
def
prefix_header_filename
self
.
requires_arc
=
pods
.
any?
{
|
pod
|
pod
.
requires_arc?
}
library
.
prefix_header_name
end
@target
=
@project
.
add_pod_target
(
@target_definition
.
label
,
@target_definition
.
platform
)
#-----------------------------------------------------------------------#
source_file_descriptions
=
[]
# @!group Installation steps
pods
.
each
{
|
p
|
p
.
add_build_files_to_target
(
@target
)
}
support_files_group
=
@project
.
support_files_group
.
new_group
(
@target_definition
.
label
)
private
target_support_files
.
each
{
|
path
|
support_files_group
.
new_file
(
path
)
}
xcconfig_file
=
support_files_group
.
files
.
find
{
|
f
|
f
.
path
==
@target_definition
.
xcconfig_name
}
# Adds the library for the {#target_definition} to the Pods
configure_build_configurations
(
xcconfig_file
,
sandbox
)
# project.
create_files
(
pods
,
sandbox
)
#
# @return [void]
#
def
add_target
@library
=
@project
.
add_pod_library
(
target_definition
)
@target
=
@library
.
target
end
end
# @return [PBXNativeTarget] The target generated by the installation
# Adds the build files of the pods to the target.
# process.
#
#
attr_reader
:target
# @return [void]
#
def
add_build_files_to_target
pods
.
each
{
|
p
|
p
.
add_build_files_to_target
(
target
)
}
end
# Adds the file references for the support files that are generated by
# the installation process to the Pods project.
#
# @return [void]
#
def
add_file_reference_for_support_files
g
=
project
.
support_files_group
.
new_group
(
target_definition
.
label
)
g
.
new_file
(
library
.
copy_resources_script_name
)
g
.
new_file
(
library
.
prefix_header_name
)
g
.
new_file
(
library
.
xcconfig_name
).
tap
{
|
f
|
@xcconfig_file_ref
=
f
}
end
#
@return [Boold] Wether the any of the pods requires arc
.
#
Configures the build settings of the target
.
#
#
#
TODO: This should not be an attribute reader
.
#
@note The `PODS_HEADERS_SEARCH_PATHS` overrides the xcconfig
.
#
#
attr_accessor
:requires_arc
# @return [void]
#
def
configure_target
set
=
{}
set
[
'OTHER_LDFLAGS'
]
=
''
set
[
'GCC_PREFIX_HEADER'
]
=
library
.
prefix_header_name
set
[
'PODS_ROOT'
]
=
'${SRCROOT}'
set
[
'PODS_HEADERS_SEARCH_PATHS'
]
=
'${PODS_BUILD_HEADERS_SEARCH_PATHS}'
set
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
]
=
@target_definition
.
inhibit_all_warnings?
?
'YES'
:
'NO'
attr_reader
:xcconfig
@target
.
build_configurations
.
each
do
|
c
|
c
.
base_configuration_reference
=
xcconfig_file_ref
c
.
build_settings
.
merge!
(
set
)
end
end
# In a workspace this is where the static library headers should be found.
# Generates the contents of the xcconfig file and saves it to disk.
#
# @note The `ALWAYS_SEARCH_USER_PATHS` flag is enabled to support
# libraries like `EmbedReader`.
#
#
def
generate_xcconfig
(
pods
,
sandbox
)
# @return [void]
#
def
create_xcconfig_file
UI
.
message
"- Generating xcconfig file at
#{
UI
.
path
(
library
.
xcconfig_path
)
}
"
do
xcconfig
=
Xcodeproj
::
Config
.
new
({
xcconfig
=
Xcodeproj
::
Config
.
new
({
'ALWAYS_SEARCH_USER_PATHS'
=>
'YES'
,
# needed to make EmbedReader build
'ALWAYS_SEARCH_USER_PATHS'
=>
'YES'
,
'OTHER_LDFLAGS'
=>
default_ld_flags
,
'OTHER_LDFLAGS'
=>
default_ld_flags
,
'HEADER_SEARCH_PATHS'
=>
'${PODS_HEADERS_SEARCH_PATHS}'
,
'HEADER_SEARCH_PATHS'
=>
'${PODS_HEADERS_SEARCH_PATHS}'
,
# CocoaPods global keys
'PODS_ROOT'
=>
library
.
relative_pods_root
,
'PODS_ROOT'
=>
@target_definition
.
relative_pods_root
,
'PODS_BUILD_HEADERS_SEARCH_PATHS'
=>
quote
(
sandbox
.
build_headers
.
search_paths
),
'PODS_BUILD_HEADERS_SEARCH_PATHS'
=>
quoted
(
sandbox
.
build_headers
.
search_paths
).
join
(
" "
),
'PODS_PUBLIC_HEADERS_SEARCH_PATHS'
=>
quote
(
sandbox
.
public_headers
.
search_paths
),
'PODS_PUBLIC_HEADERS_SEARCH_PATHS'
=>
quoted
(
sandbox
.
public_headers
.
search_paths
).
join
(
" "
),
# Pods project specific keys
'PODS_HEADERS_SEARCH_PATHS'
=>
'${PODS_PUBLIC_HEADERS_SEARCH_PATHS}'
'PODS_HEADERS_SEARCH_PATHS'
=>
'${PODS_PUBLIC_HEADERS_SEARCH_PATHS}'
})
})
pods
.
each
{
|
pod
|
xcconfig
.
merge!
(
pod
.
xcconfig
)
}
pods
.
each
{
|
pod
|
xcconfig
.
merge!
(
pod
.
xcconfig
)
}
@xcconfig
=
xcconfig
xcconfig
.
save_as
(
library
.
xcconfig_path
)
library
.
xcconfig
=
xcconfig
end
end
end
# Creates a prefix header file which imports `UIKit` or `Cocoa`. This
# file also include any prefix header content reported by the
# specification of the pods.
#
#
# @return [void]
#
#
def
copy_resources_script_for
(
pods
)
def
create_prefix_header
@copy_resources_script
||=
Generator
::
CopyResourcesScript
.
new
(
pods
.
map
{
|
p
|
p
.
relative_resource_files
}.
flatten
)
UI
.
message
"- Generating prefix header at
#{
UI
.
path
(
library
.
prefix_header_path
)
}
"
do
gen
=
Generator
::
PrefixHeader
.
new
(
target_definition
.
platform
,
pods
)
gen
.
save_as
(
library
.
prefix_header_path
)
end
end
end
def
bridge_support_generator_for
(
pods
,
sandbox
)
# Generates the bridge support metadata if requested by the {Podfile}.
Generator
::
BridgeSupport
.
new
(
pods
.
map
do
|
pod
|
#
# @return [void]
#
# TODO: Why is this added to the copy resources script?
#
def
create_bridge_support_file
if
target_definition
.
podfile
.
generate_bridge_support?
UI
.
message
"- Generating BridgeSupport metadata at
#{
UI
.
path
library
.
bridge_support_path
}
"
do
generator
=
Generator
::
BridgeSupport
.
new
(
pods
.
map
do
|
pod
|
pod
.
relative_header_files
.
map
{
|
header
|
sandbox
.
root
+
header
}
pod
.
relative_header_files
.
map
{
|
header
|
sandbox
.
root
+
header
}
end
.
flatten
)
end
.
flatten
)
generator
.
save_as
(
library
.
bridge_support_path
)
copy_resources_script
.
resources
<<
library
.
bridge_support_name
end
end
# TODO This has to be removed, but this means the specs have to be updated if they need a reference to the prefix header.
def
prefix_header_filename
@target_definition
.
prefix_header_name
end
# TODO move out to Generator::PrefixHeader
def
save_prefix_header_as
(
pathname
,
pods
)
pathname
.
open
(
'w'
)
do
|
header
|
header
.
puts
"#ifdef __OBJC__"
header
.
puts
"#import
#{
@target_definition
.
platform
==
:ios
?
'<UIKit/UIKit.h>'
:
'<Cocoa/Cocoa.h>'
}
"
header
.
puts
"#endif"
pods
.
each
do
|
pod
|
if
prefix_header_contents
=
pod
.
top_specification
.
prefix_header_contents
header
.
puts
header
.
puts
prefix_header_contents
elsif
prefix_header
=
pod
.
prefix_header_file
header
.
puts
header
.
puts
prefix_header
.
read
end
end
end
end
# Creates a script that copies the resources to the bundle of the client
# target.
#
# TODO: This should be replaced by an Xcode copy resources build phase.
#
# @return [void]
#
def
create_copy_resources_script
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
library
.
copy_resources_script_path
)
}
"
do
copy_resources_script
.
resources
<<
pods
.
map
{
|
p
|
p
.
relative_resource_files
}.
flatten
copy_resources_script
.
save_as
(
library
.
copy_resources_script_path
)
end
end
end
end
def
target_support_files
#-----------------------------------------------------------------------#
[
:copy_resources_script_name
,
:prefix_header_name
,
:xcconfig_name
].
map
{
|
file
|
@target_definition
.
send
(
file
)
}
end
def
configure_build_configurations
(
xcconfig_file
,
sandbox
)
# @!group Installation products.
@target
.
build_configurations
.
each
do
|
config
|
config
.
base_configuration_reference
=
xcconfig_file
config
.
build_settings
[
'OTHER_LDFLAGS'
]
=
''
config
.
build_settings
[
'GCC_PREFIX_HEADER'
]
=
@target_definition
.
prefix_header_name
config
.
build_settings
[
'PODS_ROOT'
]
=
'${SRCROOT}'
config
.
build_settings
[
'PODS_HEADERS_SEARCH_PATHS'
]
=
'${PODS_BUILD_HEADERS_SEARCH_PATHS}'
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
]
=
@target_definition
.
inhibit_all_warnings?
?
'YES'
:
'NO'
end
end
public
# @return [Library] the library for the target definition.
#
#
# @note Generated by the {#add_target} step.
#
#
def
create_files
(
pods
,
sandbox
)
attr_reader
:library
bridge_support_metadata_path
=
sandbox
.
root
+
@target_definition
.
bridge_support_name
UI
.
message
"- Generating BridgeSupport metadata file at
#{
UI
.
path
bridge_support_metadata_path
}
"
do
bridge_support_generator_for
(
pods
,
sandbox
).
save_as
(
bridge_support_metadata_path
)
copy_resources_script_for
(
pods
).
resources
<<
@target_definition
.
bridge_support_name
end
if
@podfile
.
generate_bridge_support?
UI
.
message
"- Generating xcconfig file at
#{
UI
.
path
(
sandbox
.
root
+
@target_definition
.
xcconfig_name
)
}
"
do
# @return [PBXNativeTarget] the target generated by the installation
generate_xcconfig
(
pods
,
sandbox
)
# process.
xcconfig
.
save_as
(
sandbox
.
root
+
@target_definition
.
xcconfig_name
)
#
@target_definition
.
xcconfig
=
xcconfig
# @note Generated by the {#add_target} step.
end
#
attr_reader
:target
UI
.
message
"- Generating prefix header at
#{
UI
.
path
(
sandbox
.
root
+
@target_definition
.
prefix_header_name
)
}
"
do
# @return [PBXFileReference] the file reference to the xcconfig file of
save_prefix_header_as
(
sandbox
.
root
+
@target_definition
.
prefix_header_name
,
pods
)
# the target.
end
#
# @note Generated by the {#add_file_reference_for_support_files} step.
#
attr_reader
:xcconfig_file_ref
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
sandbox
.
root
+
@target_definition
.
copy_resources_script_name
)
}
"
do
#-----------------------------------------------------------------------#
copy_resources_script_for
(
pods
).
save_as
(
sandbox
.
root
+
@target_definition
.
copy_resources_script_name
)
end
# @!group Private helpers.
end
private
private
def
quoted
(
strings
)
# @return [Sandbox] sandbox the sandbox where the support files should
strings
.
map
{
|
s
|
"
\"
#{
s
}
\"
"
}
# be generated.
#
def
sandbox
project
.
sandbox
end
end
# Creates and caches the copy resource script.
#
# @return [CopyResourcesScript]
#
# TODO: This should be replaced by an Xcode copy resources build phase.
#
def
copy_resources_script
@copy_resources_script
||=
Generator
::
CopyResourcesScript
.
new
end
# Converts an array of strings to a single string where the each string
# is surrounded by double quotes and separated by a space. Used to
# represent strings in a xcconfig file.
#
# @param [Array<String>] strings
# a list of strings.
#
# @return [String] the resulting string.
#
def
quote
(
strings
)
strings
.
map
{
|
s
|
%W|"
#{
s
}
"|
}.
join
(
" "
)
end
# @return [String] the default linker flags. `-ObjC` is always included
# while `-fobjc-arc` is included only if requested in the
# Podfile.
#
def
default_ld_flags
def
default_ld_flags
flags
=
%w{-ObjC}
flags
=
%w[ -ObjC ]
flags
<<
'-fobjc-arc'
if
@podfile
.
set_arc_compatibility_flag?
&&
self
.
requires_arc
requires_arc
=
pods
.
any?
{
|
pod
|
pod
.
requires_arc?
}
if
requires_arc
&&
target_definition
.
podfile
.
set_arc_compatibility_flag?
flags
<<
'-fobjc-arc'
end
flags
.
join
(
" "
)
flags
.
join
(
" "
)
end
end
end
end
...
...
spec/spec_helper.rb
View file @
21af2670
...
@@ -44,7 +44,7 @@ config = Pod::Config.instance
...
@@ -44,7 +44,7 @@ config = Pod::Config.instance
config
.
silent
=
true
config
.
silent
=
true
config
.
repos_dir
=
SpecHelper
.
tmp_repos_path
config
.
repos_dir
=
SpecHelper
.
tmp_repos_path
config
.
project_root
=
SpecHelper
.
temporary_directory
config
.
project_root
=
SpecHelper
.
temporary_directory
Pod
::
Specification
::
Statistics
.
instance
.
cache_file
=
nil
Pod
::
Specification
::
S
et
::
S
tatistics
.
instance
.
cache_file
=
nil
require
'tmpdir'
require
'tmpdir'
...
@@ -77,3 +77,4 @@ VCR.configure do |c|
...
@@ -77,3 +77,4 @@ VCR.configure do |c|
c
.
allow_http_connections_when_no_cassette
=
true
c
.
allow_http_connections_when_no_cassette
=
true
end
end
require
"active_support/core_ext/string/strip"
spec/unit/installer/target_installer_spec.rb
View file @
21af2670
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
TMP_POD_ROOT
=
ROOT
+
"tmp"
+
"podroot"
unless
defined?
TMP_POD_ROOT
describe
TargetInstaller
=
Pod
::
Installer
::
TargetInstaller
do
describe
Pod
::
Installer
::
TargetInstaller
do
describe
"In general"
do
before
do
@podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
end
@target_definition
=
@podfile
.
target_definitions
[
:default
]
@project
=
Pod
::
Project
.
new
(
config
.
sandbox
)
@specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@pods
=
[
Pod
::
LocalPod
.
new
(
@specification
,
config
.
sandbox
,
Pod
::
Platform
.
ios
)]
@installer
=
TargetInstaller
.
new
(
@project
,
@target_definition
,
@pods
,)
end
it
"returns the project"
do
@installer
.
project
.
should
==
@project
end
it
"returns the target_definition"
do
@installer
.
target_definition
.
should
==
@target_definition
end
it
"returns the pods of the target definition"
do
@installer
.
pods
.
should
==
@pods
end
end
describe
"Installation"
do
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryDirectory
before
do
before
do
...
@@ -11,21 +36,20 @@ describe Pod::Installer::TargetInstaller do
...
@@ -11,21 +36,20 @@ describe Pod::Installer::TargetInstaller do
xcodeproj
'dummy'
xcodeproj
'dummy'
end
end
@target_definition
=
@podfile
.
target_definitions
[
:default
]
@target_definition
=
@podfile
.
target_definitions
[
:default
]
@project
=
Pod
::
Project
.
new
(
config
.
sandbox
)
specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@pod
=
Pod
::
LocalPod
.
new
(
specification
,
config
.
sandbox
,
@target_definition
.
platform
)
@installer
=
TargetInstaller
.
new
(
@project
,
@target_definition
,
[
@pod
])
@project
=
Pod
::
Project
.
new
specification
.
prefix_header_contents
=
'#import "BlocksKit.h"'
@project
.
new_group
(
'Targets Support Files'
)
@pod
.
stubs
(
:root
).
returns
(
Pathname
.
new
(
fixture
(
'banana-lib'
)))
@installer
=
Pod
::
Installer
::
TargetInstaller
.
new
(
@podfile
,
@project
,
@target_definition
)
@sandbox
=
Pod
::
Sandbox
.
new
(
TMP_POD_ROOT
)
FileUtils
.
cp_r
(
fixture
(
'banana-lib'
),
TMP_POD_ROOT
+
'BananaLib'
)
@specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@pods
=
[
Pod
::
LocalPod
.
new
(
@specification
,
@sandbox
,
Pod
::
Platform
.
ios
)]
end
end
def
do_install!
def
do_install!
@pods
.
each
{
|
pod
|
pod
.
add_file_references_to_project
(
@project
)
}
# Prevent raise for missing dummy project.
@installer
.
install!
(
@pods
,
@sandbox
)
Pathname
.
any_instance
.
stubs
(
:exist?
).
returns
(
true
)
@pod
.
add_file_references_to_project
(
@project
)
@installer
.
install
end
end
it
'adds a new static library target to the project'
do
it
'adds a new static library target to the project'
do
...
@@ -34,38 +58,43 @@ describe Pod::Installer::TargetInstaller do
...
@@ -34,38 +58,43 @@ describe Pod::Installer::TargetInstaller do
@project
.
targets
.
first
.
name
.
should
==
@target_definition
.
label
@project
.
targets
.
first
.
name
.
should
==
@target_definition
.
label
end
end
it
"adds the user's build configurations to the target"
do
it
'adds the source files of each pod to the target of the Pod library'
do
@project
.
user_build_configurations
=
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
'AppStore'
=>
:release
,
'Test'
=>
:debug
}
do_install!
do_install!
@project
.
targets
.
first
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
%w{ AppStore Debug Release Test }
names
=
@installer
.
target
.
source_build_phase
.
files
.
map
{
|
bf
|
bf
.
file_ref
.
name
}
names
.
should
==
[
"Banana.m"
]
end
end
it
'adds each pod to the static library target'
do
it
"adds file references for the support files of the target"
do
@pods
[
0
].
expects
(
:add_build_files_to_target
)
do_install!
do_install!
group
=
@project
.
support_files_group
[
'Pods'
]
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
"Pods-prefix.pch"
,
"Pods-resources.sh"
,
"Pods.xcconfig"
]
end
end
# TODO: move to project
#--------------------------------------#
# it 'tells each pod to link its headers' do
# @pods[0].expects(:link_headers)
it
"adds the user's build configurations to the target"
do
# do_install!
@project
.
user_build_configurations
=
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
'AppStore'
=>
:release
,
'Test'
=>
:debug
}
# end
do_install!
@project
.
targets
.
first
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
%w{ AppStore Debug Release Test }
end
it
'adds the sandbox header search paths to the xcconfig, with quotes'
do
it
'adds the sandbox header search paths to the xcconfig, with quotes'
do
do_install!
do_install!
@installer
.
xcconfig
.
to_hash
[
'PODS_BUILD_HEADERS_SEARCH_PATHS'
].
should
.
include
(
"
\"
#{
@
sandbox
.
build_headers
.
search_paths
.
join
(
'" "'
)
}
\"
"
)
@installer
.
library
.
xcconfig
.
to_hash
[
'PODS_BUILD_HEADERS_SEARCH_PATHS'
].
should
.
include
(
"
\"
#{
config
.
sandbox
.
build_headers
.
search_paths
.
join
(
'" "'
)
}
\"
"
)
end
end
it
'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it'
do
it
'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it'
do
do_install!
do_install!
@installer
.
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
" "
).
should
.
not
.
include
(
"-fobjc-arc"
)
@installer
.
library
.
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
" "
).
should
.
not
.
include
(
"-fobjc-arc"
)
end
end
it
'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc (to support non-ARC projects on iOS 4.0)'
do
it
'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc (to support non-ARC projects on iOS 4.0)'
do
@podfil
e
.
stubs
(
:set_arc_compatibility_flag?
=>
true
)
Pod
::
Podfile
.
any_instanc
e
.
stubs
(
:set_arc_compatibility_flag?
=>
true
)
@
specification
.
stubs
(
:requires_arc
).
returns
(
true
)
@pod
.
top_
specification
.
stubs
(
:requires_arc
).
returns
(
true
)
do_install!
do_install!
@installer
.
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
" "
).
should
.
include
(
"-fobjc-arc"
)
@installer
.
library
.
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
" "
).
should
.
include
(
"-fobjc-arc"
)
end
end
it
"does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default"
do
it
"does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default"
do
...
@@ -83,30 +112,43 @@ describe Pod::Installer::TargetInstaller do
...
@@ -83,30 +112,43 @@ describe Pod::Installer::TargetInstaller do
end
end
end
end
it
"creates a prefix header, including the contents of the specification's prefix header
file"
do
it
"creates and xcconfig
file"
do
do_install!
do_install!
prefix_header
=
@sandbox
.
root
+
'Pods.pch'
xcconfig
=
config
.
sandbox
.
root
+
'Pods.xcconfig'
@installer
.
save_prefix_header_as
(
prefix_header
,
@pods
)
xcconfig
.
read
.
should
==
<<-
EOS
.
strip_heredoc
.
gsub
(
/\n$/
,
''
)
prefix_header
.
read
.
should
==
<<-
EOS
ALWAYS_SEARCH_USER_PATHS = YES
#ifdef __OBJC__
OTHER_LDFLAGS = -ObjC -framework SystemConfiguration
#import <UIKit/UIKit.h>
HEADER_SEARCH_PATHS = ${PODS_HEADERS_SEARCH_PATHS}
#endif
PODS_ROOT = ${SRCROOT}/Pods
PODS_BUILD_HEADERS_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders"
#import <BananaTree/BananaTree.h>
PODS_PUBLIC_HEADERS_SEARCH_PATHS = "${PODS_ROOT}/Headers"
EOS
PODS_HEADERS_SEARCH_PATHS = ${PODS_PUBLIC_HEADERS_SEARCH_PATHS}
EOS
end
end
it
"creates a prefix header, including the contents of the specification's prefix header"
do
it
"creates a prefix header, including the contents of the specification's prefix header"
do
@pod
.
top_specification
.
prefix_header_contents
=
'#import "BlocksKit.h"'
do_install!
prefix_header
=
config
.
sandbox
.
root
+
'Pods-prefix.pch'
prefix_header
.
read
.
should
==
<<-
EOS
.
strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "BlocksKit.h"
EOS
end
it
"creates a bridge support file"
do
Pod
::
Podfile
.
any_instance
.
stubs
(
:generate_bridge_support?
=>
true
)
Pod
::
Generator
::
BridgeSupport
.
any_instance
.
expects
(
:save_as
).
once
do_install!
do_install!
prefix_header
=
@sandbox
.
root
+
'Pods.pch'
end
@specification
.
prefix_header_contents
=
'#import "BlocksKit.h"'
@installer
.
save_prefix_header_as
(
prefix_header
,
@pods
)
it
"creates a create copy resources script"
do
prefix_header
.
read
.
should
==
<<-
EOS
do_install!
#ifdef __OBJC__
script
=
config
.
sandbox
.
root
+
'Pods-resources.sh'
#import <UIKit/UIKit.h>
script
.
read
.
should
.
include?
(
'logo-sidebar.png'
)
#endif
end
#import "BlocksKit.h"
EOS
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