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
2a673e23
Commit
2a673e23
authored
Jun 22, 2015
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TargetInspector] Inject the #installation_root via the constructor
Instead of refering to the global configuration
parent
5abe739a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
28 deletions
+59
-28
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+2
-1
target_inspector.rb
lib/cocoapods/installer/analyzer/target_inspector.rb
+12
-6
target_inspector_spec.rb
spec/unit/installer/analyzer/target_inspector_spec.rb
+45
-21
No files found.
lib/cocoapods/installer/analyzer.rb
View file @
2a673e23
...
...
@@ -651,7 +651,8 @@ module Pod
inspection_result
=
{}
UI
.
section
'Inspecting targets to integrate'
do
podfile
.
target_definition_list
.
each
do
|
target_definition
|
results
=
TargetInspector
.
new
(
target_definition
).
inspect!
inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
results
=
inspector
.
inspect!
inspection_result
[
target_definition
]
=
results
UI
.
message
(
'Using `ARCHS` setting to build architectures of '
\
"target `
#{
target_definition
.
label
}
`: (`
#{
results
.
archs
.
join
(
'`, `'
)
}
`)"
)
...
...
lib/cocoapods/installer/analyzer/target_inspector.rb
View file @
2a673e23
...
...
@@ -2,19 +2,25 @@ module Pod
class
Installer
class
Analyzer
class
TargetInspector
include
Config
::
Mixin
# @return [TargetDefinition] the target definition to inspect
#
attr_accessor
:target_definition
# @return [Pathname] the root of the CocoaPods installation where the
# Podfile is located
attr_accessor
:installation_root
# Initialize a new instance
#
# @param [TargetDefinition] target_definition
# the target definition
# @see #target_definition
#
# @param [Pathname] installation_root
# @see #installation_root
#
def
initialize
(
target_definition
)
def
initialize
(
target_definition
,
installation_root
)
@target_definition
=
target_definition
@installation_root
=
installation_root
end
# Inspect the #target_definition
...
...
@@ -51,7 +57,7 @@ module Pod
#
def
compute_project_path
if
target_definition
.
user_project_path
path
=
config
.
installation_root
+
target_definition
.
user_project_path
path
=
installation_root
+
target_definition
.
user_project_path
path
=
"
#{
path
}
.xcodeproj"
unless
File
.
extname
(
path
)
==
'.xcodeproj'
path
=
Pathname
.
new
(
path
)
unless
path
.
exist?
...
...
@@ -59,7 +65,7 @@ module Pod
"`
#{
path
}
` for the target `
#{
target_definition
.
label
}
`."
end
else
xcodeprojs
=
config
.
installation_root
.
children
.
select
{
|
e
|
e
.
fnmatch
(
'*.xcodeproj'
)
}
xcodeprojs
=
installation_root
.
children
.
select
{
|
e
|
e
.
fnmatch
(
'*.xcodeproj'
)
}
if
xcodeprojs
.
size
==
1
path
=
xcodeprojs
.
first
else
...
...
spec/unit/installer/analyzer/target_inspector_spec.rb
View file @
2a673e23
...
...
@@ -11,7 +11,8 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
user_project_path
=
'SampleProject/SampleProject'
path
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_project_path
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
path
=
target_inspector
.
send
(
:compute_project_path
)
path
.
to_s
.
should
.
include
'SampleProject/SampleProject.xcodeproj'
end
...
...
@@ -19,7 +20,8 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
target_definition
.
user_project_path
=
'Test'
e
=
lambda
{
TargetInspector
.
new
(
target_definition
).
send
(
:compute_project_path
)
}.
should
.
raise
Informative
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
e
=
lambda
{
target_inspector
.
send
(
:compute_project_path
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find/
end
...
...
@@ -27,14 +29,16 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
config
.
installation_root
=
config
.
installation_root
+
'SampleProject'
path
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_project_path
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
path
=
target_inspector
.
send
(
:compute_project_path
)
path
.
to_s
.
should
.
include
'SampleProject/SampleProject.xcodeproj'
end
it
'raise if there is no project and none specified in the target definition'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
e
=
lambda
{
TargetInspector
.
new
(
target_definition
).
send
(
:compute_project_path
)
}.
should
.
raise
Informative
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
e
=
lambda
{
target_inspector
.
send
(
:compute_project_path
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Could not.*select.*project/
end
...
...
@@ -44,7 +48,8 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
config
.
installation_root
=
config
.
installation_root
+
'Project[With]Special{chars}in*path?'
path
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_project_path
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
path
=
target_inspector
.
send
(
:compute_project_path
)
path
.
to_s
.
should
.
include
'Project[With]Special{chars}in*path?/Project[With]Special{chars}in*path?.xcodeproj'
end
end
...
...
@@ -59,7 +64,8 @@ module Pod
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
targets
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_targets
,
user_project
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
targets
=
target_inspector
.
send
(
:compute_targets
,
user_project
)
targets
.
map
(
&
:name
).
should
==
[
'UserTarget'
]
end
...
...
@@ -68,7 +74,8 @@ module Pod
target_definition
.
link_with
=
[
'UserTarget'
]
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
e
=
lambda
{
TargetInspector
.
new
(
target_definition
).
send
(
:compute_targets
,
user_project
)
}.
should
.
raise
Informative
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
e
=
lambda
{
target_inspector
.
send
(
:compute_targets
,
user_project
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find the targets/
end
...
...
@@ -78,14 +85,17 @@ module Pod
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
targets
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_targets
,
user_project
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
targets
=
target_inspector
.
send
(
:compute_targets
,
user_project
)
targets
.
map
(
&
:name
).
should
==
[
'UserTarget'
]
end
it
'raises if the name of the target definition does not match any file'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'UserTarget'
,
nil
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
e
=
lambda
{
TargetInspector
.
new
(
target_definition
).
send
(
:compute_targets
,
user_project
)
}.
should
.
raise
Informative
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
e
=
lambda
{
target_inspector
.
send
(
:compute_targets
,
user_project
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find a target named/
end
...
...
@@ -96,14 +106,17 @@ module Pod
user_project
.
new_target
(
:application
,
'FirstTarget'
,
:ios
)
user_project
.
new_target
(
:application
,
'UserTarget'
,
:ios
)
targets
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_targets
,
user_project
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
targets
=
target_inspector
.
send
(
:compute_targets
,
user_project
)
targets
.
map
(
&
:name
).
should
==
[
'FirstTarget'
]
end
it
'raises if the default target definition cannot be linked because there are no user targets'
do
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_project
=
Xcodeproj
::
Project
.
new
(
'path'
)
e
=
lambda
{
TargetInspector
.
new
(
target_definition
).
send
(
:compute_targets
,
user_project
)
}.
should
.
raise
Informative
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
e
=
lambda
{
target_inspector
.
send
(
:compute_targets
,
user_project
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Unable to find a target/
end
end
...
...
@@ -121,7 +134,8 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target
]
configurations
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_build_configurations
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
configurations
=
target_inspector
.
send
(
:compute_build_configurations
,
user_targets
)
configurations
.
should
==
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
...
...
@@ -134,7 +148,8 @@ module Pod
target_definition
.
build_configurations
=
{
'AppStore'
=>
:release
}
user_targets
=
[]
configurations
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_build_configurations
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
configurations
=
target_inspector
.
send
(
:compute_build_configurations
,
user_targets
)
configurations
.
should
==
{
'AppStore'
=>
:release
}
end
end
...
...
@@ -151,7 +166,8 @@ module Pod
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[
target
]
archs
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_archs
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
archs
=
target_inspector
.
send
(
:compute_archs
,
user_targets
)
archs
.
should
==
%w(armv7)
end
...
...
@@ -166,7 +182,8 @@ module Pod
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[
targeta
,
targetb
]
archs
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_archs
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
archs
=
target_inspector
.
send
(
:compute_archs
,
user_targets
)
archs
.
should
==
%w(armv7)
end
...
...
@@ -179,7 +196,8 @@ module Pod
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[
target
]
archs
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_archs
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
archs
=
target_inspector
.
send
(
:compute_archs
,
user_targets
)
archs
.
uniq
.
sort
.
should
==
%w(armv7 i386)
end
...
...
@@ -194,7 +212,8 @@ module Pod
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[
target_a
,
target_b
]
archs
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_archs
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
archs
=
target_inspector
.
send
(
:compute_archs
,
user_targets
)
archs
.
uniq
.
sort
.
should
==
%w(armv7 armv7s i386)
end
end
...
...
@@ -207,7 +226,8 @@ module Pod
target_definition
.
set_platform
(
:ios
,
'4.0'
)
user_targets
=
[]
platforms
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_platform
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
platforms
=
target_inspector
.
send
(
:compute_platform
,
user_targets
)
platforms
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
end
...
...
@@ -220,7 +240,8 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target
]
platforms
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_platform
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
platforms
=
target_inspector
.
send
(
:compute_platform
,
user_targets
)
platforms
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
end
...
...
@@ -238,7 +259,8 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target1
,
target2
]
platforms
=
TargetInspector
.
new
(
target_definition
).
send
(
:compute_platform
,
user_targets
)
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
platforms
=
target_inspector
.
send
(
:compute_platform
,
user_targets
)
platforms
.
should
==
Platform
.
new
(
:ios
,
'4.0'
)
end
...
...
@@ -254,7 +276,9 @@ module Pod
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
user_targets
=
[
target1
,
target2
]
e
=
lambda
{
TargetInspector
.
new
(
target_definition
).
send
(
:compute_platform
,
user_targets
)
}.
should
.
raise
Informative
target_inspector
=
TargetInspector
.
new
(
target_definition
,
config
.
installation_root
)
e
=
lambda
{
target_inspector
.
send
(
:compute_platform
,
user_targets
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/Targets with different platforms/
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