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
c189b4cf
Commit
c189b4cf
authored
Mar 27, 2012
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only integrate targets that have not yet been integrated.
parent
9cac4b54
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
8 deletions
+35
-8
integrator.rb
lib/cocoapods/project/integrator.rb
+16
-6
integrator_spec.rb
spec/functional/project/integrator_spec.rb
+19
-2
No files found.
lib/cocoapods/project/integrator.rb
View file @
c189b4cf
...
@@ -17,10 +17,12 @@ module Pod
...
@@ -17,10 +17,12 @@ module Pod
def
integrate!
def
integrate!
create_workspace!
create_workspace!
return
if
project_already_integrated?
targets
.
each
(
&
:integrate!
)
# Only need to write out the user's project if any of the target
# integrators actually did some work.
if
targets
.
map
(
&
:integrate!
).
any?
@user_project
.
save_as
(
user_project_path
)
@user_project
.
save_as
(
user_project_path
)
end
unless
config
.
silent?
unless
config
.
silent?
# TODO this really shouldn't be here
# TODO this really shouldn't be here
...
@@ -49,10 +51,6 @@ module Pod
...
@@ -49,10 +51,6 @@ module Pod
workspace
.
save_as
(
workspace_path
)
workspace
.
save_as
(
workspace_path
)
end
end
def
project_already_integrated?
@user_project
.
files
.
find
{
|
file
|
file
.
path
=~
/libPods\.a$/
}
end
class
Target
class
Target
attr_reader
:integrator
,
:target_definition
attr_reader
:integrator
,
:target_definition
...
@@ -61,24 +59,36 @@ module Pod
...
@@ -61,24 +59,36 @@ module Pod
end
end
def
integrate!
def
integrate!
return
false
if
targets
.
empty?
add_xcconfig_base_configuration
add_xcconfig_base_configuration
add_pods_library
add_pods_library
add_copy_resources_script_phase
add_copy_resources_script_phase
true
end
end
# This returns a list of the targets from the user’s project to which
# This returns a list of the targets from the user’s project to which
# this Pods static library should be linked. If no explicit target was
# this Pods static library should be linked. If no explicit target was
# specified, then the first encountered target is assumed.
# specified, then the first encountered target is assumed.
#
#
# In addition this will only return targets that do **not** already
# have the Pods library in their frameworks build phase.
#
# @return [Array<PBXNativeTarget>] Returns the list of targets that
# @return [Array<PBXNativeTarget>] Returns the list of targets that
# the Pods lib should be linked with.
# the Pods lib should be linked with.
def
targets
def
targets
@targets
||=
begin
if
link_with
=
@target_definition
.
link_with
if
link_with
=
@target_definition
.
link_with
@integrator
.
user_project
.
targets
.
select
do
|
target
|
@integrator
.
user_project
.
targets
.
select
do
|
target
|
link_with
.
include?
target
.
name
link_with
.
include?
target
.
name
end
end
else
else
[
@integrator
.
user_project
.
targets
.
first
]
[
@integrator
.
user_project
.
targets
.
first
]
end
.
reject
do
|
target
|
# reject any target that already has this Pods library in one of its frameworks build phases
target
.
frameworks_build_phases
.
any?
do
|
phase
|
phase
.
files
.
any?
{
|
build_file
|
build_file
.
file
.
name
==
@target_definition
.
lib_name
}
end
end
end
end
end
end
...
...
spec/functional/project/integrator_spec.rb
View file @
c189b4cf
...
@@ -113,9 +113,26 @@ describe Pod::Project::Integrator do
...
@@ -113,9 +113,26 @@ describe Pod::Project::Integrator do
it
'adds a Copy Pods Resources build phase to each target'
do
it
'adds a Copy Pods Resources build phase to each target'
do
@podfile
.
target_definitions
.
each
do
|
_
,
definition
|
@podfile
.
target_definitions
.
each
do
|
_
,
definition
|
target
=
@sample_project
.
targets
.
where
(
:name
=>
definition
.
link_with
.
first
)
target
=
@sample_project
.
targets
.
where
(
:name
=>
definition
.
link_with
.
first
)
expected_
phase
=
target
.
shell_script_build_phases
.
where
(
:name
=>
"Copy Pods Resources"
)
phase
=
target
.
shell_script_build_phases
.
where
(
:name
=>
"Copy Pods Resources"
)
expected_
phase
.
shell_script
.
strip
.
should
==
"
\"
${SRCROOT}/Pods/
#{
definition
.
copy_resources_script_name
}
\"
"
.
strip
phase
.
shell_script
.
strip
.
should
==
"
\"
${SRCROOT}/Pods/
#{
definition
.
copy_resources_script_name
}
\"
"
.
strip
end
end
end
end
it
"only tries to integrate Pods libraries into user targets that haven't been integrated yet"
do
app
,
test_runner
=
@integrator
.
user_project
.
targets
.
to_a
test_runner
.
frameworks_build_phases
.
first
.
files
.
last
.
destroy
targets
=
@integrator
.
targets
@integrator
.
stubs
(
:targets
).
returns
(
targets
)
targets
.
first
.
expects
(
:add_pods_library
).
never
targets
.
last
.
expects
(
:add_pods_library
)
@integrator
.
integrate!
end
it
"does not even try to save the project if none of the target integrators had any work to do"
do
@integrator
.
user_project
.
expects
(
:save_as
).
never
@integrator
.
integrate!
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