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
3f2ac634
Commit
3f2ac634
authored
Apr 16, 2016
by
Orta Therox
Committed by
Samuel Giddins
Apr 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for CP1.0 style target inheritance in `pod lib create`
parent
bd6046fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
init.rb
lib/cocoapods/command/init.rb
+34
-13
init_spec.rb
spec/functional/command/init_spec.rb
+1
-0
No files found.
lib/cocoapods/command/init.rb
View file @
3f2ac634
...
...
@@ -62,31 +62,52 @@ module Pod
# use_frameworks!
PLATFORM
project
.
native_targets
.
each
do
|
target
|
podfile
<<
target_module
(
target
)
# Split out the targets into app and test targets
all_app_targets
=
project
.
native_targets
.
reject
{
|
t
|
t
.
name
=~
/tests?/i
}
all_tests_targets
=
project
.
native_targets
.
select
{
|
t
|
t
.
name
=~
/tests?/i
}
# Create an array of [app, (optional)test] target pairs
app_test_pairs
=
all_app_targets
.
map
do
|
target
|
test
=
all_tests_targets
.
find
{
|
t
|
t
.
name
.
start_with?
target
.
name
}
[
target
,
test
].
compact
end
app_test_pairs
.
each
do
|
target_pair
|
podfile
<<
target_module
(
target_pair
)
end
podfile
<<
"
\n
"
end
# @param [Xcodeproj::PBXTarget] target
# A target to generate a Podfile target module for.
# @param [[Xcodeproj::PBXTarget]] targets
# An array which always has a target as it's first item
# and may optionally contain a second target as its test target
#
# @return [String] the text for the target module
#
def
target_module
(
target
)
target_module
=
"
\n
target '
#{
target
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
def
target_module
(
targets
)
app
=
targets
.
first
target_module
=
"
\n
target '
#{
app
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
template_contents
(
config
.
default_podfile_path
,
" "
)
if
target
.
name
=~
/tests?/i
target_module
<<
template_contents
(
config
.
default_test_podfile_path
)
else
target_module
<<
template_contents
(
config
.
default_podfile_path
)
test
=
targets
[
1
]
if
test
target_module
<<
"
\n
target '
#{
test
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
" inherit! :search_paths
\n
"
target_module
<<
template_contents
(
config
.
default_test_podfile_path
,
" "
)
target_module
<<
"
\n
end
\n
"
end
target_module
<<
"
\n
end
\n
"
end
def
template_contents
(
path
)
# @param [[Xcodeproj::PBXTarget]] targets
# An array which always has a target as it's first item
# and may optionally contain a second target as its test target
#
# @return [String] the text for the target module
#
def
template_contents
(
path
,
prefix
)
if
path
.
exist?
path
.
read
.
chomp
.
lines
.
map
{
|
line
|
"
#{
line
}
"
}.
join
(
"
\n
"
)
path
.
read
.
chomp
.
lines
.
map
{
|
line
|
"
#{
prefix
}
#{
line
}
"
}.
join
(
"
\n
"
)
else
''
end
...
...
spec/functional/command/init_spec.rb
View file @
3f2ac634
...
...
@@ -95,6 +95,7 @@ module Pod
open
(
config
.
default_test_podfile_path
,
'w'
)
{
|
f
|
f
<<
"pod 'Kiwi'"
}
project
=
Xcodeproj
::
Project
.
new
(
temporary_directory
+
'test.xcodeproj'
)
project
.
new_target
(
:application
,
'App'
,
:ios
)
project
.
new_target
(
:application
,
'AppTests'
,
:ios
)
project
.
save
...
...
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