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
78c006a9
Commit
78c006a9
authored
Sep 06, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TargetInstaller] Rename #library to @target
parent
5094ba9a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
71 deletions
+71
-71
target_installer.rb
...pods/installer/pods_project_generator/target_installer.rb
+24
-24
aggregate_target_installer.rb
..._generator/target_installer/aggregate_target_installer.rb
+15
-15
pod_target_installer.rb
...roject_generator/target_installer/pod_target_installer.rb
+21
-21
aggregate_target_installer_spec.rb
...rator/target_installer/aggregate_target_installer_spec.rb
+4
-4
pod_target_installer_spec.rb
...t_generator/target_installer/pod_target_installer_spec.rb
+7
-7
No files found.
lib/cocoapods/installer/pods_project_generator/target_installer.rb
View file @
78c006a9
...
...
@@ -3,7 +3,7 @@ module Pod
class
PodsProjectGenerator
# Controller class responsible of creating and configuring the static
#
library
target in Pods project. It also creates the support file needed
#
target
target in Pods project. It also creates the support file needed
# by the target.
#
class
TargetInstaller
...
...
@@ -13,16 +13,16 @@ module Pod
#
attr_reader
:sandbox
# @return [
Library] The library
whose target needs to be generated.
# @return [
target] The target
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
...
...
@@ -31,7 +31,7 @@ module Pod
# @!group Installation steps
#---------------------------------------------------------------------#
# Adds the target for the
library
to the Pods project with the
# Adds the target for the
target
to the Pods project with the
# appropriate build configurations.
#
# @note The `PODS_HEADERS_SEARCH_PATHS` overrides the xcconfig.
...
...
@@ -39,24 +39,24 @@ 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_target
,
name
,
platform
,
deployment_target
)
settings
=
{}
if
library
.
platform
.
requires_legacy_ios_archs?
if
target
.
platform
.
requires_legacy_ios_archs?
settings
[
'ARCHS'
]
=
"armv6 armv7"
end
@target
.
build_settings
(
'Debug'
).
merge!
(
settings
)
@target
.
build_settings
(
'Release'
).
merge!
(
settings
)
@
native_
target
.
build_settings
(
'Debug'
).
merge!
(
settings
)
@
native_
target
.
build_settings
(
'Release'
).
merge!
(
settings
)
library
.
user_build_configurations
.
each
do
|
bc_name
,
type
|
@target
.
add_build_configuration
(
bc_name
,
type
)
target
.
user_build_configurations
.
each
do
|
bc_name
,
type
|
@
native_
target
.
add_build_configuration
(
bc_name
,
type
)
end
library
.
target
=
@
target
target
.
target
=
@native_
target
end
# Creates the group that holds the references to the support files
...
...
@@ -65,7 +65,7 @@ module Pod
# @return [void]
#
def
create_suport_files_group
@support_files_group
=
project
.
support_files_group
.
new_group
(
library
.
name
)
@support_files_group
=
project
.
support_files_group
.
new_group
(
target
.
name
)
end
# Generates a dummy source file for each target so libraries that contain
...
...
@@ -74,12 +74,12 @@ module Pod
# @return [void]
#
def
create_dummy_source
path
=
library
.
dummy_source_path
path
=
target
.
dummy_source_path
UI
.
message
"- Generating dummy source file at
#{
UI
.
path
(
path
)
}
"
do
generator
=
Generator
::
DummySource
.
new
(
library
.
label
)
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
)
target
.
target
.
source_build_phase
.
add_file_reference
(
file_reference
)
end
end
...
...
@@ -88,7 +88,7 @@ module Pod
#
# @note Generated by the {#add_target} step.
#
attr_reader
:target
attr_reader
:
native_
target
private
...
...
@@ -102,10 +102,10 @@ module Pod
sandbox
.
project
end
# @return [TargetDefinition] the target definition of the
library
.
# @return [TargetDefinition] the target definition of the
target
.
#
def
target_definition
library
.
target_definition
target
.
target_definition
end
# @return [PBXGroup] the group where the file references to the support
...
...
lib/cocoapods/installer/pods_project_generator/target_installer/aggregate_target_installer.rb
View file @
78c006a9
...
...
@@ -12,7 +12,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_suport_files_group
create_xcconfig_file
...
...
@@ -33,14 +33,14 @@ module Pod
# @return [void]
#
def
create_xcconfig_file
path
=
library
.
xcconfig_path
path
=
target
.
xcconfig_path
UI
.
message
"- Generating xcconfig file at
#{
UI
.
path
(
path
)
}
"
do
gen
=
Generator
::
XCConfig
::
AggregateXCConfig
.
new
(
library
)
gen
=
Generator
::
XCConfig
::
AggregateXCConfig
.
new
(
target
)
gen
.
save_as
(
path
)
library
.
xcconfig
=
gen
.
xcconfig
target
.
xcconfig
=
gen
.
xcconfig
xcconfig_file_ref
=
add_file_to_support_group
(
path
)
target
.
build_configurations
.
each
do
|
c
|
target
.
target
.
build_configurations
.
each
do
|
c
|
c
.
base_configuration_reference
=
xcconfig_file_ref
end
end
...
...
@@ -50,9 +50,9 @@ module Pod
# pods and the installed specifications of a pod.
#
def
create_target_environment_header
path
=
library
.
target_environment_header_path
path
=
target
.
target_environment_header_path
UI
.
message
"- Generating target environment header at
#{
UI
.
path
(
path
)
}
"
do
generator
=
Generator
::
TargetEnvironmentHeader
.
new
(
library
.
pod_targets
.
map
{
|
l
|
l
.
specs
}.
flatten
)
generator
=
Generator
::
TargetEnvironmentHeader
.
new
(
target
.
pod_targets
.
map
{
|
l
|
l
.
specs
}.
flatten
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
...
...
@@ -61,16 +61,16 @@ 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
path
=
target
.
bridge_support_path
UI
.
message
"- Generating BridgeSupport metadata at
#{
UI
.
path
(
path
)
}
"
do
headers
=
target
.
headers_build_phase
.
files
.
map
{
|
bf
|
sandbox
.
root
+
bf
.
file_ref
.
path
}
headers
=
target
.
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
)
...
...
@@ -88,16 +88,16 @@ module Pod
# @return [void]
#
def
create_copy_resources_script
path
=
library
.
copy_resources_script_path
path
=
target
.
copy_resources_script_path
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
path
)
}
"
do
file_accessors
=
library
.
pod_targets
.
map
(
&
:file_accessors
).
flatten
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
...
...
@@ -108,11 +108,11 @@ 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
)
UI
.
message
"- Generating acknowledgements at
#{
UI
.
path
(
path
)
}
"
do
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/pods_project_generator/target_installer/pod_target_installer.rb
View file @
78c006a9
...
...
@@ -12,7 +12,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
move_target_product_file_reference
add_files_to_build_phases
...
...
@@ -39,21 +39,21 @@ module Pod
#
def
add_files_to_build_phases
UI
.
message
"- Adding Build files"
do
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
)
source_files
=
file_accessor
.
source_files
file_refs
=
source_files
.
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
target
.
add_file_references
(
file_refs
,
flags
)
target
.
target
.
add_file_references
(
file_refs
,
flags
)
end
end
end
def
move_target_product_file_reference
pod_name
=
library
.
pod_name
pod_name
=
target
.
pod_name
group
=
project
.
group_for_spec
(
pod_name
,
:products
)
target
.
product_reference
.
move
(
group
)
target
.
target
.
product_reference
.
move
(
group
)
end
# Adds the resources of the Pods to the Pods project.
...
...
@@ -65,7 +65,7 @@ module Pod
#
def
add_resources_bundle_targets
UI
.
message
"- Adding resource bundles to Pods project"
do
library
.
file_accessors
.
each
do
|
file_accessor
|
target
.
file_accessors
.
each
do
|
file_accessor
|
file_accessor
.
resource_bundles
.
each
do
|
bundle_name
,
paths
|
file_references
=
paths
.
map
{
|
sf
|
project
.
reference_for_path
(
sf
)
}
group
=
project
.
group_for_spec
(
file_accessor
.
spec
.
name
,
:products
)
...
...
@@ -73,7 +73,7 @@ module Pod
bundle_target
=
project
.
new_resources_bundle
(
bundle_name
,
file_accessor
.
spec_consumer
.
platform_name
,
product_group
)
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
...
...
@@ -88,25 +88,25 @@ 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
)
UI
.
message
"- Generating public xcconfig file at
#{
UI
.
path
(
path
)
}
"
do
public_gen
.
save_as
(
path
)
#
# TODO
add_file_to_support_group
(
path
)
# relative_path = path.relative_path_from(sandbox.root)
# group = project.group_for_spec(
library
.root_spec.name, :support_files)
# group = project.group_for_spec(
target
.root_spec.name, :support_files)
# group.new_file(relative_path)
end
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
)
UI
.
message
"- Generating private xcconfig file at
#{
UI
.
path
(
path
)
}
"
do
private_gen
.
save_as
(
path
)
xcconfig_file_ref
=
add_file_to_support_group
(
path
)
target
.
build_configurations
.
each
do
|
c
|
target
.
target
.
build_configurations
.
each
do
|
c
|
c
.
base_configuration_reference
=
xcconfig_file_ref
end
end
...
...
@@ -119,14 +119,14 @@ module Pod
# @return [void]
#
def
create_prefix_header
path
=
library
.
prefix_header_path
path
=
target
.
prefix_header_path
UI
.
message
"- Generating prefix header at
#{
UI
.
path
(
path
)
}
"
do
generator
=
Generator
::
PrefixHeader
.
new
(
library
.
file_accessors
,
library
.
platform
)
generator
.
imports
<<
library
.
target_environment_header_path
.
basename
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
|
target
.
target
.
build_configurations
.
each
do
|
c
|
relative_path
=
path
.
relative_path_from
(
sandbox
.
root
)
c
.
build_settings
[
'GCC_PREFIX_HEADER'
]
=
relative_path
.
to_s
end
...
...
@@ -143,9 +143,9 @@ module Pod
#
def
link_to_system_frameworks
UI
.
message
"- Linking to system frameworks"
do
library
.
specs
.
each
do
|
spec
|
spec
.
consumer
(
library
.
platform
).
frameworks
.
each
do
|
framework
|
project
.
add_system_framework
(
framework
,
library
.
target
)
target
.
specs
.
each
do
|
spec
|
spec
.
consumer
(
target
.
platform
).
frameworks
.
each
do
|
framework
|
project
.
add_system_framework
(
framework
,
target
.
target
)
end
end
end
...
...
@@ -215,7 +215,7 @@ module Pod
# @return [PBXFileReference] the file reference of the added file.
#
def
add_file_to_support_group
(
path
)
pod_name
=
library
.
pod_name
pod_name
=
target
.
pod_name
group
=
project
.
group_for_spec
(
pod_name
,
:support_files
)
group
.
new_file
(
path
)
end
...
...
spec/unit/installer/pods_project_generator/target_installer/aggregate_target_installer_spec.rb
View file @
78c006a9
...
...
@@ -54,7 +54,7 @@ module Pod
#--------------------------------------#
it
'adds the target for the static
library
to the project'
do
it
'adds the target for the static
target
to the project'
do
@installer
.
install!
@project
.
targets
.
count
.
should
==
1
@project
.
targets
.
first
.
name
.
should
==
@target_definition
.
label
...
...
@@ -105,7 +105,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
.
target
.
build_configurations
.
each
do
|
config
|
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
].
should
.
be
.
nil
end
end
...
...
@@ -157,9 +157,9 @@ module Pod
plist
.
read
.
should
.
include?
(
'Permission is hereby granted'
)
end
it
"creates a dummy source to ensure the creation of a single base
library
"
do
it
"creates a dummy source to ensure the creation of a single base
target
"
do
@installer
.
install!
build_files
=
@installer
.
library
.
target
.
source_build_phase
.
files
build_files
=
@installer
.
target
.
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/pods_project_generator/target_installer/pod_target_installer_spec.rb
View file @
78c006a9
...
...
@@ -44,7 +44,7 @@ module Pod
#--------------------------------------#
it
'adds the target for the static
library
to the project'
do
it
'adds the target for the static
target
to the project'
do
@installer
.
install!
@project
.
targets
.
count
.
should
==
1
@project
.
targets
.
first
.
name
.
should
==
'Pods-BananaLib'
...
...
@@ -87,16 +87,16 @@ 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
.
target
.
build_configurations
.
each
do
|
config
|
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
].
should
.
be
.
nil
end
end
#--------------------------------------#
it
'adds the source files of each pod to the target of the Pod
library
'
do
it
'adds the source files of each pod to the target of the Pod
target
'
do
@installer
.
install!
names
=
@installer
.
library
.
target
.
source_build_phase
.
files
.
map
{
|
bf
|
bf
.
file_ref
.
display_name
}
names
=
@installer
.
target
.
target
.
source_build_phase
.
files
.
map
{
|
bf
|
bf
.
file_ref
.
display_name
}
names
.
should
.
include
(
"Banana.m"
)
end
...
...
@@ -138,7 +138,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
.
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'
...
...
@@ -196,7 +196,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'
)
...
...
@@ -208,7 +208,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'
)
...
...
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