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
298c6280
Commit
298c6280
authored
Oct 18, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4380 from CocoaPods/seg-open-project-once
Only open the user project once per installation
parents
8e142b2e
d0081ee0
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
78 additions
and
40 deletions
+78
-40
CHANGELOG.md
CHANGELOG.md
+7
-0
installer.rb
lib/cocoapods/installer.rb
+1
-3
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+10
-3
target_inspection_result.rb
lib/cocoapods/installer/analyzer/target_inspection_result.rb
+4
-0
target_inspector.rb
lib/cocoapods/installer/analyzer/target_inspector.rb
+15
-7
post_install_hooks_context.rb
lib/cocoapods/installer/post_install_hooks_context.rb
+14
-2
target_integrator.rb
...ds/installer/user_project_integrator/target_integrator.rb
+2
-2
aggregate_target.rb
lib/cocoapods/target/aggregate_target.rb
+11
-11
post_install_hooks_context_spec.rb
spec/unit/installer/post_install_hooks_context_spec.rb
+6
-3
aggregate_target_installer_spec.rb
...aller/target_installer/aggregate_target_installer_spec.rb
+0
-1
xcconfig_integrator_spec.rb
..._integrator/target_integrator/xcconfig_integrator_spec.rb
+1
-1
target_integrator_spec.rb
...staller/user_project_integrator/target_integrator_spec.rb
+2
-2
user_project_integrator_spec.rb
spec/unit/installer/user_project_integrator_spec.rb
+1
-1
installer_spec.rb
spec/unit/installer_spec.rb
+3
-3
aggregate_target_spec.rb
spec/unit/target/aggregate_target_spec.rb
+1
-1
No files found.
CHANGELOG.md
View file @
298c6280
...
...
@@ -6,6 +6,13 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
## Master
##### Enhancements
*
Reduce the number of times the user's Xcode project is opened, speeding up
installation.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
#4374
](
https://github.com/CocoaPods/CocoaPods/issues/4374
)
##### Bug Fixes
*
Fix a crash in dependency resolution when running Ruby 2.3.
...
...
lib/cocoapods/installer.rb
View file @
298c6280
...
...
@@ -548,9 +548,7 @@ module Pod
#
def
prepare_pods_project
UI
.
message
'- Creating Pods project'
do
object_version
=
aggregate_targets
.
map
(
&
:user_project_path
).
compact
.
map
do
|
path
|
Xcodeproj
::
Project
.
open
(
path
).
object_version
.
to_i
end
.
min
object_version
=
aggregate_targets
.
map
(
&
:user_project
).
compact
.
map
{
|
p
|
p
.
object_version
.
to_i
}.
min
if
object_version
@pods_project
=
Pod
::
Project
.
new
(
sandbox
.
project_path
,
false
,
object_version
)
...
...
lib/cocoapods/installer/analyzer.rb
View file @
298c6280
...
...
@@ -246,7 +246,7 @@ module Pod
if
config
.
integrate_targets?
target_inspection
=
result
.
target_inspections
[
target_definition
]
target
.
user_project
_path
=
target_inspection
.
project_path
target
.
user_project
=
target_inspection
.
project
target
.
client_root
=
target
.
user_project_path
.
dirname
target
.
user_target_uuids
=
target_inspection
.
project_target_uuids
target
.
user_build_configurations
=
target_inspection
.
build_configurations
...
...
@@ -654,14 +654,21 @@ module Pod
def
inspect_targets_to_integrate
inspection_result
=
{}
UI
.
section
'Inspecting targets to integrate'
do
podfile
.
target_definition_list
.
each
do
|
target_definition
|
inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
inspectors
=
podfile
.
target_definition_list
.
map
do
|
target_definition
|
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
end
inspectors
.
group_by
(
&
:compute_project_path
).
each
do
|
project_path
,
target_inspectors
|
project
=
Xcodeproj
::
Project
.
open
(
project_path
)
target_inspectors
.
each
do
|
inspector
|
target_definition
=
inspector
.
target_definition
inspector
.
user_project
=
project
results
=
inspector
.
compute_results
inspection_result
[
target_definition
]
=
results
UI
.
message
(
'Using `ARCHS` setting to build architectures of '
\
"target `
#{
target_definition
.
label
}
`: (`
#{
results
.
archs
.
join
(
'`, `'
)
}
`)"
)
end
end
end
inspection_result
end
end
...
...
lib/cocoapods/installer/analyzer/target_inspection_result.rb
View file @
298c6280
...
...
@@ -35,6 +35,10 @@ module Pod
# due to the presence of Swift source in the user's targets
#
attr_accessor
:recommends_frameworks
# @return [Xcodeproj::Project] the user's Xcode project
#
attr_accessor
:project
end
end
end
...
...
lib/cocoapods/installer/analyzer/target_inspector.rb
View file @
298c6280
...
...
@@ -25,27 +25,26 @@ module Pod
# Inspect the #target_definition
#
# @raise If no `user_project` is set
#
# @return [TargetInspectionResult]
#
def
compute_results
project_path
=
compute_project_path
user_project
=
Xcodeproj
::
Project
.
open
(
project_path
)
raise
ArgumentError
,
'Cannot compute results without a user project set'
unless
user_project
targets
=
compute_targets
(
user_project
)
result
=
TargetInspectionResult
.
new
result
.
target_definition
=
target_definition
result
.
project_path
=
project_
path
result
.
project_path
=
user_project
.
path
result
.
project_target_uuids
=
targets
.
map
(
&
:uuid
)
result
.
build_configurations
=
compute_build_configurations
(
targets
)
result
.
platform
=
compute_platform
(
targets
)
result
.
archs
=
compute_archs
(
targets
)
result
.
project
=
user_project
result
end
#-----------------------------------------------------------------------#
private
# Returns the path of the user project that the #target_definition
# should integrate.
#
...
...
@@ -77,6 +76,15 @@ module Pod
path
end
# @return [Xcodeproj::Project] the user's Xcode project, used for target
# inspection
#
attr_accessor
:user_project
#-----------------------------------------------------------------------#
private
# Returns a list of the targets from the project of #target_definition
# that needs to be integrated.
#
...
...
lib/cocoapods/installer/post_install_hooks_context.rb
View file @
298c6280
...
...
@@ -8,6 +8,10 @@ module Pod
#
attr_accessor
:sandbox_root
# @return [Project] The Pods Xcode project.
#
attr_accessor
:pods_project
# @return [Array<UmbrellaTargetDescription>] The list of
# the CocoaPods umbrella targets generated by the installer.
#
...
...
@@ -29,7 +33,7 @@ module Pod
umbrella_targets_descriptions
=
[]
aggregate_targets
.
each
do
|
umbrella
|
desc
=
UmbrellaTargetDescription
.
new
desc
.
user_project
_path
=
umbrella
.
user_project_path
desc
.
user_project
=
umbrella
.
user_project
desc
.
user_target_uuids
=
umbrella
.
user_target_uuids
desc
.
specs
=
umbrella
.
specs
desc
.
platform_name
=
umbrella
.
platform
.
name
...
...
@@ -40,6 +44,7 @@ module Pod
result
=
new
result
.
sandbox_root
=
sandbox
.
root
.
to_s
result
.
pods_project
=
sandbox
.
project
result
.
umbrella_targets
=
umbrella_targets_descriptions
result
end
...
...
@@ -47,10 +52,17 @@ module Pod
# Pure data class which describes and umbrella target.
#
class
UmbrellaTargetDescription
# @return [Xcodeproj::Project] The user project into which this target
# is integrated.
#
attr_accessor
:user_project
# @return [String] The path of the user project
# integrated by this target.
#
attr_accessor
:user_project_path
def
user_project_path
user_project
.
path
if
user_project
end
# @return [Array<String>] The list of the UUIDs of the
# user targets integrated by this umbrella
...
...
lib/cocoapods/installer/user_project_integrator/target_integrator.rb
View file @
298c6280
...
...
@@ -268,7 +268,7 @@ module Pod
# match the given target.
#
def
native_targets
@native_targets
||=
target
.
user_targets
(
user_project
)
@native_targets
||=
target
.
user_targets
end
# @return [Array<PBXNativeTarget>] The list of all the targets that
...
...
@@ -305,7 +305,7 @@ module Pod
# @return [Project]
#
def
user_project
@user_project
||=
Xcodeproj
::
Project
.
open
(
target
.
user_project_path
)
target
.
user_project
end
# @return [Specification::Consumer] the consumer for the specifications.
...
...
lib/cocoapods/target/aggregate_target.rb
View file @
298c6280
...
...
@@ -54,13 +54,17 @@ module Pod
#
attr_accessor
:client_root
# @return [
Pathname] the path of
the user project that this target will
# @return [
Xcodeproj::Project]
the user project that this target will
# integrate as identified by the analyzer.
#
# @note The project instance is not stored to prevent editing different
# instances.
attr_accessor
:user_project
# @return [Pathname] the path of the user project that this target will
# integrate as identified by the analyzer.
#
attr_accessor
:user_project_path
def
user_project_path
user_project
.
path
if
user_project
end
# @return [Array<String>] the list of the UUIDs of the user targets that
# will be integrated by this target as identified by the analyzer.
...
...
@@ -72,16 +76,12 @@ module Pod
# List all user targets that will be integrated by this #target.
#
# @param [Xcodeproj::Project] project
# The project to search for the user targets
#
# @return [Array<PBXNativeTarget>]
#
def
user_targets
(
project
=
nil
)
return
[]
unless
user_project_path
project
||=
Xcodeproj
::
Project
.
open
(
user_project_path
)
def
user_targets
return
[]
unless
user_project
user_target_uuids
.
map
do
|
uuid
|
native_target
=
project
.
objects_by_uuid
[
uuid
]
native_target
=
user_
project
.
objects_by_uuid
[
uuid
]
unless
native_target
raise
Informative
,
'[Bug] Unable to find the target with '
\
"the `
#{
uuid
}
` UUID for the `
#{
self
}
` integration library"
...
...
spec/unit/installer/post_install_hooks_context_spec.rb
View file @
298c6280
...
...
@@ -3,13 +3,15 @@ require File.expand_path('../../../spec_helper', __FILE__)
module
Pod
describe
Installer
::
PostInstallHooksContext
do
it
'offers a convenience method to be generated'
do
sandbox
=
stub
(
:root
=>
'/path'
)
pods_project
=
Project
.
new
(
'/path/Pods.xcodeproj'
)
sandbox
=
stub
(
:root
=>
'/path'
,
:project
=>
pods_project
)
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
user_project
=
Xcodeproj
::
Project
.
open
(
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
))
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
pod_target
=
PodTarget
.
new
([
spec
],
[
target_definition
],
config
.
sandbox
)
umbrella
=
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
umbrella
.
user_project
_path
=
'/path/project.xcodeproj'
umbrella
.
user_project
=
user_project
umbrella
.
user_target_uuids
=
[
'UUID'
]
umbrella
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'8.0'
))
umbrella
.
pod_targets
=
[
pod_target
]
...
...
@@ -17,10 +19,11 @@ module Pod
result
=
Installer
::
PostInstallHooksContext
.
generate
(
sandbox
,
[
umbrella
])
result
.
class
.
should
==
Installer
::
PostInstallHooksContext
result
.
sandbox_root
.
should
==
'/path'
result
.
pods_project
.
should
==
pods_project
result
.
umbrella_targets
.
count
.
should
==
1
umbrella_target
=
result
.
umbrella_targets
.
first
umbrella_target
.
user_target_uuids
.
should
==
[
'UUID'
]
umbrella_target
.
user_project
_path
.
should
==
'/path/project.xcodeproj'
umbrella_target
.
user_project
.
should
==
user_project
umbrella_target
.
specs
.
should
==
[
spec
]
umbrella_target
.
platform_name
.
should
==
:ios
umbrella_target
.
platform_deployment_target
.
should
==
'8.0'
...
...
spec/unit/installer/target_installer/aggregate_target_installer_spec.rb
View file @
298c6280
...
...
@@ -24,7 +24,6 @@ module Pod
@target
=
AggregateTarget
.
new
(
@target_definition
,
config
.
sandbox
)
@target
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
@target
.
user_project_path
=
config
.
sandbox
.
root
+
'../user_project.xcodeproj'
@target
.
client_root
=
config
.
sandbox
.
root
.
dirname
@target
.
user_build_configurations
=
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
'AppStore'
=>
:release
,
'Test'
=>
:debug
}
...
...
spec/unit/installer/user_project_integrator/target_integrator/xcconfig_integrator_spec.rb
View file @
298c6280
...
...
@@ -10,7 +10,7 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
target_definition
.
link_with_first_target
=
true
@pod_bundle
=
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
@pod_bundle
.
user_project
_path
=
project_path
@pod_bundle
.
user_project
=
@project
@pod_bundle
.
client_root
=
project_path
.
dirname
@pod_bundle
.
user_target_uuids
=
[
@target
.
uuid
]
configuration
=
Xcodeproj
::
Config
.
new
(
...
...
spec/unit/installer/user_project_integrator/target_integrator_spec.rb
View file @
298c6280
...
...
@@ -10,12 +10,12 @@ module Pod
before
do
project_path
=
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
@project
=
Xcodeproj
::
Project
.
open
(
project_path
)
Xcodeproj
::
Project
.
new
(
config
.
sandbox
.
project_path
).
save
Project
.
new
(
config
.
sandbox
.
project_path
).
save
@target
=
@project
.
targets
.
first
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
target_definition
.
link_with_first_target
=
true
@pod_bundle
=
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
@pod_bundle
.
user_project
_path
=
project_path
@pod_bundle
.
user_project
=
@project
@pod_bundle
.
client_root
=
project_path
.
dirname
@pod_bundle
.
user_target_uuids
=
[
@target
.
uuid
]
configuration
=
Xcodeproj
::
Config
.
new
(
...
...
spec/unit/installer/user_project_integrator_spec.rb
View file @
298c6280
...
...
@@ -17,7 +17,7 @@ module Pod
Xcodeproj
::
Project
.
new
(
config
.
sandbox
.
project_path
).
save
@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_project
=
Xcodeproj
::
Project
.
open
(
@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
,
[
@target
,
empty_library
])
...
...
spec/unit/installer_spec.rb
View file @
298c6280
...
...
@@ -491,7 +491,7 @@ module Pod
end
before
do
@installer
.
stubs
(
:analysis_result
).
returns
(
stub
(
:all_user_build_configurations
=>
{}))
@installer
.
stubs
(
:analysis_result
).
returns
(
stub
(
:all_user_build_configurations
=>
{}
,
:target_inspections
=>
nil
))
end
it
'creates the Pods project'
do
...
...
@@ -656,7 +656,7 @@ module Pod
describe
'#write_pod_project'
do
before
do
@installer
.
stubs
(
:aggregate_targets
).
returns
([])
@installer
.
stubs
(
:analysis_result
).
returns
(
stub
(
:all_user_build_configurations
=>
{}))
@installer
.
stubs
(
:analysis_result
).
returns
(
stub
(
:all_user_build_configurations
=>
{}
,
:target_inspections
=>
nil
))
@installer
.
send
(
:prepare_pods_project
)
end
...
...
@@ -695,7 +695,7 @@ module Pod
aggregate_target
=
AggregateTarget
.
new
(
nil
,
config
.
sandbox
)
aggregate_target
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
aggregate_target
.
stubs
(
:user_project
_path
).
returns
(
proj
.
path
)
aggregate_target
.
stubs
(
:user_project
).
returns
(
proj
)
@installer
.
stubs
(
:aggregate_targets
).
returns
([
aggregate_target
])
@installer
.
send
(
:prepare_pods_project
)
...
...
spec/unit/target/aggregate_target_spec.rb
View file @
298c6280
...
...
@@ -31,7 +31,7 @@ module Pod
it
'returns the user targets'
do
project_path
=
SpecHelper
.
fixture
(
'SampleProject/SampleProject.xcodeproj'
)
@target
.
user_project
_path
=
project_path
@target
.
user_project
=
Xcodeproj
::
Project
.
open
(
project_path
)
@target
.
user_target_uuids
=
[
'A346496C14F9BE9A0080D870'
]
targets
=
@target
.
user_targets
targets
.
count
.
should
==
1
...
...
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