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
ed6862fd
Commit
ed6862fd
authored
Nov 05, 2011
by
Nolan Waite
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ProjectTemplate is really a module
parent
70858e8c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
47 deletions
+38
-47
installer.rb
lib/cocoapods/installer.rb
+14
-14
project_template.rb
lib/cocoapods/project_template.rb
+22
-31
integration_spec.rb
spec/integration_spec.rb
+2
-2
project_spec.rb
spec/unit/xcode/project_spec.rb
+0
-0
No files found.
lib/cocoapods/installer.rb
View file @
ed6862fd
...
...
@@ -20,8 +20,8 @@ module Pod
attr_reader
:target
def
initialize
(
podfile
,
xcodeproj
,
definition
)
@podfile
,
@
xcodeproj
,
@definition
=
podfile
,
xcodeproj
,
definition
def
initialize
(
podfile
,
project
,
definition
)
@podfile
,
@
project
,
@definition
=
podfile
,
project
,
definition
end
def
xcconfig
...
...
@@ -77,7 +77,7 @@ module Pod
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
def
install!
# First add the target to the project
@target
=
@
xcodeproj
.
targets
.
new_static_library
(
@definition
.
lib_name
)
@target
=
@
project
.
targets
.
new_static_library
(
@definition
.
lib_name
)
user_header_search_paths
=
[]
build_specifications
.
each
do
|
spec
|
...
...
@@ -101,7 +101,7 @@ module Pod
# Add all the target related support files to the group, even the copy
# resources script although the project doesn't actually use them.
support_files_group
=
@
xcodeproj
.
groups
.
find
do
|
group
|
support_files_group
=
@
project
.
groups
.
find
do
|
group
|
group
.
name
==
"Targets Support Files"
end
.
groups
.
new
(
"name"
=>
@definition
.
lib_name
)
support_files_group
.
files
.
new
(
'path'
=>
copy_resources_filename
)
...
...
@@ -132,27 +132,27 @@ module Pod
@podfile
=
podfile
end
def
template
return
@
template
if
@template
@
template
=
ProjectTemplate
.
new
(
@podfile
.
platform
)
def
project
return
@
project
if
@project
@
project
=
ProjectTemplate
.
for_platform
(
@podfile
.
platform
)
# First we need to resolve dependencies across *all* targets, so that the
# same correct versions of pods are being used for all targets. This
# happens when we call `build_specifications'.
build_specifications
.
each
do
|
spec
|
# Add all source files to the project grouped by pod
group
=
@
template
.
project
.
add_pod_group
(
spec
.
name
)
group
=
@project
.
add_pod_group
(
spec
.
name
)
spec
.
expanded_source_files
.
each
do
|
path
|
group
.
children
.
new
(
'path'
=>
path
.
to_s
)
end
end
# Add a group to hold all the target support files
@
template
.
project
.
main_group
.
groups
.
new
(
'name'
=>
'Targets Support Files'
)
@
template
@project
.
main_group
.
groups
.
new
(
'name'
=>
'Targets Support Files'
)
@
project
end
def
targets
@targets
||=
@podfile
.
targets
.
values
.
map
do
|
target_definition
|
Target
.
new
(
@podfile
,
template
.
project
,
target_definition
)
Target
.
new
(
@podfile
,
project
,
target_definition
)
end
end
...
...
@@ -166,9 +166,9 @@ module Pod
target
.
install!
target
.
create_files_in
(
root
)
end
p
bxproj
=
File
.
join
(
root
,
'Pods.xcodeproj'
)
puts
" * Writing Xcode project file to `
#{
p
bxproj
}
'"
if
config
.
verbose?
template
.
project
.
save_as
(
pbxproj
)
p
rojpath
=
File
.
join
(
root
,
'Pods.xcodeproj'
)
puts
" * Writing Xcode project file to `
#{
p
rojpath
}
'"
if
config
.
verbose?
project
.
save_as
(
projpath
)
# Post install hooks run last!
targets
.
each
do
|
target
|
...
...
lib/cocoapods/project_template.rb
View file @
ed6862fd
require
'fileutils'
module
Pod
class
ProjectTemplate
def
initialize
(
platform
)
@platform
=
platform
generate_template_project!
end
attr_reader
:platform
attr_reader
:project
def
save_to
(
pods_root
)
@project
.
save_as
(
File
.
join
(
pods_root
,
'Pods.xcodeproj'
))
end
def
generate_template_project!
@project
=
Xcode
::
Project
.
new
root
=
@project
.
objects
.
add
(
Xcode
::
Project
::
PBXProject
,
{
module
ProjectTemplate
def
self
.
for_platform
(
platform
)
project
=
Xcode
::
Project
.
new
root
=
project
.
objects
.
add
(
Xcode
::
Project
::
PBXProject
,
{
'attributes'
=>
{
'LastUpgradeCheck'
=>
'0420'
},
'compatibilityVersion'
=>
'Xcode 3.2'
,
'developmentRegion'
=>
'English'
,
'hasScannedForEncodings'
=>
'0'
,
'knownRegions'
=>
[
'en'
],
'mainGroup'
=>
@
project
.
groups
.
new
({
'sourceTree'
=>
'<group>'
}).
uuid
,
'mainGroup'
=>
project
.
groups
.
new
({
'sourceTree'
=>
'<group>'
}).
uuid
,
'projectDirPath'
=>
''
,
'projectRoot'
=>
''
,
'targets'
=>
[]
})
@
project
.
root_object
=
root
@project
.
main_group
<<
@
project
.
groups
.
new
({
project
.
root_object
=
root
project
.
main_group
<<
project
.
groups
.
new
({
'name'
=>
'Pods'
,
'sourceTree'
=>
'<group>'
})
framework
=
@
project
.
files
.
new
({
framework
=
project
.
files
.
new
({
'lastKnownFileType'
=>
'wrapper.framework'
,
'name'
=>
platform
==
:ios
?
'Foundation.framework'
:
'Cocoa.framework'
,
'path'
=>
"System/Library/Frameworks/
#{
platform
==
:ios
?
'Framework'
:
'Cocoa'
}
.framework"
,
'sourceTree'
=>
'SDKROOT'
})
framework
.
group
=
@
project
.
groups
.
new
({
framework
.
group
=
project
.
groups
.
new
({
'name'
=>
'Frameworks'
,
'sourceTree'
=>
'<group>'
})
@
project
.
main_group
<<
framework
.
group
products
=
@
project
.
groups
.
new
({
project
.
main_group
<<
framework
.
group
products
=
project
.
groups
.
new
({
'name'
=>
'Products'
,
'sourceTree'
=>
'<group>'
})
@
project
.
main_group
<<
products
@
project
.
root_object
.
products
=
products
project
.
main_group
<<
products
project
.
root_object
.
products
=
products
@project
.
root_object
.
attributes
[
'buildConfigurationList'
]
=
@
project
.
objects
.
add
(
Xcode
::
Project
::
XCConfigurationList
,
{
project
.
root_object
.
attributes
[
'buildConfigurationList'
]
=
project
.
objects
.
add
(
Xcode
::
Project
::
XCConfigurationList
,
{
'defaultConfigurationIsVisible'
=>
'0'
,
'defaultConfigurationName'
=>
'Release'
,
'buildConfigurations'
=>
[
@
project
.
objects
.
add
(
Xcode
::
Project
::
XCBuildConfiguration
,
{
project
.
objects
.
add
(
Xcode
::
Project
::
XCBuildConfiguration
,
{
'name'
=>
'Debug'
,
'buildSettings'
=>
build_settings
(
:debug
)
'buildSettings'
=>
build_settings
(
platform
,
:debug
)
}),
@
project
.
objects
.
add
(
Xcode
::
Project
::
XCBuildConfiguration
,
{
project
.
objects
.
add
(
Xcode
::
Project
::
XCBuildConfiguration
,
{
'name'
=>
'Release'
,
'buildSettings'
=>
build_settings
(
:release
)
'buildSettings'
=>
build_settings
(
platform
,
:release
)
})
].
map
(
&
:uuid
)
}).
uuid
project
end
private
COMMON_BUILD_SETTINGS
=
{
:all
=>
{
'ALWAYS_SEARCH_USER_PATHS'
=>
'NO'
,
...
...
@@ -97,7 +88,7 @@ module Pod
'SDKROOT'
=>
'macosx'
}
}
def
build_settings
(
scheme
)
def
self
.
build_settings
(
platform
,
scheme
)
settings
=
COMMON_BUILD_SETTINGS
[
:all
].
merge
(
COMMON_BUILD_SETTINGS
[
platform
])
settings
[
'COPY_PHASE_STRIP'
]
=
scheme
==
:debug
?
'NO'
:
'YES'
if
scheme
==
:debug
...
...
spec/integration_spec.rb
View file @
ed6862fd
...
...
@@ -77,7 +77,7 @@ else
(
root
+
'Pods.xcconfig'
).
read
.
should
==
installer
.
targets
.
first
.
xcconfig
.
to_s
project_file
=
(
root
+
'Pods.xcodeproj/project.pbxproj'
).
to_s
NSDictionary
.
dictionaryWithContentsOfFile
(
project_file
).
should
==
installer
.
template
.
project
.
to_hash
NSDictionary
.
dictionaryWithContentsOfFile
(
project_file
).
should
==
installer
.
project
.
to_hash
puts
"
\n
[!] Compiling static library..."
Dir
.
chdir
(
config
.
project_pods_root
)
do
...
...
@@ -144,7 +144,7 @@ else
installer
.
install!
project
=
Pod
::
Xcode
::
Project
.
new
(
config
.
project_pods_root
+
'Pods.xcodeproj'
)
project
.
source_files
.
should
==
installer
.
template
.
project
.
source_files
project
.
source_files
.
should
==
installer
.
project
.
source_files
end
it
"creates a project with multiple targets"
do
...
...
spec/unit/xcode/project_spec.rb
View file @
ed6862fd
This diff is collapsed.
Click to expand it.
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