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
c8ce4ad1
Commit
c8ce4ad1
authored
Oct 21, 2014
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2461 from mrackwitz/refactorings
Refactorings in Preparation to Framework Support
parents
ca511f0f
8f0a245e
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
225 additions
and
135 deletions
+225
-135
CHANGELOG.md
CHANGELOG.md
+5
-0
cocoapods.rb
lib/cocoapods.rb
+1
-0
header.rb
lib/cocoapods/generator/header.rb
+75
-0
prefix_header.rb
lib/cocoapods/generator/prefix_header.rb
+15
-34
library_representation.rb
lib/cocoapods/hooks/library_representation.rb
+1
-1
installer.rb
lib/cocoapods/installer.rb
+3
-3
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+21
-21
aggregate_target_installer.rb
.../installer/target_installer/aggregate_target_installer.rb
+17
-17
pod_target_installer.rb
...oapods/installer/target_installer/pod_target_installer.rb
+19
-19
target.rb
lib/cocoapods/target.rb
+1
-1
pod_target.rb
lib/cocoapods/target/pod_target.rb
+2
-2
header_spec.rb
spec/unit/generator/header_spec.rb
+38
-0
prefix_header_spec.rb
spec/unit/generator/prefix_header_spec.rb
+0
-10
library_representation_spec.rb
spec/unit/hooks/library_representation_spec.rb
+1
-1
aggregate_target_installer_spec.rb
...aller/target_installer/aggregate_target_installer_spec.rb
+2
-2
pod_target_installer_spec.rb
...t/installer/target_installer/pod_target_installer_spec.rb
+7
-7
target_installer_spec.rb
spec/unit/installer/target_installer_spec.rb
+3
-3
user_project_integrator_spec.rb
spec/unit/installer/user_project_integrator_spec.rb
+14
-14
No files found.
CHANGELOG.md
View file @
c8ce4ad1
...
...
@@ -10,6 +10,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
repo push`
in CocoaPods 0.33.
[
Fabio Pelosin
](
https://github.com/fabiopelosin
)
*
Refactorings in preparation to framework support, which could break usages
of the Hooks-API.
[
Marius Rackwitz
](
https://github.com/mrackwitz
)
[
#2461
](
https://github.com/CocoaPods/CocoaPods/issues/2461
)
## 0.34.4
...
...
lib/cocoapods.rb
View file @
c8ce4ad1
...
...
@@ -56,6 +56,7 @@ module Pod
autoload
:BridgeSupport
,
'cocoapods/generator/bridge_support'
autoload
:CopyResourcesScript
,
'cocoapods/generator/copy_resources_script'
autoload
:DummySource
,
'cocoapods/generator/dummy_source'
autoload
:Header
,
'cocoapods/generator/header'
autoload
:PrefixHeader
,
'cocoapods/generator/prefix_header'
autoload
:TargetEnvironmentHeader
,
'cocoapods/generator/target_environment_header'
autoload
:XCConfig
,
'cocoapods/generator/xcconfig'
...
...
lib/cocoapods/generator/header.rb
0 → 100644
View file @
c8ce4ad1
module
Pod
module
Generator
# Generates a header file.
#
# According to the platform the header imports `UIKit/UIKit.h` or
# `Cocoa/Cocoa.h`.
#
class
Header
# @return [Symbol] the platform for which the prefix header will be
# generated.
#
attr_reader
:platform
# @return [Array<String>] The list of the headers to import.
#
attr_reader
:imports
# @param [Symbol] platform
# @see platform
#
def
initialize
(
platform
)
@platform
=
platform
@imports
=
[]
end
# Generates the contents of the header according to the platform.
#
# @note If the platform is iOS an import call to `UIKit/UIKit.h` is
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported.
#
# @return [String]
#
def
generate
result
=
""
result
<<
generate_platform_import_header
result
<<
"
\n
"
imports
.
each
do
|
import
|
result
<<
%|#import "#{import}"\n|
end
result
end
# Generates and saves the header to the given path.
#
# @param [Pathname] path
# The path where the header should be stored.
#
# @return [void]
#
def
save_as
(
path
)
path
.
open
(
'w'
)
{
|
header
|
header
.
write
(
generate
)
}
end
#-----------------------------------------------------------------------#
protected
# Generates the contents of the header according to the platform.
#
# @note If the platform is iOS an import call to `UIKit/UIKit.h` is
# added to the top of the header. For OS X `Cocoa/Cocoa.h` is
# imported.
#
# @return [String]
#
def
generate_platform_import_header
"#import
#{
platform
==
:ios
?
'<UIKit/UIKit.h>'
:
'<Cocoa/Cocoa.h>'
}
\n
"
end
end
end
end
lib/cocoapods/generator/prefix_header.rb
View file @
c8ce4ad1
...
...
@@ -6,38 +6,26 @@ module Pod
# According to the platform the prefix header imports `UIKit/UIKit.h` or
# `Cocoa/Cocoa.h`.
#
class
PrefixHeader
class
PrefixHeader
<
Header
# @return [Array<FileAccessor>] The file accessors for which to generate
# the prefix header.
#
attr_reader
:file_accessors
# @
return [Platform] the platform for which the prefix header will be
#
generated.
# @
param [Array<FileAccessor>] file_accessors
#
@see file_accessors
#
attr_reader
:platform
# @return [Array<String>] The list of the headers to import (with
# quotes).
#
attr_reader
:imports
# @param [Platform] platform @see platform
# @param [Array<LocalPod>] consumers @see consumers
# @param [Platform] platform
# @see platform
#
def
initialize
(
file_accessors
,
platform
)
@file_accessors
=
file_accessors
@platform
=
platform
@imports
=
[]
super
platform
end
# Generates the contents of the prefix header according to the platform
# and the pods.
#
# @note If the platform is iOS an import call to `UIKit/UIKit.h` is
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported.
#
# @note Only unique prefix_header_contents are added to the prefix
# header.
#
...
...
@@ -48,20 +36,12 @@ module Pod
# file_accessor.prefix_header.
#
def
generate
result
=
"#ifdef __OBJC__
\n
"
result
<<
"#import
#{
platform
==
:ios
?
'<UIKit/UIKit.h>'
:
'<Cocoa/Cocoa.h>'
}
\n
"
result
<<
"#endif
\n
"
imports
.
each
do
|
import
|
result
<<
%(\n#import "#{import}")
end
result
=
super
unique_prefix_header_contents
=
file_accessors
.
map
do
|
file_accessor
|
file_accessor
.
spec_consumer
.
prefix_header_contents
end
.
compact
.
uniq
result
<<
"
\n
"
unique_prefix_header_contents
.
each
do
|
prefix_header_contents
|
result
<<
prefix_header_contents
result
<<
"
\n
"
...
...
@@ -75,15 +55,16 @@ module Pod
result
end
# Generates and saves the prefix header to the given path.
#
# @param [Pathname] path
# the path where the prefix header should be stored.
protected
# Generates the contents of the header according to the platform.
#
# @return [
void
]
# @return [
String
]
#
def
save_as
(
path
)
path
.
open
(
'w'
)
{
|
header
|
header
.
write
(
generate
)
}
def
generate_platform_import_header
result
=
"#ifdef __OBJC__
\n
"
result
<<
super
result
<<
"#endif
\n
"
end
end
end
...
...
lib/cocoapods/hooks/library_representation.rb
View file @
c8ce4ad1
...
...
@@ -69,7 +69,7 @@ module Pod
# process.
#
def
target
library
.
target
library
.
native_
target
end
#-----------------------------------------------------------------------#
...
...
lib/cocoapods/installer.rb
View file @
c8ce4ad1
...
...
@@ -418,7 +418,7 @@ module Pod
pod_targets
.
sort_by
(
&
:name
).
each
do
|
pod_target
|
pod_target
.
file_accessors
.
each
do
|
file_accessor
|
file_accessor
.
spec_consumer
.
frameworks
.
each
do
|
framework
|
pod_target
.
target
.
add_system_framework
(
framework
)
pod_target
.
native_
target
.
add_system_framework
(
framework
)
end
end
end
...
...
@@ -428,7 +428,7 @@ module Pod
def
set_target_dependencies
aggregate_targets
.
each
do
|
aggregate_target
|
aggregate_target
.
pod_targets
.
each
do
|
pod_target
|
aggregate_target
.
target
.
add_dependency
(
pod_target
.
target
)
aggregate_target
.
native_target
.
add_dependency
(
pod_target
.
native_
target
)
pod_target
.
dependencies
.
each
do
|
dep
|
unless
dep
==
pod_target
.
pod_name
...
...
@@ -437,7 +437,7 @@ module Pod
unless
pod_dependency_target
puts
"[BUG] DEP:
#{
dep
}
"
end
pod_target
.
target
.
add_dependency
(
pod_dependency_target
.
target
)
pod_target
.
native_target
.
add_dependency
(
pod_dependency_target
.
native_
target
)
end
end
end
...
...
lib/cocoapods/installer/target_installer.rb
View file @
c8ce4ad1
...
...
@@ -10,16 +10,16 @@ module Pod
#
attr_reader
:sandbox
# @return [
Library
] The library whose target needs to be generated.
# @return [
Target
] The library whose target needs to be generated.
#
attr_reader
:
library
attr_reader
:
target
# @param [Project] project @see project
# @param [
Library] library @see library
# @param [
Target] target @see target
#
def
initialize
(
sandbox
,
library
)
def
initialize
(
sandbox
,
target
)
@sandbox
=
sandbox
@
library
=
library
@
target
=
target
end
private
...
...
@@ -36,31 +36,31 @@ module Pod
# @return [void]
#
def
add_target
name
=
library
.
label
platform
=
library
.
platform
.
name
deployment_target
=
library
.
platform
.
deployment_target
.
to_s
@target
=
project
.
new_target
(
:static_library
,
name
,
platform
,
deployment_target
)
name
=
target
.
label
platform
=
target
.
platform
.
name
deployment_target
=
target
.
platform
.
deployment_target
.
to_s
@
native_
target
=
project
.
new_target
(
:static_library
,
name
,
platform
,
deployment_target
)
library
.
user_build_configurations
.
each
do
|
bc_name
,
type
|
configuration
=
@target
.
add_build_configuration
(
bc_name
,
type
)
target
.
user_build_configurations
.
each
do
|
bc_name
,
type
|
configuration
=
@
native_
target
.
add_build_configuration
(
bc_name
,
type
)
end
settings
=
{
'OTHER_LDFLAGS'
=>
''
,
'OTHER_LIBTOOLFLAGS'
=>
''
}
if
library
.
archs
settings
[
'ARCHS'
]
=
library
.
archs
if
target
.
archs
settings
[
'ARCHS'
]
=
target
.
archs
end
@target
.
build_configurations
.
each
do
|
configuration
|
@
native_
target
.
build_configurations
.
each
do
|
configuration
|
configuration
.
build_settings
.
merge!
(
settings
)
end
library
.
target
=
@
target
target
.
native_target
=
@native_
target
end
# Creates the directory where to store the support files of the target.
#
def
create_support_files_dir
library
.
support_files_dir
.
mkdir
target
.
support_files_dir
.
mkdir
end
# Generates a dummy source file for each target so libraries that contain
...
...
@@ -69,11 +69,11 @@ module Pod
# @return [void]
#
def
create_dummy_source
path
=
library
.
dummy_source_path
generator
=
Generator
::
DummySource
.
new
(
library
.
label
)
path
=
target
.
dummy_source_path
generator
=
Generator
::
DummySource
.
new
(
target
.
label
)
generator
.
save_as
(
path
)
file_reference
=
add_file_to_support_group
(
path
)
target
.
source_build_phase
.
add_file_reference
(
file_reference
)
native_
target
.
source_build_phase
.
add_file_reference
(
file_reference
)
end
# @return [PBXNativeTarget] the target generated by the installation
...
...
@@ -81,7 +81,7 @@ module Pod
#
# @note Generated by the {#add_target} step.
#
attr_reader
:target
attr_reader
:
native_
target
private
...
...
@@ -98,7 +98,7 @@ module Pod
# @return [TargetDefinition] the target definition of the library.
#
def
target_definition
library
.
target_definition
target
.
target_definition
end
# @return [PBXGroup] the group where the file references to the support
...
...
lib/cocoapods/installer/target_installer/aggregate_target_installer.rb
View file @
c8ce4ad1
...
...
@@ -9,7 +9,7 @@ module Pod
# @return [void]
#
def
install!
UI
.
message
"- Installing target `
#{
library
.
name
}
`
#{
library
.
platform
}
"
do
UI
.
message
"- Installing target `
#{
target
.
name
}
`
#{
target
.
platform
}
"
do
add_target
create_support_files_dir
create_suport_files_group
...
...
@@ -33,8 +33,8 @@ module Pod
#
def
create_suport_files_group
parent
=
project
.
support_files_group
name
=
library
.
name
dir
=
library
.
support_files_dir
name
=
target
.
name
dir
=
target
.
support_files_dir
@support_files_group
=
parent
.
new_group
(
name
,
dir
)
end
...
...
@@ -43,11 +43,11 @@ module Pod
# @return [void]
#
def
create_xcconfig_file
target
.
build_configurations
.
each
do
|
configuration
|
path
=
library
.
xcconfig_path
(
configuration
.
name
)
gen
=
Generator
::
XCConfig
::
AggregateXCConfig
.
new
(
library
,
configuration
.
name
)
native_
target
.
build_configurations
.
each
do
|
configuration
|
path
=
target
.
xcconfig_path
(
configuration
.
name
)
gen
=
Generator
::
XCConfig
::
AggregateXCConfig
.
new
(
target
,
configuration
.
name
)
gen
.
save_as
(
path
)
library
.
xcconfigs
[
configuration
.
name
]
=
gen
.
xcconfig
target
.
xcconfigs
[
configuration
.
name
]
=
gen
.
xcconfig
xcconfig_file_ref
=
add_file_to_support_group
(
path
)
configuration
.
base_configuration_reference
=
xcconfig_file_ref
end
...
...
@@ -57,8 +57,8 @@ module Pod
# pods and the installed specifications of a pod.
#
def
create_target_environment_header
path
=
library
.
target_environment_header_path
generator
=
Generator
::
TargetEnvironmentHeader
.
new
(
library
.
specs_by_build_configuration
)
path
=
target
.
target_environment_header_path
generator
=
Generator
::
TargetEnvironmentHeader
.
new
(
target
.
specs_by_build_configuration
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
...
...
@@ -66,15 +66,15 @@ module Pod
# Generates the bridge support metadata if requested by the {Podfile}.
#
# @note The bridge support metadata is added to the resources of the
#
library
because it is needed for environments interpreted at
#
target
because it is needed for environments interpreted at
# runtime.
#
# @return [void]
#
def
create_bridge_support_file
if
target_definition
.
podfile
.
generate_bridge_support?
path
=
library
.
bridge_support_path
headers
=
target
.
headers_build_phase
.
files
.
map
{
|
bf
|
sandbox
.
root
+
bf
.
file_ref
.
path
}
path
=
target
.
bridge_support_path
headers
=
native_
target
.
headers_build_phase
.
files
.
map
{
|
bf
|
sandbox
.
root
+
bf
.
file_ref
.
path
}
generator
=
Generator
::
BridgeSupport
.
new
(
headers
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
...
...
@@ -91,15 +91,15 @@ module Pod
# @return [void]
#
def
create_copy_resources_script
path
=
library
.
copy_resources_script_path
file_accessors
=
library
.
pod_targets
.
map
(
&
:file_accessors
).
flatten
path
=
target
.
copy_resources_script_path
file_accessors
=
target
.
pod_targets
.
map
(
&
:file_accessors
).
flatten
resource_paths
=
file_accessors
.
map
{
|
accessor
|
accessor
.
resources
.
flatten
.
map
{
|
res
|
res
.
relative_path_from
(
project
.
path
.
dirname
)
}
}.
flatten
resource_bundles
=
file_accessors
.
map
{
|
accessor
|
accessor
.
resource_bundles
.
keys
.
map
{
|
name
|
"${BUILT_PRODUCTS_DIR}/
#{
name
}
.bundle"
}
}.
flatten
resources
=
[]
resources
.
concat
(
resource_paths
)
resources
.
concat
(
resource_bundles
)
resources
<<
bridge_support_file
if
bridge_support_file
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources
,
library
.
platform
)
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources
,
target
.
platform
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
...
...
@@ -109,10 +109,10 @@ module Pod
# @return [void]
#
def
create_acknowledgements
basepath
=
library
.
acknowledgements_basepath
basepath
=
target
.
acknowledgements_basepath
Generator
::
Acknowledgements
.
generators
.
each
do
|
generator_class
|
path
=
generator_class
.
path_from_basepath
(
basepath
)
file_accessors
=
library
.
pod_targets
.
map
(
&
:file_accessors
).
flatten
file_accessors
=
target
.
pod_targets
.
map
(
&
:file_accessors
).
flatten
generator
=
generator_class
.
new
(
file_accessors
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
...
...
lib/cocoapods/installer/target_installer/pod_target_installer.rb
View file @
c8ce4ad1
...
...
@@ -9,7 +9,7 @@ module Pod
# @return [void]
#
def
install!
UI
.
message
"- Installing target `
#{
library
.
name
}
`
#{
library
.
platform
}
"
do
UI
.
message
"- Installing target `
#{
target
.
name
}
`
#{
target
.
platform
}
"
do
add_target
create_support_files_dir
add_files_to_build_phases
...
...
@@ -33,15 +33,15 @@ module Pod
# @return [void]
#
def
add_files_to_build_phases
library
.
file_accessors
.
each
do
|
file_accessor
|
target
.
file_accessors
.
each
do
|
file_accessor
|
consumer
=
file_accessor
.
spec_consumer
flags
=
compiler_flags_for_consumer
(
consumer
)
all_source_files
=
file_accessor
.
source_files
regular_source_files
=
all_source_files
.
reject
{
|
sf
|
sf
.
extname
==
'.d'
}
regular_file_refs
=
regular_source_files
.
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
target
.
add_file_references
(
regular_file_refs
,
flags
)
native_
target
.
add_file_references
(
regular_file_refs
,
flags
)
other_file_refs
=
(
all_source_files
-
regular_source_files
).
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
target
.
add_file_references
(
other_file_refs
,
nil
)
native_
target
.
add_file_references
(
other_file_refs
,
nil
)
end
end
...
...
@@ -53,22 +53,22 @@ module Pod
# @return [void]
#
def
add_resources_bundle_targets
library
.
file_accessors
.
each
do
|
file_accessor
|
target
.
file_accessors
.
each
do
|
file_accessor
|
file_accessor
.
resource_bundles
.
each
do
|
bundle_name
,
paths
|
# Add a dependency on an existing Resource Bundle target if possible
if
bundle_target
=
project
.
targets
.
find
{
|
target
|
target
.
name
==
bundle_name
}
target
.
add_dependency
(
bundle_target
)
native_
target
.
add_dependency
(
bundle_target
)
next
end
file_references
=
paths
.
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
bundle_target
=
project
.
new_resources_bundle
(
bundle_name
,
file_accessor
.
spec_consumer
.
platform_name
)
bundle_target
.
add_resources
(
file_references
)
library
.
user_build_configurations
.
each
do
|
bc_name
,
type
|
target
.
user_build_configurations
.
each
do
|
bc_name
,
type
|
bundle_target
.
add_build_configuration
(
bc_name
,
type
)
end
target
.
add_dependency
(
bundle_target
)
native_
target
.
add_dependency
(
bundle_target
)
end
end
end
...
...
@@ -78,17 +78,17 @@ module Pod
# @return [void]
#
def
create_xcconfig_file
path
=
library
.
xcconfig_path
public_gen
=
Generator
::
XCConfig
::
PublicPodXCConfig
.
new
(
library
)
path
=
target
.
xcconfig_path
public_gen
=
Generator
::
XCConfig
::
PublicPodXCConfig
.
new
(
target
)
public_gen
.
save_as
(
path
)
add_file_to_support_group
(
path
)
path
=
library
.
xcconfig_private_path
private_gen
=
Generator
::
XCConfig
::
PrivatePodXCConfig
.
new
(
library
,
public_gen
.
xcconfig
)
path
=
target
.
xcconfig_private_path
private_gen
=
Generator
::
XCConfig
::
PrivatePodXCConfig
.
new
(
target
,
public_gen
.
xcconfig
)
private_gen
.
save_as
(
path
)
xcconfig_file_ref
=
add_file_to_support_group
(
path
)
target
.
build_configurations
.
each
do
|
c
|
native_
target
.
build_configurations
.
each
do
|
c
|
c
.
base_configuration_reference
=
xcconfig_file_ref
end
end
...
...
@@ -100,13 +100,13 @@ module Pod
# @return [void]
#
def
create_prefix_header
path
=
library
.
prefix_header_path
generator
=
Generator
::
PrefixHeader
.
new
(
library
.
file_accessors
,
library
.
platform
)
generator
.
imports
<<
library
.
target_environment_header_path
.
basename
path
=
target
.
prefix_header_path
generator
=
Generator
::
PrefixHeader
.
new
(
target
.
file_accessors
,
target
.
platform
)
generator
.
imports
<<
target
.
target_environment_header_path
.
basename
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
target
.
build_configurations
.
each
do
|
c
|
native_
target
.
build_configurations
.
each
do
|
c
|
relative_path
=
path
.
relative_path_from
(
project
.
path
.
dirname
)
c
.
build_settings
[
'GCC_PREFIX_HEADER'
]
=
relative_path
.
to_s
end
...
...
@@ -176,8 +176,8 @@ module Pod
# @return [PBXFileReference] the file reference of the added file.
#
def
add_file_to_support_group
(
path
)
pod_name
=
library
.
pod_name
dir
=
library
.
support_files_dir
pod_name
=
target
.
pod_name
dir
=
target
.
support_files_dir
group
=
project
.
pod_support_files_group
(
pod_name
,
dir
)
group
.
new_file
(
path
)
end
...
...
lib/cocoapods/target.rb
View file @
c8ce4ad1
...
...
@@ -52,7 +52,7 @@ module Pod
# @return [PBXNativeTarget] the target generated in the Pods project for
# this library.
#
attr_accessor
:target
attr_accessor
:
native_
target
# @return [Platform] the platform for this library.
#
...
...
lib/cocoapods/target/pod_target.rb
View file @
c8ce4ad1
...
...
@@ -57,8 +57,8 @@ module Pod
# depends.
#
def
dependencies
spec
s
.
map
do
|
spec
|
spec
.
consumer
(
platform
)
.
dependencies
.
map
{
|
dep
|
Specification
.
root_name
(
dep
.
name
)
}
spec
_consumers
.
map
do
|
consumer
|
consumer
.
dependencies
.
map
{
|
dep
|
Specification
.
root_name
(
dep
.
name
)
}
end
.
flatten
end
...
...
spec/unit/generator/header_spec.rb
0 → 100644
View file @
c8ce4ad1
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Header
=
Generator
::
Header
do
before
do
@gen
=
Header
.
new
(
Pod
::
Platform
.
ios
)
end
it
'includes the imports'
do
@gen
.
imports
<<
'header.h'
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
#import <UIKit/UIKit.h>
#import "header.h"
EOS
end
it
'imports UIKit in iOS platforms'
do
@gen
.
stubs
(
:platform
).
returns
(
Pod
::
Platform
.
ios
)
@gen
.
generate
.
should
.
include?
(
'#import <UIKit/UIKit.h>'
)
end
it
'imports Cocoa for OS X platforms'
do
@gen
.
stubs
(
:platform
).
returns
(
Pod
::
Platform
.
osx
)
@gen
.
generate
.
should
.
include?
(
'#import <Cocoa/Cocoa.h>'
)
end
it
'writes the header file to the disk'
do
path
=
temporary_directory
+
'Test.h'
@gen
.
save_as
(
path
)
path
.
read
.
should
==
<<-
EOS
.
strip_heredoc
#import <UIKit/UIKit.h>
EOS
end
end
end
spec/unit/generator/prefix_header_spec.rb
View file @
c8ce4ad1
...
...
@@ -80,16 +80,6 @@ module Pod
EOS
end
it
'imports UIKit in iOS platforms'
do
@gen
.
stubs
(
:platform
).
returns
(
Pod
::
Platform
.
ios
)
@gen
.
generate
.
should
.
include?
(
'#import <UIKit/UIKit.h>'
)
end
it
'imports Cocoa for OS X platforms'
do
@gen
.
stubs
(
:platform
).
returns
(
Pod
::
Platform
.
osx
)
@gen
.
generate
.
should
.
include?
(
'#import <Cocoa/Cocoa.h>'
)
end
it
'writes the prefix header file to the disk'
do
path
=
temporary_directory
+
'Test.pch'
@gen
.
save_as
(
path
)
...
...
spec/unit/hooks/library_representation_spec.rb
View file @
c8ce4ad1
...
...
@@ -64,7 +64,7 @@ module Pod
it
'returns the native target'
do
target
=
stub
@lib
.
target
=
target
@lib
.
native_
target
=
target
@rep
.
target
.
should
==
target
end
...
...
spec/unit/installer/target_installer/aggregate_target_installer_spec.rb
View file @
c8ce4ad1
...
...
@@ -109,7 +109,7 @@ module Pod
it
'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default'
do
@installer
.
install!
@installer
.
library
.
target
.
build_configurations
.
each
do
|
config
|
@installer
.
target
.
native_
target
.
build_configurations
.
each
do
|
config
|
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
].
should
.
be
.
nil
end
end
...
...
@@ -166,7 +166,7 @@ module Pod
it
'creates a dummy source to ensure the creation of a single base library'
do
@installer
.
install!
build_files
=
@installer
.
library
.
target
.
source_build_phase
.
files
build_files
=
@installer
.
target
.
native_
target
.
source_build_phase
.
files
build_file
=
build_files
.
find
{
|
bf
|
bf
.
file_ref
.
path
.
include?
(
'Pods-dummy.m'
)
}
build_file
.
should
.
be
.
not
.
nil
build_file
.
file_ref
.
path
.
should
==
'Pods-dummy.m'
...
...
spec/unit/installer/target_installer/pod_target_installer_spec.rb
View file @
c8ce4ad1
...
...
@@ -88,7 +88,7 @@ module Pod
it
'does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default'
do
@installer
.
install!
@installer
.
library
.
target
.
build_configurations
.
each
do
|
config
|
@installer
.
target
.
native_
target
.
build_configurations
.
each
do
|
config
|
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
].
should
.
be
.
nil
end
end
...
...
@@ -97,7 +97,7 @@ module Pod
it
'adds the source files of each pod to the target of the Pod library'
do
@installer
.
install!
names
=
@installer
.
library
.
target
.
source_build_phase
.
files
.
map
{
|
bf
|
bf
.
file_ref
.
display_name
}
names
=
@installer
.
target
.
native_
target
.
source_build_phase
.
files
.
map
{
|
bf
|
bf
.
file_ref
.
display_name
}
names
.
should
.
include
(
'Banana.m'
)
end
...
...
@@ -142,7 +142,7 @@ module Pod
it
'creates a dummy source to ensure the compilation of libraries with only categories'
do
@installer
.
install!
build_files
=
@installer
.
library
.
target
.
source_build_phase
.
files
build_files
=
@installer
.
target
.
native_
target
.
source_build_phase
.
files
build_file
=
build_files
.
find
{
|
bf
|
bf
.
file_ref
.
display_name
==
'Pods-BananaLib-dummy.m'
}
build_file
.
should
.
be
.
not
.
nil
build_file
.
file_ref
.
path
.
should
==
'Pods-BananaLib-dummy.m'
...
...
@@ -158,10 +158,10 @@ module Pod
end
it
'flags should not be added to dtrace files'
do
@installer
.
library
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
@installer
.
install!
dtrace_files
=
@installer
.
library
.
target
.
source_build_phase
.
files
.
reject
do
|
sf
|
dtrace_files
=
@installer
.
target
.
native_target
.
source_build_phase
.
files
.
reject
do
|
sf
|
!
(
File
.
extname
(
sf
.
file_ref
.
path
)
==
'.d'
)
end
dtrace_files
.
each
do
|
dt
|
...
...
@@ -170,7 +170,7 @@ module Pod
end
it
'adds -w per pod if target definition inhibits warnings for that pod'
do
@installer
.
library
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
flags
.
should
.
include?
(
'-w'
)
...
...
@@ -182,7 +182,7 @@ module Pod
end
it
'adds -Xanalyzer -analyzer-disable-checker per pod'
do
@installer
.
library
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
@installer
.
target
.
target_definition
.
stubs
(
:inhibits_warnings_for_pod?
).
returns
(
true
)
flags
=
@installer
.
send
(
:compiler_flags_for_consumer
,
@spec
.
consumer
(
:ios
))
flags
.
should
.
include?
(
'-Xanalyzer -analyzer-disable-checker'
)
...
...
spec/unit/installer/target_installer_spec.rb
View file @
c8ce4ad1
...
...
@@ -32,7 +32,7 @@ module Pod
it
'adds the architectures to the custom build configurations of the user target'
do
@pod_target
.
archs
=
'$(ARCHS_STANDARD_64_BIT)'
@installer
.
send
(
:add_target
)
@installer
.
send
(
:target
).
resolved_build_setting
(
'ARCHS'
).
should
==
{
@installer
.
send
(
:
native_
target
).
resolved_build_setting
(
'ARCHS'
).
should
==
{
'Release'
=>
'$(ARCHS_STANDARD_64_BIT)'
,
'Debug'
=>
'$(ARCHS_STANDARD_64_BIT)'
,
'AppStore'
=>
'$(ARCHS_STANDARD_64_BIT)'
,
...
...
@@ -42,8 +42,8 @@ module Pod
it
'always clears the OTHER_LDFLAGS and OTHER_LIBTOOLFLAGS, because these lib targets do not ever need any'
do
@installer
.
send
(
:add_target
)
@installer
.
send
(
:target
).
resolved_build_setting
(
'OTHER_LDFLAGS'
).
values
.
uniq
.
should
==
[
''
]
@installer
.
send
(
:target
).
resolved_build_setting
(
'OTHER_LIBTOOLFLAGS'
).
values
.
uniq
.
should
==
[
''
]
@installer
.
send
(
:
native_
target
).
resolved_build_setting
(
'OTHER_LDFLAGS'
).
values
.
uniq
.
should
==
[
''
]
@installer
.
send
(
:
native_
target
).
resolved_build_setting
(
'OTHER_LIBTOOLFLAGS'
).
values
.
uniq
.
should
==
[
''
]
end
end
...
...
spec/unit/installer/user_project_integrator_spec.rb
View file @
c8ce4ad1
...
...
@@ -18,12 +18,12 @@ module Pod
end
config
.
sandbox
.
project
=
Project
.
new
(
config
.
sandbox
.
project_path
)
Xcodeproj
::
Project
.
new
(
config
.
sandbox
.
project_path
).
save
@
library
=
AggregateTarget
.
new
(
@podfile
.
target_definitions
[
'Pods'
],
config
.
sandbox
)
@
library
.
client_root
=
sample_project_path
.
dirname
@
library
.
user_project_path
=
sample_project_path
@
library
.
user_target_uuids
=
[
'A346496C14F9BE9A0080D870'
]
@
target
=
AggregateTarget
.
new
(
@podfile
.
target_definitions
[
'Pods'
],
config
.
sandbox
)
@
target
.
client_root
=
sample_project_path
.
dirname
@
target
.
user_project_path
=
sample_project_path
@
target
.
user_target_uuids
=
[
'A346496C14F9BE9A0080D870'
]
empty_library
=
AggregateTarget
.
new
(
@podfile
.
target_definitions
[
:empty
],
config
.
sandbox
)
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@
library
,
empty_library
])
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@
target
,
empty_library
])
end
#-----------------------------------------------------------------------#
...
...
@@ -59,10 +59,10 @@ module Pod
UI
.
warnings
=
''
target_config
=
stub
(
:name
=>
'Release'
,
:build_settings
=>
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
[
'FLAG=1'
]
})
user_target
=
stub
(
:name
=>
'SampleProject'
,
:build_configurations
=>
[
target_config
])
@
library
.
stubs
(
:user_targets
).
returns
([
user_target
])
@
target
.
stubs
(
:user_targets
).
returns
([
user_target
])
@
library
.
xcconfigs
[
'Release'
]
=
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'COCOAPODS=1'
}
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@
library
])
@
target
.
xcconfigs
[
'Release'
]
=
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'COCOAPODS=1'
}
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@
target
])
@integrator
.
unstub
(
:warn_about_xcconfig_overrides
)
@integrator
.
send
(
:warn_about_xcconfig_overrides
)
...
...
@@ -74,10 +74,10 @@ module Pod
UI
.
warnings
=
''
target_config
=
stub
(
:name
=>
'Release'
,
:build_settings
=>
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
[
'FLAG=1'
,
'${inherited}'
]
})
user_target
=
stub
(
:name
=>
'SampleProject'
,
:build_configurations
=>
[
target_config
])
@
library
.
stubs
(
:user_targets
).
returns
([
user_target
])
@
target
.
stubs
(
:user_targets
).
returns
([
user_target
])
@
library
.
xcconfigs
[
'Release'
]
=
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'COCOAPODS=1'
}
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@
library
])
@
target
.
xcconfigs
[
'Release'
]
=
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'COCOAPODS=1'
}
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@
target
])
@integrator
.
unstub
(
:warn_about_xcconfig_overrides
)
@integrator
.
send
(
:warn_about_xcconfig_overrides
)
...
...
@@ -88,10 +88,10 @@ module Pod
UI
.
warnings
=
''
target_config
=
stub
(
:name
=>
'Release'
,
:build_settings
=>
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
[
'FLAG=1'
,
'$(inherited)'
]
})
user_target
=
stub
(
:name
=>
'SampleProject'
,
:build_configurations
=>
[
target_config
])
@
library
.
stubs
(
:user_targets
).
returns
([
user_target
])
@
target
.
stubs
(
:user_targets
).
returns
([
user_target
])
@
library
.
xcconfigs
[
'Release'
]
=
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'COCOAPODS=1'
}
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@
library
])
@
target
.
xcconfigs
[
'Release'
]
=
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'COCOAPODS=1'
}
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@
target
])
@integrator
.
unstub
(
:warn_about_xcconfig_overrides
)
@integrator
.
send
(
:warn_about_xcconfig_overrides
)
...
...
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