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
1222f114
Commit
1222f114
authored
Jan 26, 2016
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Validator] Only import if the pod target is being built
parent
ea2c2170
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
validator.rb
lib/cocoapods/validator.rb
+2
-2
validator_spec.rb
spec/unit/validator_spec.rb
+13
-5
No files found.
lib/cocoapods/validator.rb
View file @
1222f114
...
@@ -399,12 +399,12 @@ module Pod
...
@@ -399,12 +399,12 @@ module Pod
if
language
==
:swift
if
language
==
:swift
source_file
=
validation_dir
.
+
(
'App/main.swift'
)
source_file
=
validation_dir
.
+
(
'App/main.swift'
)
source_file
.
parent
.
mkpath
source_file
.
parent
.
mkpath
import_statement
=
use_frameworks
?
"import
#{
pod_target
.
product_module_name
}
\n
"
:
''
import_statement
=
use_frameworks
&&
pod_target
.
should_build?
?
"import
#{
pod_target
.
product_module_name
}
\n
"
:
''
source_file
.
open
(
'w'
)
{
|
f
|
f
<<
import_statement
}
source_file
.
open
(
'w'
)
{
|
f
|
f
<<
import_statement
}
else
else
source_file
=
validation_dir
.
+
(
'App/main.m'
)
source_file
=
validation_dir
.
+
(
'App/main.m'
)
source_file
.
parent
.
mkpath
source_file
.
parent
.
mkpath
import_statement
=
if
use_frameworks
import_statement
=
if
use_frameworks
&&
pod_target
.
should_build?
"@import
#{
pod_target
.
product_module_name
}
;
\n
"
"@import
#{
pod_target
.
product_module_name
}
;
\n
"
else
else
header_name
=
"
#{
pod_target
.
product_module_name
}
/
#{
pod_target
.
product_module_name
}
.h"
header_name
=
"
#{
pod_target
.
product_module_name
}
/
#{
pod_target
.
product_module_name
}
.h"
...
...
spec/unit/validator_spec.rb
View file @
1222f114
...
@@ -496,7 +496,7 @@ module Pod
...
@@ -496,7 +496,7 @@ module Pod
end
end
it
'creates a swift import'
do
it
'creates a swift import'
do
pod_target
=
stub
(
:uses_swift?
=>
true
,
:product_module_name
=>
'ModuleName'
)
pod_target
=
stub
(
:uses_swift?
=>
true
,
:
should_build?
=>
true
,
:
product_module_name
=>
'ModuleName'
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
.
basename
.
to_s
.
should
==
'main.swift'
file
.
basename
.
to_s
.
should
==
'main.swift'
...
@@ -506,7 +506,7 @@ module Pod
...
@@ -506,7 +506,7 @@ module Pod
end
end
it
'creates an objective-c import'
do
it
'creates an objective-c import'
do
pod_target
=
stub
(
:uses_swift?
=>
false
,
:product_module_name
=>
'ModuleName'
)
pod_target
=
stub
(
:uses_swift?
=>
false
,
:
should_build?
=>
true
,
:
product_module_name
=>
'ModuleName'
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
.
basename
.
to_s
.
should
==
'main.m'
file
.
basename
.
to_s
.
should
==
'main.m'
...
@@ -517,6 +517,14 @@ module Pod
...
@@ -517,6 +517,14 @@ module Pod
int main() {}
int main() {}
OBJC
OBJC
end
end
it
'creates no import when the pod target has no source files'
do
pod_target
=
stub
(
:uses_swift?
=>
true
,
:should_build?
=>
false
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
.
basename
.
to_s
.
should
==
'main.swift'
file
.
read
.
should
==
''
end
end
end
describe
'when linting as a static lib'
do
describe
'when linting as a static lib'
do
...
@@ -526,7 +534,7 @@ module Pod
...
@@ -526,7 +534,7 @@ module Pod
end
end
it
'creates an objective-c import when a plausible umbrella header is found'
do
it
'creates an objective-c import when a plausible umbrella header is found'
do
pod_target
=
stub
(
:uses_swift?
=>
false
,
:product_module_name
=>
'ModuleName'
,
:sandbox
=>
@sandbox
)
pod_target
=
stub
(
:uses_swift?
=>
false
,
:
should_build?
=>
true
,
:
product_module_name
=>
'ModuleName'
,
:sandbox
=>
@sandbox
)
header_name
=
"
#{
pod_target
.
product_module_name
}
/
#{
pod_target
.
product_module_name
}
.h"
header_name
=
"
#{
pod_target
.
product_module_name
}
/
#{
pod_target
.
product_module_name
}
.h"
umbrella
=
pod_target
.
sandbox
.
public_headers
.
root
.
+
(
header_name
)
umbrella
=
pod_target
.
sandbox
.
public_headers
.
root
.
+
(
header_name
)
umbrella
.
dirname
.
mkpath
umbrella
.
dirname
.
mkpath
...
@@ -543,7 +551,7 @@ module Pod
...
@@ -543,7 +551,7 @@ module Pod
end
end
it
'does not create an objective-c import when no umbrella header is found'
do
it
'does not create an objective-c import when no umbrella header is found'
do
pod_target
=
stub
(
:uses_swift?
=>
false
,
:product_module_name
=>
'ModuleName'
,
:sandbox
=>
@sandbox
)
pod_target
=
stub
(
:uses_swift?
=>
false
,
:
should_build?
=>
true
,
:
product_module_name
=>
'ModuleName'
,
:sandbox
=>
@sandbox
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
=
@validator
.
send
(
:write_app_import_source_file
,
pod_target
)
file
.
basename
.
to_s
.
should
==
'main.m'
file
.
basename
.
to_s
.
should
==
'main.m'
...
@@ -559,7 +567,7 @@ module Pod
...
@@ -559,7 +567,7 @@ module Pod
it
'adds the importing file to the app target'
do
it
'adds the importing file to the app target'
do
@validator
.
stubs
(
:use_frameworks
).
returns
(
true
)
@validator
.
stubs
(
:use_frameworks
).
returns
(
true
)
@validator
.
send
(
:create_app_project
)
@validator
.
send
(
:create_app_project
)
pod_target
=
stub
(
:uses_swift?
=>
true
,
:pod_name
=>
'JSONKit'
,
:product_module_name
=>
'ModuleName'
)
pod_target
=
stub
(
:uses_swift?
=>
true
,
:
should_build?
=>
true
,
:
pod_name
=>
'JSONKit'
,
:product_module_name
=>
'ModuleName'
)
installer
=
stub
(
:pod_targets
=>
[
pod_target
])
installer
=
stub
(
:pod_targets
=>
[
pod_target
])
@validator
.
instance_variable_set
(
:@installer
,
installer
)
@validator
.
instance_variable_set
(
:@installer
,
installer
)
@validator
.
send
(
:add_app_project_import
)
@validator
.
send
(
:add_app_project_import
)
...
...
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