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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
22 deletions
+58
-22
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
+49
-13
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
validator
.
validate
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
end
if
validator
.
validated?
...
...
lib/cocoapods/command/spec/lint.rb
View file @
0e2b2dd2
...
...
@@ -61,7 +61,7 @@ module Pod
failure_reasons
<<
validator
.
failure_reason
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
end
end
...
...
lib/cocoapods/installer/analyzer.rb
View file @
0e2b2dd2
...
...
@@ -247,12 +247,12 @@ module Pod
if
config
.
integrate_targets?
target_inspection
=
result
.
target_inspections
[
target_definition
]
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_build_configurations
=
target_inspection
.
build_configurations
target
.
archs
=
target_inspection
.
archs
else
target
.
client_root
=
config
.
installation_root
target
.
client_root
=
config
.
installation_root
.
realpath
target
.
user_target_uuids
=
[]
target
.
user_build_configurations
=
target_definition
.
build_configurations
||
{
'Release'
=>
:release
,
'Debug'
=>
:debug
}
if
target_definition
.
platform
&&
target_definition
.
platform
.
name
==
:osx
...
...
lib/cocoapods/validator.rb
View file @
0e2b2dd2
...
...
@@ -257,17 +257,24 @@ module Pod
UI
.
message
"
\n\n
#{
spec
}
- Analyzing on
#{
platform
}
platform."
.
green
.
reversed
@consumer
=
spec
.
consumer
(
platform
)
setup_validation_environment
begin
create_app_project
download_pod
check_file_patterns
install_pod
add_app_project_import
validate_vendored_dynamic_frameworks
build_pod
ensure
tear_down_validation_environment
end
validated?
end
return
false
if
fail_fast
&&
!
valid
perform_extensive_subspec_analysis
(
spec
)
unless
@no_subspecs
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."
)
false
end
...
...
@@ -340,10 +347,10 @@ module Pod
validation_dir
.
mkpath
@original_config
=
Config
.
instance
.
clone
config
.
installation_root
=
validation_dir
config
.
sandbox_root
=
validation_dir
+
'Pods'
config
.
silent
=
!
config
.
verbose
config
.
integrate_targets
=
fals
e
config
.
integrate_targets
=
tru
e
config
.
skip_repo_update
=
true
config
.
deterministic_uuids
=
false
end
def
tear_down_validation_environment
...
...
@@ -361,13 +368,44 @@ module Pod
@file_accessor
=
@installer
.
pod_targets
.
flat_map
(
&
:file_accessors
).
find
{
|
fa
|
fa
.
spec
.
name
==
consumer
.
spec
.
name
}
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
# for all available platforms with xcodebuild.
#
def
install_pod
%i(determine_dependency_product_types verify_no_duplicate_framework_names
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
)
}
deployment_target
=
spec
.
subspec_by_name
(
subspec_name
).
deployment_target
(
consumer
.
platform_name
)
...
...
@@ -412,7 +450,7 @@ module Pod
UI
.
warn
"Skipping compilation with `xcodebuild' because it can't be found.
\n
"
.
yellow
else
UI
.
message
"
\n
Building with xcodebuild.
\n
"
.
yellow
do
output
=
Dir
.
chdir
(
config
.
sandbox_root
)
{
xcodebuild
}
output
=
xcodebuild
UI
.
puts
output
parsed_output
=
parse_xcodebuild_output
(
output
)
parsed_output
.
each
do
|
message
|
...
...
@@ -631,18 +669,17 @@ module Pod
# returns its output (both STDOUT and STDERR).
#
def
xcodebuild
command
=
'xcodebuild clean build -target Pods'
command
=
%W(clean build -workspace App.xcworkspace -scheme App)
case
consumer
.
platform_name
when
:ios
command
<<
' CODE_SIGN_IDENTITY=- -sdk iphonesimulator'
command
+=
%w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator)
when
:watchos
command
<<
' CODE_SIGN_IDENTITY=- -sdk watchsimulator'
command
+=
%w(CODE_SIGN_IDENTITY=- -sdk watchsimulator)
when
:tvos
command
<<
' CODE_SIGN_IDENTITY=- -sdk appletvsimulator'
command
+=
%w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator)
end
output
,
status
=
_xcodebuild
"
#{
command
}
2>&1"
output
,
status
=
Dir
.
chdir
(
validation_dir
)
{
_xcodebuild
(
command
)
}
unless
status
.
success?
message
=
'Returned an unsuccessful exit code.'
...
...
@@ -659,9 +696,8 @@ module Pod
# resulting status.
#
def
_xcodebuild
(
command
)
UI
.
puts
command
if
config
.
verbose
output
=
`
#{
command
}
`
[
output
,
$?
]
UI
.
puts
'xcodebuild '
<<
command
.
join
(
' '
)
if
config
.
verbose
Executable
.
capture_command
(
'xcodebuild'
,
command
,
capture: :merge
)
end
#-------------------------------------------------------------------------#
...
...
spec/unit/validator_spec.rb
View file @
0e2b2dd2
...
...
@@ -404,11 +404,11 @@ module Pod
git
=
Executable
.
which
(
:git
)
Executable
.
stubs
(
:which
).
with
(
'git'
).
returns
(
git
)
Executable
.
expects
(
:which
).
with
(
'xcodebuild'
).
times
(
4
).
returns
(
'/usr/bin/xcodebuild'
)
command
=
'xcodebuild clean build -target Pods'
validator
.
expects
(
:`
).
with
(
"
#{
command
}
2>&1"
).
once
.
returns
(
''
)
validator
.
expects
(
:`
).
with
(
"
#{
command
}
CODE_SIGN_IDENTITY=- -sdk appletvsimulator 2>&1"
).
once
.
returns
(
''
)
validator
.
expects
(
:`
).
with
(
"
#{
command
}
CODE_SIGN_IDENTITY=- -sdk iphonesimulator 2>&1"
).
once
.
returns
(
''
)
validator
.
expects
(
:`
).
with
(
"
#{
command
}
CODE_SIGN_IDENTITY=- -sdk watchsimulator 2>&1"
).
once
.
returns
(
''
)
command
=
%w(clean build -workspace App.xcworkspace -scheme App)
Executable
.
expects
(
:capture_command
).
with
(
'xcodebuild'
,
command
,
capture: :merge
).
once
.
returns
([
''
,
stub
(
:success?
=>
true
)]
)
Executable
.
expects
(
:capture_command
).
with
(
'xcodebuild'
,
command
+
%w(CODE_SIGN_IDENTITY=- -sdk appletvsimulator)
,
capture: :merge
).
once
.
returns
([
''
,
stub
(
:success?
=>
true
)]
)
Executable
.
expects
(
:capture_command
).
with
(
'xcodebuild'
,
command
+
%w(CODE_SIGN_IDENTITY=- -sdk iphonesimulator)
,
capture: :merge
).
once
.
returns
([
''
,
stub
(
:success?
=>
true
)]
)
Executable
.
expects
(
:capture_command
).
with
(
'xcodebuild'
,
command
+
%w(CODE_SIGN_IDENTITY=- -sdk watchsimulator)
,
capture: :merge
).
once
.
returns
([
''
,
stub
(
:success?
=>
true
)]
)
validator
.
validate
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