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