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
f2fe34ce
Commit
f2fe34ce
authored
Apr 19, 2016
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Init] Automatically set use_frameworks! for a target if it is likely using swift
parent
fbaac42c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
12 deletions
+36
-12
init.rb
lib/cocoapods/command/init.rb
+21
-6
init_spec.rb
spec/functional/command/init_spec.rb
+15
-6
No files found.
lib/cocoapods/command/init.rb
View file @
f2fe34ce
...
@@ -58,12 +58,12 @@ module Pod
...
@@ -58,12 +58,12 @@ module Pod
podfile
<<
<<-
PLATFORM
.
strip_heredoc
podfile
<<
<<-
PLATFORM
.
strip_heredoc
# Uncomment this line to define a global platform for your project
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '9.0'
# Uncomment this line if you're using Swift
# use_frameworks!
PLATFORM
PLATFORM
# Split out the targets into app and test targets
# Split out the targets into app and test targets
test_targets
,
app_targets
=
project
.
native_targets
.
partition
{
|
t
|
t
.
name
=~
/test/i
}
test_targets
,
app_targets
=
project
.
native_targets
.
sort_by
{
|
t
|
t
.
name
.
downcase
}.
partition
{
|
t
|
t
.
name
=~
/test/i
}
app_targets
.
each
do
|
app_target
|
app_targets
.
each
do
|
app_target
|
test_targets_for_app
=
test_targets
.
select
do
|
target
|
test_targets_for_app
=
test_targets
.
select
do
|
target
|
...
@@ -83,12 +83,27 @@ module Pod
...
@@ -83,12 +83,27 @@ module Pod
#
#
def
target_module
(
app
,
tests
)
def
target_module
(
app
,
tests
)
target_module
=
"
\n
target '
#{
app
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
=
"
\n
target '
#{
app
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
template_contents
(
config
.
default_podfile_path
,
" "
,
"Pods for
#{
app
.
name
}
\n
"
)
target_module
<<
if
app
.
resolved_build_setting
(
'SWIFT_OPTIMIZATION_LEVEL'
).
values
.
any?
<<-
RUBY
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
RUBY
else
<<-
RUBY
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
RUBY
end
target_module
<<
template_contents
(
config
.
default_podfile_path
,
' '
,
"Pods for
#{
app
.
name
}
\n
"
)
tests
.
each
do
|
test
|
tests
.
each
do
|
test
|
target_module
<<
"
\n
target '
#{
test
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
"
\n
target '
#{
test
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
" inherit! :search_paths
\n
"
target_module
<<
" inherit! :search_paths
\n
"
target_module
<<
template_contents
(
config
.
default_test_podfile_path
,
" "
,
"Pods for testing"
)
target_module
<<
template_contents
(
config
.
default_test_podfile_path
,
' '
,
'Pods for testing'
)
target_module
<<
"
\n
end
\n
"
target_module
<<
"
\n
end
\n
"
end
end
...
@@ -105,7 +120,7 @@ module Pod
...
@@ -105,7 +120,7 @@ module Pod
if
path
.
exist?
if
path
.
exist?
path
.
read
.
chomp
.
lines
.
map
{
|
line
|
"
#{
prefix
}#{
line
}
"
}.
join
(
"
\n
"
)
path
.
read
.
chomp
.
lines
.
map
{
|
line
|
"
#{
prefix
}#{
line
}
"
}.
join
(
"
\n
"
)
else
else
"
#{
prefix
}
#
#{
fallback
}
"
"
#{
prefix
}
#
#{
fallback
}
"
end
end
end
end
end
end
...
...
spec/functional/command/init_spec.rb
View file @
f2fe34ce
...
@@ -91,7 +91,8 @@ module Pod
...
@@ -91,7 +91,8 @@ module Pod
project
=
Xcodeproj
::
Project
.
new
(
temporary_directory
+
'test.xcodeproj'
)
project
=
Xcodeproj
::
Project
.
new
(
temporary_directory
+
'test.xcodeproj'
)
project
.
new_target
(
:application
,
'App'
,
:ios
)
project
.
new_target
(
:application
,
'App'
,
:ios
)
project
.
new_target
(
:application
,
'AppTests'
,
:ios
)
project
.
new_target
(
:application
,
'AppTests'
,
:ios
)
project
.
new_target
(
:application
,
"AppFeatureTests"
,
:ios
)
project
.
new_target
(
:application
,
'AppFeatureTests'
,
:ios
)
project
.
new_target
(
:application
,
'Swifty App'
,
:osx
,
nil
,
nil
,
:swift
)
project
.
save
project
.
save
run_command
(
'init'
)
run_command
(
'init'
)
...
@@ -99,30 +100,38 @@ module Pod
...
@@ -99,30 +100,38 @@ module Pod
expected_podfile
=
<<-
RUBY
.
strip_heredoc
expected_podfile
=
<<-
RUBY
.
strip_heredoc
# Uncomment this line to define a global platform for your project
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '9.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'App' do
target 'App' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for App
# Pods for App
target 'AppTests' do
target 'App
Feature
Tests' do
inherit! :search_paths
inherit! :search_paths
# Pods for testing
# Pods for testing
end
end
target 'App
Feature
Tests' do
target 'AppTests' do
inherit! :search_paths
inherit! :search_paths
# Pods for testing
# Pods for testing
end
end
end
end
target 'Swifty App' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Swifty App
end
RUBY
RUBY
File
.
read
(
'Podfile'
).
should
==
expected_podfile
File
.
read
(
'Podfile'
).
should
==
expected_podfile
end
end
end
end
it
'includes default test pods in test targets in a Podfile'
do
it
'includes default test pods in test targets in a Podfile'
do
Dir
.
chdir
(
temporary_directory
)
do
Dir
.
chdir
(
temporary_directory
)
do
tmp_templates_dir
=
Pathname
.
pwd
+
'templates_dir'
tmp_templates_dir
=
Pathname
.
pwd
+
'templates_dir'
...
...
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