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
0e2b2dd2
Commit
0e2b2dd2
authored
Aug 29, 2015
by
Samuel E. Giddins
Committed by
Samuel Giddins
Oct 25, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Validator] Validate that apps can import the Pod
parent
4c7ce87f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
31 deletions
+67
-31
lib.rb
lib/cocoapods/command/lib.rb
+1
-1
lint.rb
lib/cocoapods/command/spec/lint.rb
+1
-1
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+2
-2
validator.rb
lib/cocoapods/validator.rb
+58
-22
validator_spec.rb
spec/unit/validator_spec.rb
+5
-5
No files found.
lib/cocoapods/command/lib.rb
View file @
0e2b2dd2
...
@@ -164,7 +164,7 @@ module Pod
...
@@ -164,7 +164,7 @@ module Pod
validator
.
validate
validator
.
validate
unless
@clean
unless
@clean
UI
.
puts
"Pods
project available at `
#{
validator
.
validation_dir
}
/Pods/Pods.xcodeproj
` for inspection."
UI
.
puts
"Pods
workspace available at `
#{
validator
.
validation_dir
}
/App.xcworkspace
` for inspection."
UI
.
puts
UI
.
puts
end
end
if
validator
.
validated?
if
validator
.
validated?
...
...
lib/cocoapods/command/spec/lint.rb
View file @
0e2b2dd2
...
@@ -61,7 +61,7 @@ module Pod
...
@@ -61,7 +61,7 @@ module Pod
failure_reasons
<<
validator
.
failure_reason
failure_reasons
<<
validator
.
failure_reason
unless
@clean
unless
@clean
UI
.
puts
"Pods
project available at `
#{
validator
.
validation_dir
}
/Pods/Pods.xcodeproj
` for inspection."
UI
.
puts
"Pods
workspace available at `
#{
validator
.
validation_dir
}
/App.xcworkspace
` for inspection."
UI
.
puts
UI
.
puts
end
end
end
end
...
...
lib/cocoapods/installer/analyzer.rb
View file @
0e2b2dd2
...
@@ -247,12 +247,12 @@ module Pod
...
@@ -247,12 +247,12 @@ module Pod
if
config
.
integrate_targets?
if
config
.
integrate_targets?
target_inspection
=
result
.
target_inspections
[
target_definition
]
target_inspection
=
result
.
target_inspections
[
target_definition
]
target
.
user_project
=
target_inspection
.
project
target
.
user_project
=
target_inspection
.
project
target
.
client_root
=
target
.
user_project_path
.
dirname
target
.
client_root
=
target
.
user_project_path
.
dirname
.
realpath
target
.
user_target_uuids
=
target_inspection
.
project_target_uuids
target
.
user_target_uuids
=
target_inspection
.
project_target_uuids
target
.
user_build_configurations
=
target_inspection
.
build_configurations
target
.
user_build_configurations
=
target_inspection
.
build_configurations
target
.
archs
=
target_inspection
.
archs
target
.
archs
=
target_inspection
.
archs
else
else
target
.
client_root
=
config
.
installation_root
target
.
client_root
=
config
.
installation_root
.
realpath
target
.
user_target_uuids
=
[]
target
.
user_target_uuids
=
[]
target
.
user_build_configurations
=
target_definition
.
build_configurations
||
{
'Release'
=>
:release
,
'Debug'
=>
:debug
}
target
.
user_build_configurations
=
target_definition
.
build_configurations
||
{
'Release'
=>
:release
,
'Debug'
=>
:debug
}
if
target_definition
.
platform
&&
target_definition
.
platform
.
name
==
:osx
if
target_definition
.
platform
&&
target_definition
.
platform
.
name
==
:osx
...
...
lib/cocoapods/validator.rb
View file @
0e2b2dd2
...
@@ -257,17 +257,24 @@ module Pod
...
@@ -257,17 +257,24 @@ module Pod
UI
.
message
"
\n\n
#{
spec
}
- Analyzing on
#{
platform
}
platform."
.
green
.
reversed
UI
.
message
"
\n\n
#{
spec
}
- Analyzing on
#{
platform
}
platform."
.
green
.
reversed
@consumer
=
spec
.
consumer
(
platform
)
@consumer
=
spec
.
consumer
(
platform
)
setup_validation_environment
setup_validation_environment
download_pod
begin
check_file_patterns
create_app_project
install_pod
download_pod
validate_vendored_dynamic_frameworks
check_file_patterns
build_pod
install_pod
tear_down_validation_environment
add_app_project_import
validate_vendored_dynamic_frameworks
build_pod
ensure
tear_down_validation_environment
end
validated?
validated?
end
end
return
false
if
fail_fast
&&
!
valid
return
false
if
fail_fast
&&
!
valid
perform_extensive_subspec_analysis
(
spec
)
unless
@no_subspecs
perform_extensive_subspec_analysis
(
spec
)
unless
@no_subspecs
rescue
=>
e
rescue
=>
e
message
=
e
.
to_s
message
<<
"
\n
"
<<
e
.
backtrace
.
join
(
"
\n
"
)
<<
"
\n
"
if
config
.
verbose?
error
(
'unknown'
,
"Encountered an unknown error (
#{
e
}
) during validation."
)
error
(
'unknown'
,
"Encountered an unknown error (
#{
e
}
) during validation."
)
false
false
end
end
...
@@ -339,11 +346,11 @@ module Pod
...
@@ -339,11 +346,11 @@ module Pod
validation_dir
.
rmtree
if
validation_dir
.
exist?
validation_dir
.
rmtree
if
validation_dir
.
exist?
validation_dir
.
mkpath
validation_dir
.
mkpath
@original_config
=
Config
.
instance
.
clone
@original_config
=
Config
.
instance
.
clone
config
.
installation_root
=
validation_dir
config
.
installation_root
=
validation_dir
config
.
s
andbox_root
=
validation_dir
+
'Pods'
config
.
s
ilent
=
!
config
.
verbose
config
.
silent
=
!
config
.
verbos
e
config
.
integrate_targets
=
tru
e
config
.
integrate_targets
=
fals
e
config
.
skip_repo_update
=
tru
e
config
.
skip_repo_update
=
tru
e
config
.
deterministic_uuids
=
fals
e
end
end
def
tear_down_validation_environment
def
tear_down_validation_environment
...
@@ -361,13 +368,44 @@ module Pod
...
@@ -361,13 +368,44 @@ module Pod
@file_accessor
=
@installer
.
pod_targets
.
flat_map
(
&
:file_accessors
).
find
{
|
fa
|
fa
.
spec
.
name
==
consumer
.
spec
.
name
}
@file_accessor
=
@installer
.
pod_targets
.
flat_map
(
&
:file_accessors
).
find
{
|
fa
|
fa
.
spec
.
name
==
consumer
.
spec
.
name
}
end
end
def
create_app_project
app_project
=
Xcodeproj
::
Project
.
new
(
validation_dir
+
'App.xcodeproj'
)
deployment_target
=
spec
.
subspec_by_name
(
subspec_name
).
deployment_target
(
consumer
.
platform_name
)
app_project
.
new_target
(
:application
,
'App'
,
consumer
.
platform_name
,
deployment_target
)
app_project
.
save
app_project
.
recreate_user_schemes
Xcodeproj
::
XCScheme
.
share_scheme
(
app_project
.
path
,
'App'
)
end
def
add_app_project_import
app_project
=
Xcodeproj
::
Project
.
open
(
validation_dir
+
'App.xcodeproj'
)
pod_target
=
@installer
.
pod_targets
.
find
{
|
pt
|
pt
.
pod_name
==
spec
.
root
.
name
}
language
=
pod_target
.
uses_swift?
?
:
swift
:
:objc
if
language
==
:swift
source_file
=
validation_dir
.
+
(
'App/main.swift'
)
source_file
.
parent
.
mkpath
import_statement
=
use_frameworks
?
"import
#{
pod_target
.
product_module_name
}
\n
"
:
''
source_file
.
open
(
'w'
)
{
|
f
|
f
<<
import_statement
}
else
source_file
=
validation_dir
.
+
(
'App/main.m'
)
source_file
.
parent
.
mkpath
import_statement
=
use_frameworks
?
"@import
#{
pod_target
.
product_module_name
}
;
\n
"
:
''
source_file
.
open
(
'w'
)
{
|
f
|
f
<<
"@import Foundation;
\n
#{
import_statement
}
int main() {}
\n
"
}
end
source_file_ref
=
app_project
.
new_group
(
'App'
,
'App'
).
new_file
(
source_file
)
app_project
.
targets
.
first
.
add_file_references
([
source_file_ref
])
app_project
.
save
end
# It creates a podfile in memory and builds a library containing the pod
# It creates a podfile in memory and builds a library containing the pod
# for all available platforms with xcodebuild.
# for all available platforms with xcodebuild.
#
#
def
install_pod
def
install_pod
%i(determine_dependency_product_types verify_no_duplicate_framework_names
%i(determine_dependency_product_types verify_no_duplicate_framework_names
verify_no_static_framework_transitive_dependencies
verify_no_static_framework_transitive_dependencies
verify_framework_usage generate_pods_project
verify_framework_usage generate_pods_project
integrate_user_project
perform_post_install_actions)
.
each
{
|
m
|
@installer
.
send
(
m
)
}
perform_post_install_actions)
.
each
{
|
m
|
@installer
.
send
(
m
)
}
deployment_target
=
spec
.
subspec_by_name
(
subspec_name
).
deployment_target
(
consumer
.
platform_name
)
deployment_target
=
spec
.
subspec_by_name
(
subspec_name
).
deployment_target
(
consumer
.
platform_name
)
...
@@ -412,7 +450,7 @@ module Pod
...
@@ -412,7 +450,7 @@ module Pod
UI
.
warn
"Skipping compilation with `xcodebuild' because it can't be found.
\n
"
.
yellow
UI
.
warn
"Skipping compilation with `xcodebuild' because it can't be found.
\n
"
.
yellow
else
else
UI
.
message
"
\n
Building with xcodebuild.
\n
"
.
yellow
do
UI
.
message
"
\n
Building with xcodebuild.
\n
"
.
yellow
do
output
=
Dir
.
chdir
(
config
.
sandbox_root
)
{
xcodebuild
}
output
=
xcodebuild
UI
.
puts
output
UI
.
puts
output
parsed_output
=
parse_xcodebuild_output
(
output
)
parsed_output
=
parse_xcodebuild_output
(
output
)
parsed_output
.
each
do
|
message
|
parsed_output
.
each
do
|
message
|
...
@@ -631,18 +669,17 @@ module Pod
...
@@ -631,18 +669,17 @@ module Pod
# returns its output (both STDOUT and STDERR).
# returns its output (both STDOUT and STDERR).
#
#
def
xcodebuild
def
xcodebuild
command
=
'xcodebuild clean build -target Pods'
command
=
%W(clean build -workspace App.xcworkspace -scheme App)
case
consumer
.
platform_name
case
consumer
.
platform_name
when
:ios
when
:ios
command
<<
' CODE_SIGN_IDENTITY=- -sdk iphonesimulator'
command
+=
%w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator)
when
:watchos
when
:watchos
command
<<
' CODE_SIGN_IDENTITY=- -sdk watchsimulator'
command
+=
%w(CODE_SIGN_IDENTITY=- -sdk watchsimulator)
when
:tvos
when
:tvos
command
<<
' CODE_SIGN_IDENTITY=- -sdk appletvsimulator'
command
+=
%w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator)
end
end
output
,
status
=
_xcodebuild
"
#{
command
}
2>&1"
output
,
status
=
Dir
.
chdir
(
validation_dir
)
{
_xcodebuild
(
command
)
}
unless
status
.
success?
unless
status
.
success?
message
=
'Returned an unsuccessful exit code.'
message
=
'Returned an unsuccessful exit code.'
...
@@ -659,9 +696,8 @@ module Pod
...
@@ -659,9 +696,8 @@ module Pod
# resulting status.
# resulting status.
#
#
def
_xcodebuild
(
command
)
def
_xcodebuild
(
command
)
UI
.
puts
command
if
config
.
verbose
UI
.
puts
'xcodebuild '
<<
command
.
join
(
' '
)
if
config
.
verbose
output
=
`
#{
command
}
`
Executable
.
capture_command
(
'xcodebuild'
,
command
,
capture: :merge
)
[
output
,
$?
]
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
...
spec/unit/validator_spec.rb
View file @
0e2b2dd2
...
@@ -404,11 +404,11 @@ module Pod
...
@@ -404,11 +404,11 @@ module Pod
git
=
Executable
.
which
(
:git
)
git
=
Executable
.
which
(
:git
)
Executable
.
stubs
(
:which
).
with
(
'git'
).
returns
(
git
)
Executable
.
stubs
(
:which
).
with
(
'git'
).
returns
(
git
)
Executable
.
expects
(
:which
).
with
(
'xcodebuild'
).
times
(
4
).
returns
(
'/usr/bin/xcodebuild'
)
Executable
.
expects
(
:which
).
with
(
'xcodebuild'
).
times
(
4
).
returns
(
'/usr/bin/xcodebuild'
)
command
=
'xcodebuild clean build -target Pods'
command
=
%w(clean build -workspace App.xcworkspace -scheme App)
validator
.
expects
(
:`
).
with
(
"
#{
command
}
2>&1"
).
once
.
returns
(
''
)
Executable
.
expects
(
:capture_command
).
with
(
'xcodebuild'
,
command
,
capture: :merge
).
once
.
returns
([
''
,
stub
(
:success?
=>
true
)]
)
validator
.
expects
(
:`
).
with
(
"
#{
command
}
CODE_SIGN_IDENTITY=- -sdk appletvsimulator 2>&1"
).
once
.
returns
(
''
)
Executable
.
expects
(
:capture_command
).
with
(
'xcodebuild'
,
command
+
%w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator)
,
capture: :merge
).
once
.
returns
([
''
,
stub
(
:success?
=>
true
)]
)
validator
.
expects
(
:`
).
with
(
"
#{
command
}
CODE_SIGN_IDENTITY=- -sdk iphonesimulator 2>&1"
).
once
.
returns
(
''
)
Executable
.
expects
(
:capture_command
).
with
(
'xcodebuild'
,
command
+
%w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator)
,
capture: :merge
).
once
.
returns
([
''
,
stub
(
:success?
=>
true
)]
)
validator
.
expects
(
:`
).
with
(
"
#{
command
}
CODE_SIGN_IDENTITY=- -sdk watchsimulator 2>&1"
).
once
.
returns
(
''
)
Executable
.
expects
(
:capture_command
).
with
(
'xcodebuild'
,
command
+
%w(CODE_SIGN_IDENTITY=- -sdk watchsimulator)
,
capture: :merge
).
once
.
returns
([
''
,
stub
(
:success?
=>
true
)]
)
validator
.
validate
validator
.
validate
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