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
beb77b4a
Commit
beb77b4a
authored
Nov 01, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create iOS static library project programmatically (WIP).
parent
35db5a85
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
213 additions
and
243 deletions
+213
-243
installer.rb
lib/cocoapods/installer.rb
+6
-1
project.rb
lib/cocoapods/xcode/project.rb
+158
-74
project_spec.rb
spec/unit/xcode/project_spec.rb
+46
-59
project.pbxproj
...cocoa-touch-static-library/Pods.xcodeproj/project.pbxproj
+3
-109
No files found.
lib/cocoapods/installer.rb
View file @
beb77b4a
...
@@ -34,7 +34,12 @@ module Pod
...
@@ -34,7 +34,12 @@ module Pod
end
end
def
xcodeproj
def
xcodeproj
@xcodeproj
||=
Xcode
::
Project
.
new
(
template
.
xcodeproj_path
)
unless
@xcodeproj
@xcodeproj
=
Xcode
::
Project
.
new
(
template
.
xcodeproj_path
)
target
=
@xcodeproj
.
targets
.
new_static_library
(
'Pods'
)
p
target
.
attributes
end
@xcodeproj
end
end
# 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.
...
...
lib/cocoapods/xcode/project.rb
View file @
beb77b4a
...
@@ -16,17 +16,34 @@ module Pod
...
@@ -16,17 +16,34 @@ module Pod
names
.
each
{
|
name
|
attribute
(
name
)
}
names
.
each
{
|
name
|
attribute
(
name
)
}
end
end
def
self
.
has_many
(
plural_attr_name
,
options
=
{})
def
self
.
has_many
(
plural_attr_name
,
options
=
{}
,
&
block
)
klass
=
options
[
:class
]
||
PBXFileReference
klass
=
options
[
:class
]
||
PBXFileReference
singular_attr_name
=
options
[
:singular
]
||
plural_attr_name
.
to_s
[
0
..-
2
]
# strip off 's'
singular_attr_name
=
options
[
:singular
]
||
plural_attr_name
.
to_s
[
0
..-
2
]
# strip off 's'
uuid_list_name
=
"
#{
singular_attr_name
}
References"
if
options
[
:fkey_on_target
]
attribute
(
plural_attr_name
,
uuid_list_name
)
define_method
(
plural_attr_name
)
do
define_method
(
plural_attr_name
)
do
scoped
=
@project
.
objects
.
select_by_class
(
klass
).
select
do
|
object
|
uuids
=
send
(
uuid_list_name
)
object
.
send
(
options
[
:uuid
])
==
self
.
uuid
list_by_class
(
uuids
,
klass
)
end
end
PBXObjectList
.
new
(
klass
,
@project
,
scoped
)
do
|
object
|
define_method
(
"
#{
plural_attr_name
}
="
)
do
|
objects
|
object
.
send
(
"
#{
options
[
:uuid
]
}
="
,
self
.
uuid
)
send
(
"
#{
uuid_list_name
}
="
,
objects
.
map
(
&
:uuid
))
end
end
else
uuid_list_name
=
options
[
:uuid
]
||
"
#{
singular_attr_name
}
References"
attribute
(
plural_attr_name
,
uuid_list_name
)
define_method
(
plural_attr_name
)
do
uuids
=
send
(
uuid_list_name
)
if
block
list_by_class
(
uuids
,
klass
)
do
|
object
|
instance_exec
(
object
,
&
block
)
end
else
list_by_class
(
uuids
,
klass
)
end
end
define_method
(
"
#{
plural_attr_name
}
="
)
do
|
objects
|
send
(
"
#{
uuid_list_name
}
="
,
objects
.
map
(
&
:uuid
))
end
end
end
end
end
...
@@ -64,6 +81,10 @@ module Pod
...
@@ -64,6 +81,10 @@ module Pod
self
.
isa
||=
self
.
class
.
isa
self
.
isa
||=
self
.
class
.
isa
end
end
def
==
(
other
)
other
.
is_a?
(
PBXObject
)
&&
self
.
uuid
==
other
.
uuid
end
def
inspect
def
inspect
"#<
#{
isa
}
UUID: `
#{
uuid
}
', name: `
#{
name
}
'>"
"#<
#{
isa
}
UUID: `
#{
uuid
}
', name: `
#{
name
}
'>"
end
end
...
@@ -79,13 +100,17 @@ module Pod
...
@@ -79,13 +100,17 @@ module Pod
uuid
.
gsub
(
'-'
,
''
)[
0
..
23
]
uuid
.
gsub
(
'-'
,
''
)[
0
..
23
]
end
end
def
list_by_class
(
uuids
,
klass
,
scoped
=
nil
)
def
list_by_class
(
uuids
,
klass
,
scoped
=
nil
,
&
block
)
unless
scoped
unless
scoped
scoped
=
uuids
.
map
{
|
uuid
|
@project
.
objects
[
uuid
]
}.
select
{
|
o
|
o
.
is_a?
(
klass
)
}
scoped
=
uuids
.
map
{
|
uuid
|
@project
.
objects
[
uuid
]
}.
select
{
|
o
|
o
.
is_a?
(
klass
)
}
end
end
PBXObjectList
.
new
(
klass
,
@project
,
scoped
)
do
|
object
|
if
block
# Add the uuid of a newly created object to the uuids list
PBXObjectList
.
new
(
klass
,
@project
,
scoped
,
&
block
)
uuids
<<
object
.
uuid
else
PBXObjectList
.
new
(
klass
,
@project
,
scoped
)
do
|
object
|
# Add the uuid of a newly created object to the uuids list
uuids
<<
object
.
uuid
end
end
end
end
end
end
end
...
@@ -105,7 +130,7 @@ module Pod
...
@@ -105,7 +130,7 @@ module Pod
class
PBXFileReference
<
PBXObject
class
PBXFileReference
<
PBXObject
attributes
:path
,
:sourceTree
,
:explicitFileType
,
:includeInIndex
attributes
:path
,
:sourceTree
,
:explicitFileType
,
:includeInIndex
has_
one
:buildFile
,
:uuid
=>
:fileRef
,
:class
=>
Project
::
PBXBuildFile
has_
many
:buildFiles
,
:uuid
=>
:fileRef
,
:fkey_on_target
=>
true
,
:class
=>
Project
::
PBXBuildFile
def
initialize
(
project
,
uuid
,
attributes
)
def
initialize
(
project
,
uuid
,
attributes
)
is_new
=
uuid
.
nil?
is_new
=
uuid
.
nil?
...
@@ -113,6 +138,7 @@ module Pod
...
@@ -113,6 +138,7 @@ module Pod
self
.
path
=
path
if
path
# sets default name
self
.
path
=
path
if
path
# sets default name
self
.
sourceTree
||=
'SOURCE_ROOT'
self
.
sourceTree
||=
'SOURCE_ROOT'
if
is_new
if
is_new
@project
.
main_group
.
children
<<
self
@project
.
build_files
.
new
.
file
=
self
@project
.
build_files
.
new
.
file
=
self
end
end
end
end
...
@@ -131,7 +157,19 @@ module Pod
...
@@ -131,7 +157,19 @@ module Pod
class
PBXGroup
<
PBXObject
class
PBXGroup
<
PBXObject
attributes
:sourceTree
attributes
:sourceTree
has_many
:children
,
:singular
=>
:child
has_many
:children
,
:singular
=>
:child
do
|
object
|
if
object
.
is_a?
(
PBXFileReference
)
# Remove from the group it was in
if
group
=
@project
.
groups
.
find
{
|
group
|
group
.
children
.
include?
(
object
)
}
# TODO
# * group.children.delete(object)
# * object.group = nil
group
.
childReferences
.
delete
(
object
.
uuid
)
end
end
childReferences
<<
object
.
uuid
end
def
initialize
(
*
)
def
initialize
(
*
)
super
super
...
@@ -144,32 +182,15 @@ module Pod
...
@@ -144,32 +182,15 @@ module Pod
end
end
def
source_files
def
source_files
list_by_class
(
childReferences
,
PBXFileReference
,
files
.
select
(
&
:buildFile
)
)
list_by_class
(
childReferences
,
PBXFileReference
,
files
.
reject
{
|
file
|
file
.
buildFiles
.
empty?
}
)
end
end
def
groups
def
groups
list_by_class
(
childReferences
,
PBXGroup
)
list_by_class
(
childReferences
,
PBXGroup
)
end
end
def
add_source_file
(
path
,
copy_header_phase
=
nil
,
compiler_flags
=
nil
)
file
=
files
.
new
(
'path'
=>
path
.
to_s
)
build_file
=
file
.
buildFile
if
path
.
extname
==
'.h'
build_file
.
settings
=
{
'ATTRIBUTES'
=>
[
"Public"
]
}
# Working around a bug in Xcode 4.2 betas, remove this once the Xcode bug is fixed:
# https://github.com/alloy/cocoapods/issues/13
#phase = copy_header_phase || @project.headers_build_phases.first
phase
=
copy_header_phase
||
@project
.
copy_files_build_phases
.
first
# TODO is this really needed?
phase
.
files
<<
build_file
else
build_file
.
settings
=
{
'COMPILER_FLAGS'
=>
compiler_flags
}
if
compiler_flags
@project
.
source_build_phase
.
files
<<
build_file
end
file
end
def
<<
(
child
)
def
<<
(
child
)
child
References
<<
child
.
uui
d
child
ren
<<
chil
d
end
end
end
end
...
@@ -179,6 +200,7 @@ module Pod
...
@@ -179,6 +200,7 @@ module Pod
end
end
class
PBXBuildPhase
<
PBXObject
class
PBXBuildPhase
<
PBXObject
# TODO rename this to buildFiles and add a files :through => :buildFiles shortcut
has_many
:files
,
:class
=>
PBXBuildFile
has_many
:files
,
:class
=>
PBXBuildFile
attributes
:buildActionMask
,
:runOnlyForDeploymentPostprocessing
attributes
:buildActionMask
,
:runOnlyForDeploymentPostprocessing
...
@@ -195,6 +217,13 @@ module Pod
...
@@ -195,6 +217,13 @@ module Pod
class
PBXCopyFilesBuildPhase
<
PBXBuildPhase
class
PBXCopyFilesBuildPhase
<
PBXBuildPhase
attributes
:dstPath
,
:dstSubfolderSpec
attributes
:dstPath
,
:dstSubfolderSpec
def
self
.
new_pod_dir
(
project
,
pod_name
,
path
)
new
(
project
,
nil
,
{
"dstPath"
=>
"$(PUBLIC_HEADERS_FOLDER_PATH)/
#{
path
}
"
,
"name"
=>
"Copy
#{
pod_name
}
Public Headers"
,
})
end
def
initialize
(
*
)
def
initialize
(
*
)
super
super
self
.
dstSubfolderSpec
||=
"16"
self
.
dstSubfolderSpec
||=
"16"
...
@@ -218,11 +247,28 @@ module Pod
...
@@ -218,11 +247,28 @@ module Pod
belongs_to
:buildConfigurationList
belongs_to
:buildConfigurationList
belongs_to
:product
,
:uuid
=>
:productReference
belongs_to
:product
,
:uuid
=>
:productReference
def
self
.
new_static_library
(
project
,
productName
)
# TODO should probably switch the uuid and attributes argument
target
=
new
(
project
,
nil
,
'productType'
=>
STATIC_LIBRARY
,
'productName'
=>
productName
)
target
.
product
.
path
=
"lib
#{
productName
}
.a"
target
.
product
.
includeInIndex
=
"0"
# no idea what this is
target
.
product
.
explicitFileType
=
"archive.ar"
target
.
buildPhases
.
add
(
PBXSourcesBuildPhase
)
buildPhase
=
target
.
buildPhases
.
add
(
PBXFrameworksBuildPhase
)
project
.
groups
.
find
{
|
g
|
g
.
name
==
'Frameworks'
}.
files
.
each
do
|
framework
|
buildPhase
.
files
<<
framework
.
buildFiles
.
new
end
target
.
buildPhases
.
add
(
PBXCopyFilesBuildPhase
,
'dstPath'
=>
'$(PUBLIC_HEADERS_FOLDER_PATH)'
)
target
end
def
initialize
(
project
,
*
)
def
initialize
(
project
,
*
)
super
super
self
.
buildPhaseReferences
||=
[]
self
.
name
||=
productName
self
.
buildRuleReferences
||=
[]
self
.
buildRuleReferences
||=
[]
self
.
dependencyReferences
||=
[]
self
.
dependencyReferences
||=
[]
unless
buildConfigurationList
unless
buildConfigurationList
self
.
buildConfigurationList
=
project
.
objects
.
add
(
XCConfigurationList
)
self
.
buildConfigurationList
=
project
.
objects
.
add
(
XCConfigurationList
)
...
@@ -231,20 +277,38 @@ module Pod
...
@@ -231,20 +277,38 @@ module Pod
buildConfigurationList
.
buildConfigurations
.
new
(
'name'
=>
'Release'
)
buildConfigurationList
.
buildConfigurations
.
new
(
'name'
=>
'Release'
)
end
end
unless
product
self
.
product
||=
project
.
files
.
new
(
'sourceTree'
=>
'BUILT_PRODUCTS_DIR'
)
self
.
product
=
project
.
objects
.
add
(
PBXFileReference
,
'sourceTree'
=>
'BUILT_PRODUCTS_DIR'
)
self
.
buildPhaseReferences
||=
[]
case
productType
when
STATIC_LIBRARY
product
.
path
=
"lib
#{
productName
}
.a"
product
.
includeInIndex
=
"0"
# no idea what this is
product
.
explicitFileType
=
"archive.ar"
end
end
end
end
def
buildConfigurations
def
buildConfigurations
buildConfigurationList
.
buildConfigurations
buildConfigurationList
.
buildConfigurations
end
end
def
source_build_phases
buildPhases
.
select_by_class
(
PBXSourcesBuildPhase
)
end
def
copy_files_build_phases
buildPhases
.
select_by_class
(
PBXCopyFilesBuildPhase
)
end
def
add_source_file
(
path
,
copy_header_phase
=
nil
,
compiler_flags
=
nil
)
file
=
@project
.
files
.
new
(
'path'
=>
path
.
to_s
)
buildFile
=
file
.
buildFiles
.
new
if
path
.
extname
==
'.h'
buildFile
.
settings
=
{
'ATTRIBUTES'
=>
[
"Public"
]
}
# Working around a bug in Xcode 4.2 betas, remove this once the Xcode bug is fixed:
# https://github.com/alloy/cocoapods/issues/13
#phase = copy_header_phase || headers_build_phases.first
phase
=
copy_header_phase
||
copy_files_build_phases
.
first
phase
.
files
<<
buildFile
else
buildFile
.
settings
=
{
'COMPILER_FLAGS'
=>
compiler_flags
}
if
compiler_flags
source_build_phases
.
first
.
files
<<
buildFile
end
file
end
end
end
class
XCBuildConfiguration
<
PBXObject
class
XCBuildConfiguration
<
PBXObject
...
@@ -281,7 +345,11 @@ module Pod
...
@@ -281,7 +345,11 @@ module Pod
@represented_class
=
represented_class
@represented_class
=
represented_class
@project
=
project
@project
=
project
@scoped_hash
=
scoped
.
is_a?
(
Array
)
?
scoped
.
inject
({})
{
|
h
,
o
|
h
[
o
.
uuid
]
=
o
.
attributes
;
h
}
:
scoped
@scoped_hash
=
scoped
.
is_a?
(
Array
)
?
scoped
.
inject
({})
{
|
h
,
o
|
h
[
o
.
uuid
]
=
o
.
attributes
;
h
}
:
scoped
@callback
=
new_object_callback
@callback
=
new_object_callback
||
lambda
{
|
o
|
add_object
(
o
)
}
end
def
empty?
@scoped_hash
.
empty?
end
end
def
[]
(
uuid
)
def
[]
(
uuid
)
...
@@ -292,14 +360,13 @@ module Pod
...
@@ -292,14 +360,13 @@ module Pod
def
add
(
klass
,
hash
=
{})
def
add
(
klass
,
hash
=
{})
object
=
klass
.
new
(
@project
,
nil
,
hash
)
object
=
klass
.
new
(
@project
,
nil
,
hash
)
@project
.
objects_hash
[
object
.
uuid
]
=
object
.
attributes
add_object
(
object
)
@callback
.
call
(
object
)
if
@callback
object
object
end
end
def
new
(
hash
=
{})
def
new
(
hash
=
{})
object
=
add
(
@represented_class
,
hash
)
add
(
@represented_class
,
hash
)
@callback
.
call
(
object
)
if
@callback
object
end
end
def
<<
(
object
)
def
<<
(
object
)
...
@@ -312,14 +379,51 @@ module Pod
...
@@ -312,14 +379,51 @@ module Pod
end
end
end
end
def
==
(
other
)
self
.
to_a
==
other
.
to_a
end
def
first
to_a
.
first
end
def
last
to_a
.
last
end
def
inspect
def
inspect
"<PBXObjectList:
#{
map
(
&
:inspect
)
}
>"
"<PBXObjectList:
#{
map
(
&
:inspect
)
}
>"
end
end
# Only makes sense on
the list that has the full objects_hash as its scoped hash
.
# Only makes sense on
lists that contain mixed classes
.
def
select_by_class
(
klass
)
def
select_by_class
(
klass
)
scoped
=
@project
.
objects_hash
.
select
{
|
_
,
attr
|
attr
[
'isa'
]
==
klass
.
isa
}
scoped
=
@scoped_hash
.
select
{
|
_
,
attr
|
attr
[
'isa'
]
==
klass
.
isa
}
PBXObjectList
.
new
(
klass
,
@project
,
scoped
)
PBXObjectList
.
new
(
klass
,
@project
,
scoped
)
do
|
object
|
# Objects added to the subselection should still use the same
# callback as this list.
self
<<
object
end
end
def
method_missing
(
name
,
*
args
,
&
block
)
if
@represented_class
.
respond_to?
(
name
)
object
=
@represented_class
.
send
(
name
,
@project
,
*
args
)
# The callbacks are only for PBXObject instances instantiated
# from the class method that we forwarded the message to.
if
object
.
is_a?
(
PBXObject
)
add_object
(
object
)
@callback
.
call
(
object
)
end
object
else
super
end
end
private
def
add_object
(
object
)
@project
.
objects_hash
[
object
.
uuid
]
=
object
.
attributes
end
end
end
end
...
@@ -367,14 +471,6 @@ module Pod
...
@@ -367,14 +471,6 @@ module Pod
objects
.
select_by_class
(
PBXBuildFile
)
objects
.
select_by_class
(
PBXBuildFile
)
end
end
def
source_build_phase
objects
.
find
{
|
o
|
o
.
is_a?
(
PBXSourcesBuildPhase
)
}
end
def
copy_files_build_phases
objects
.
select_by_class
(
PBXCopyFilesBuildPhase
)
end
def
targets
def
targets
objects
.
select_by_class
(
PBXNativeTarget
)
objects
.
select_by_class
(
PBXNativeTarget
)
end
end
...
@@ -395,18 +491,6 @@ module Pod
...
@@ -395,18 +491,6 @@ module Pod
@plist
.
writeToFile
(
File
.
join
(
projpath
,
'project.pbxproj'
),
atomically
:true
)
@plist
.
writeToFile
(
File
.
join
(
projpath
,
'project.pbxproj'
),
atomically
:true
)
end
end
# TODO add comments, or even constants, describing what these magic numbers are.
def
add_copy_header_build_phase
(
name
,
path
)
phase
=
copy_files_build_phases
.
new
({
"buildActionMask"
=>
"2147483647"
,
"dstPath"
=>
"$(PUBLIC_HEADERS_FOLDER_PATH)/
#{
path
}
"
,
"dstSubfolderSpec"
=>
"16"
,
"name"
=>
"Copy
#{
name
}
Public Headers"
,
"runOnlyForDeploymentPostprocessing"
=>
"0"
,
})
targets
.
first
.
buildPhases
<<
phase
phase
end
# A silly hack to pretty print the objects hash from MacRuby.
# A silly hack to pretty print the objects hash from MacRuby.
def
pretty_print
def
pretty_print
...
...
spec/unit/xcode/project_spec.rb
View file @
beb77b4a
...
@@ -23,6 +23,10 @@ describe "Pod::Xcode::Project" do
...
@@ -23,6 +23,10 @@ describe "Pod::Xcode::Project" do
@project
.
to_hash
.
should
==
NSDictionary
.
dictionaryWithContentsOfFile
(
template_file
)
@project
.
to_hash
.
should
==
NSDictionary
.
dictionaryWithContentsOfFile
(
template_file
)
end
end
before
do
@target
=
@project
.
targets
.
new_static_library
(
'Pods'
)
end
it
"returns the objects hash"
do
it
"returns the objects hash"
do
@project
.
objects_hash
.
should
==
@project
.
to_hash
[
'objects'
]
@project
.
objects_hash
.
should
==
@project
.
to_hash
[
'objects'
]
end
end
...
@@ -50,6 +54,22 @@ describe "Pod::Xcode::Project" do
...
@@ -50,6 +54,22 @@ describe "Pod::Xcode::Project" do
end
end
end
end
describe
"a PBXFileReference"
do
before
do
@file
=
@project
.
files
.
new
(
'path'
=>
'some/file.m'
)
end
it
"is automatically added to the main group"
do
@project
.
main_group
.
children
.
should
.
include
@file
end
it
"is removed from the original group when added to another group"
do
@project
.
pods
.
children
<<
@file
@project
.
pods
.
children
.
should
.
include
@file
@project
.
main_group
.
children
.
should
.
not
.
include
@file
end
end
describe
"a new PBXBuildPhase"
do
describe
"a new PBXBuildPhase"
do
before
do
before
do
@phase
=
@project
.
objects
.
add
(
Pod
::
Xcode
::
Project
::
PBXBuildPhase
)
@phase
=
@project
.
objects
.
add
(
Pod
::
Xcode
::
Project
::
PBXBuildPhase
)
...
@@ -132,15 +152,8 @@ describe "Pod::Xcode::Project" do
...
@@ -132,15 +152,8 @@ describe "Pod::Xcode::Project" do
end
end
describe
"a new PBXNativeTarget"
do
describe
"a new PBXNativeTarget"
do
before
do
@target
=
@project
.
targets
.
new
({
'productName'
=>
'Pods'
,
'productType'
=>
Pod
::
Xcode
::
Project
::
PBXNativeTarget
::
STATIC_LIBRARY
})
#@target = @project.targets.first
end
it
"returns the product name, which is the name of the binary (minus prefix/suffix)"
do
it
"returns the product name, which is the name of the binary (minus prefix/suffix)"
do
@target
.
name
.
should
==
"Pods"
@target
.
productName
.
should
==
"Pods"
@target
.
productName
.
should
==
"Pods"
end
end
...
@@ -232,7 +245,7 @@ describe "Pod::Xcode::Project" do
...
@@ -232,7 +245,7 @@ describe "Pod::Xcode::Project" do
it
"adds a new PBXBuildFile to the objects hash when a new PBXFileReference is created"
do
it
"adds a new PBXBuildFile to the objects hash when a new PBXFileReference is created"
do
file
=
@project
.
files
.
new
(
'name'
=>
'/some/source/file.h'
)
file
=
@project
.
files
.
new
(
'name'
=>
'/some/source/file.h'
)
build_file
=
file
.
buildFile
build_file
=
file
.
buildFile
s
.
new
build_file
.
file
=
file
build_file
.
file
=
file
build_file
.
fileRef
.
should
==
file
.
uuid
build_file
.
fileRef
.
should
==
file
.
uuid
build_file
.
isa
.
should
==
'PBXBuildFile'
build_file
.
isa
.
should
==
'PBXBuildFile'
...
@@ -250,35 +263,18 @@ describe "Pod::Xcode::Project" do
...
@@ -250,35 +263,18 @@ describe "Pod::Xcode::Project" do
}).
should
.
not
==
nil
}).
should
.
not
==
nil
end
end
it
"adds an `m' or `c' file as a build file, adds it to the specified group, and adds it to the `sources build' phase list"
do
it
"adds an `m' or `c' file to the `sources build' phase list"
do
file_ref_uuids
,
build_file_uuids
=
[],
[]
group
=
@project
.
add_pod_group
(
'SomeGroup'
)
%w{ m mm c cpp }
.
each
do
|
ext
|
%w{ m mm c cpp }
.
each
do
|
ext
|
path
=
Pathname
.
new
(
"path/to/file.
#{
ext
}
"
)
path
=
Pathname
.
new
(
"path/to/file.
#{
ext
}
"
)
file
=
group
.
add_source_file
(
path
)
file
=
@target
.
add_source_file
(
path
)
# ensure that it was added to all objects
@project
.
objects_hash
[
file
.
uuid
].
should
==
{
file
=
@project
.
objects
[
file
.
uuid
]
'name'
=>
path
.
basename
.
to_s
,
'isa'
=>
'PBXFileReference'
,
'sourceTree'
=>
'SOURCE_ROOT'
,
'path'
=>
path
.
to_s
}
file_ref_uuids
<<
file
.
uuid
build_file_uuid
,
_
=
find_object
({
phase
=
@target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXSourcesBuildPhase
)
}
'isa'
=>
'PBXBuildFile'
,
phase
.
files
.
map
{
|
buildFile
|
buildFile
.
file
}.
should
.
include
file
'fileRef'
=>
file
.
uuid
})
build_file_uuids
<<
build_file_uuid
group
.
childReferences
.
should
==
file_ref_uuids
phase
=
@target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXCopyFilesBuildPhase
)
}
phase
.
files
.
map
{
|
buildFile
|
buildFile
.
file
}.
should
.
not
.
include
file
_
,
object
=
find_object
(
'isa'
=>
'PBXSourcesBuildPhase'
)
object
[
'files'
].
should
==
build_file_uuids
_
,
object
=
find_object
(
'isa'
=>
'PBXHeadersBuildPhase'
)
object
[
'files'
].
should
.
not
.
include
build_file_uuid
end
end
end
end
...
@@ -286,7 +282,7 @@ describe "Pod::Xcode::Project" do
...
@@ -286,7 +282,7 @@ describe "Pod::Xcode::Project" do
build_file_uuids
=
[]
build_file_uuids
=
[]
%w{ m mm c cpp }
.
each
do
|
ext
|
%w{ m mm c cpp }
.
each
do
|
ext
|
path
=
Pathname
.
new
(
"path/to/file.
#{
ext
}
"
)
path
=
Pathname
.
new
(
"path/to/file.
#{
ext
}
"
)
file
=
@project
.
pods
.
add_source_file
(
path
,
nil
,
'-fno-obj-arc'
)
file
=
@project
.
targets
.
first
.
add_source_file
(
path
,
nil
,
'-fno-obj-arc'
)
find_object
({
find_object
({
'isa'
=>
'PBXBuildFile'
,
'isa'
=>
'PBXBuildFile'
,
'fileRef'
=>
file
.
uuid
,
'fileRef'
=>
file
.
uuid
,
...
@@ -296,37 +292,28 @@ describe "Pod::Xcode::Project" do
...
@@ -296,37 +292,28 @@ describe "Pod::Xcode::Project" do
end
end
it
"creates a copy build header phase which will copy headers to a specified path"
do
it
"creates a copy build header phase which will copy headers to a specified path"
do
phase
=
@project
.
add_copy_header_build_phase
(
"SomePod"
,
"Path/To/Source"
)
phase
=
@project
.
targets
.
first
.
copy_files_build_phases
.
new_pod_dir
(
"SomePod"
,
"Path/To/Source"
)
find_object
({
find_object
({
'isa'
=>
'PBXCopyFilesBuildPhase'
,
'isa'
=>
'PBXCopyFilesBuildPhase'
,
'dstPath'
=>
'$(PUBLIC_HEADERS_FOLDER_PATH)/Path/To/Source'
,
'dstPath'
=>
'$(PUBLIC_HEADERS_FOLDER_PATH)/Path/To/Source'
,
'name'
=>
'Copy SomePod Public Headers'
'name'
=>
'Copy SomePod Public Headers'
}).
should
.
not
==
nil
}).
should
.
not
==
nil
target
=
@project
.
targets
.
first
@project
.
targets
.
first
.
buildPhases
.
should
.
include
phase
target
.
attributes
[
'buildPhases'
].
should
.
include
phase
.
uuid
end
end
it
"adds a `h' file as a build file and adds it to the `headers build' phase list"
do
# TODO add test for the optional copy_header_phase
group
=
@project
.
groups
.
new
(
'name'
=>
'SomeGroup'
)
#it "adds a `h' file as a build file and adds it to the `headers build' phase list" do
it
"adds a `h' file as a build file and adds it to the `copy header files' build phase list"
do
path
=
Pathname
.
new
(
"path/to/file.h"
)
path
=
Pathname
.
new
(
"path/to/file.h"
)
file
=
group
.
add_source_file
(
path
)
file
=
@target
.
add_source_file
(
path
)
@project
.
objects_hash
[
file
.
uuid
].
should
==
{
# ensure that it was added to all objects
'name'
=>
path
.
basename
.
to_s
,
file
=
@project
.
objects
[
file
.
uuid
]
'isa'
=>
'PBXFileReference'
,
'sourceTree'
=>
'SOURCE_ROOT'
,
phase
=
@target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXSourcesBuildPhase
)
}
'path'
=>
path
.
to_s
phase
.
files
.
map
{
|
buildFile
|
buildFile
.
file
}.
should
.
not
.
include
file
}
build_file_uuid
,
_
=
find_object
({
phase
=
@target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXCopyFilesBuildPhase
)
}
'isa'
=>
'PBXBuildFile'
,
phase
.
files
.
map
{
|
buildFile
|
buildFile
.
file
}.
should
.
include
file
'fileRef'
=>
file
.
uuid
})
#_, object = find_object('isa' => 'PBXHeadersBuildPhase')
_
,
object
=
find_object
(
'isa'
=>
'PBXCopyFilesBuildPhase'
)
object
[
'files'
].
should
==
[
build_file_uuid
]
_
,
object
=
find_object
(
'isa'
=>
'PBXSourcesBuildPhase'
)
object
[
'files'
].
should
.
not
.
include
build_file_uuid
end
end
it
"saves the template with the adjusted project"
do
it
"saves the template with the adjusted project"
do
...
@@ -341,7 +328,7 @@ describe "Pod::Xcode::Project" do
...
@@ -341,7 +328,7 @@ describe "Pod::Xcode::Project" do
it
"returns all source files"
do
it
"returns all source files"
do
group
=
@project
.
groups
.
new
(
'name'
=>
'SomeGroup'
)
group
=
@project
.
groups
.
new
(
'name'
=>
'SomeGroup'
)
files
=
[
Pathname
.
new
(
'/some/file.h'
),
Pathname
.
new
(
'/some/file.m'
)]
files
=
[
Pathname
.
new
(
'/some/file.h'
),
Pathname
.
new
(
'/some/file.m'
)]
files
.
each
{
|
file
|
group
.
add_source_file
(
file
)
}
files
.
each
{
|
file
|
group
<<
@target
.
add_source_file
(
file
)
}
group
.
source_files
.
map
(
&
:pathname
).
sort
.
should
==
files
.
sort
group
.
source_files
.
map
(
&
:pathname
).
sort
.
should
==
files
.
sort
end
end
end
end
xcode-project-templates/cocoa-touch-static-library/Pods.xcodeproj/project.pbxproj
View file @
beb77b4a
...
@@ -6,41 +6,12 @@
...
@@ -6,41 +6,12 @@
objectVersion
=
46
;
objectVersion
=
46
;
objects
=
{
objects
=
{
/* Begin PBXBuildFile section */
515B0FB9141D52E0001DC3E6
/* Foundation.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
515B0FB8141D52E0001DC3E6
/* Foundation.framework */
;
};
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
82A8B61C142F7EC7006897C9
/* Copy Public Headers */
=
{
isa
=
PBXCopyFilesBuildPhase
;
buildActionMask
=
2147483647
;
dstPath
=
"$(PUBLIC_HEADERS_FOLDER_PATH)"
;
dstSubfolderSpec
=
16
;
files
=
(
);
name
=
"Copy Public Headers"
;
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
/* Begin PBXFileReference section */
515160D0141EC5D100EBB823
/* Pods.xcconfig */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.xcconfig
;
path
=
Pods.xcconfig
;
sourceTree
=
"<group>"
;
};
515160D0141EC5D100EBB823
/* Pods.xcconfig */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.xcconfig
;
path
=
Pods.xcconfig
;
sourceTree
=
"<group>"
;
};
515B0FB5141D52E0001DC3E6
/* libPods.a */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
archive.ar
;
includeInIndex
=
0
;
path
=
libPods.a
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
515B0FB8141D52E0001DC3E6
/* Foundation.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
Foundation.framework
;
path
=
System/Library/Frameworks/Foundation.framework
;
sourceTree
=
SDKROOT
;
};
515B0FB8141D52E0001DC3E6
/* Foundation.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
Foundation.framework
;
path
=
System/Library/Frameworks/Foundation.framework
;
sourceTree
=
SDKROOT
;
};
515B0FBC141D52E0001DC3E6
/* Pods-Prefix.pch */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"Pods-Prefix.pch"
;
sourceTree
=
SOURCE_ROOT
;
};
515B0FBC141D52E0001DC3E6
/* Pods-Prefix.pch */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"Pods-Prefix.pch"
;
sourceTree
=
SOURCE_ROOT
;
};
/* End PBXFileReference section */
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
515B0FB2141D52E0001DC3E6
/* Frameworks */
=
{
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
515B0FB9141D52E0001DC3E6
/* Foundation.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
/* Begin PBXGroup section */
515B0FAA141D52E0001DC3E6
=
{
515B0FAA141D52E0001DC3E6
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
...
@@ -55,7 +26,6 @@
...
@@ -55,7 +26,6 @@
515B0FB6141D52E0001DC3E6
/* Products */
=
{
515B0FB6141D52E0001DC3E6
/* Products */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
515B0FB5141D52E0001DC3E6
/* libPods.a */
,
);
);
name
=
Products
;
name
=
Products
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -87,40 +57,12 @@
...
@@ -87,40 +57,12 @@
};
};
/* End PBXGroup section */
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
515B0FB3141D52E0001DC3E6
/* Headers */
=
{
isa
=
PBXHeadersBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
515B0FB4141D52E0001DC3E6
/* Pods */
=
{
isa
=
PBXNativeTarget
;
buildConfigurationList
=
515B0FC2141D52E0001DC3E6
/* Build configuration list for PBXNativeTarget "Pods" */
;
buildPhases
=
(
515B0FB1141D52E0001DC3E6
/* Sources */
,
515B0FB2141D52E0001DC3E6
/* Frameworks */
,
515B0FB3141D52E0001DC3E6
/* Headers */
,
82A8B61C142F7EC7006897C9
/* Copy Public Headers */
,
);
buildRules
=
(
);
dependencies
=
(
);
name
=
Pods
;
productName
=
Pods
;
productReference
=
515B0FB5141D52E0001DC3E6
/* libPods.a */
;
productType
=
"com.apple.product-type.library.static"
;
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
/* Begin PBXProject section */
515B0FAC141D52E0001DC3E6
/* Project object */
=
{
515B0FAC141D52E0001DC3E6
/* Project object */
=
{
isa
=
PBXProject
;
isa
=
PBXProject
;
attributes
=
{
LastUpgradeCheck
=
0420
;
};
buildConfigurationList
=
515B0FAF141D52E0001DC3E6
/* Build configuration list for PBXProject "Pods" */
;
buildConfigurationList
=
515B0FAF141D52E0001DC3E6
/* Build configuration list for PBXProject "Pods" */
;
compatibilityVersion
=
"Xcode 3.2"
;
compatibilityVersion
=
"Xcode 3.2"
;
developmentRegion
=
English
;
developmentRegion
=
English
;
...
@@ -133,21 +75,10 @@
...
@@ -133,21 +75,10 @@
projectDirPath
=
""
;
projectDirPath
=
""
;
projectRoot
=
""
;
projectRoot
=
""
;
targets
=
(
targets
=
(
515B0FB4141D52E0001DC3E6
/* Pods */
,
);
);
};
};
/* End PBXProject section */
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
515B0FB1141D52E0001DC3E6
/* Sources */
=
{
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
/* Begin XCBuildConfiguration section */
515B0FC0141D52E0001DC3E6
/* Debug */
=
{
515B0FC0141D52E0001DC3E6
/* Debug */
=
{
isa
=
XCBuildConfiguration
;
isa
=
XCBuildConfiguration
;
...
@@ -193,34 +124,6 @@
...
@@ -193,34 +124,6 @@
};
};
name
=
Release
;
name
=
Release
;
};
};
515B0FC3141D52E0001DC3E6
/* Debug */
=
{
isa
=
XCBuildConfiguration
;
baseConfigurationReference
=
515160D0141EC5D100EBB823
/* Pods.xcconfig */
;
buildSettings
=
{
DSTROOT
=
/tmp/Pods.dst
;
GCC_PRECOMPILE_PREFIX_HEADER
=
YES
;
GCC_PREFIX_HEADER
=
"Pods-Prefix.pch"
;
GCC_VERSION
=
com.apple.compilers.llvm.clang.1_0
;
OTHER_LDFLAGS
=
"-ObjC"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SKIP_INSTALL
=
YES
;
};
name
=
Debug
;
};
515B0FC4141D52E0001DC3E6
/* Release */
=
{
isa
=
XCBuildConfiguration
;
baseConfigurationReference
=
515160D0141EC5D100EBB823
/* Pods.xcconfig */
;
buildSettings
=
{
DSTROOT
=
/tmp/Pods.dst
;
GCC_PRECOMPILE_PREFIX_HEADER
=
YES
;
GCC_PREFIX_HEADER
=
"Pods-Prefix.pch"
;
GCC_VERSION
=
com.apple.compilers.llvm.clang.1_0
;
OTHER_LDFLAGS
=
"-ObjC"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SKIP_INSTALL
=
YES
;
};
name
=
Release
;
};
/* End XCBuildConfiguration section */
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
/* Begin XCConfigurationList section */
...
@@ -233,15 +136,6 @@
...
@@ -233,15 +136,6 @@
defaultConfigurationIsVisible
=
0
;
defaultConfigurationIsVisible
=
0
;
defaultConfigurationName
=
Release
;
defaultConfigurationName
=
Release
;
};
};
515B0FC2141D52E0001DC3E6
/* Build configuration list for PBXNativeTarget "Pods" */
=
{
isa
=
XCConfigurationList
;
buildConfigurations
=
(
515B0FC3141D52E0001DC3E6
/* Debug */
,
515B0FC4141D52E0001DC3E6
/* Release */
,
);
defaultConfigurationIsVisible
=
0
;
defaultConfigurationName
=
Release
;
};
/* End XCConfigurationList section */
/* End XCConfigurationList section */
};
};
rootObject
=
515B0FAC141D52E0001DC3E6
/* Project object */
;
rootObject
=
515B0FAC141D52E0001DC3E6
/* Project object */
;
...
...
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