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
35db5a85
Commit
35db5a85
authored
Oct 30, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor by using more of the new project API.
parent
38a8e724
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
52 deletions
+51
-52
installer.rb
lib/cocoapods/installer.rb
+3
-3
project.rb
lib/cocoapods/xcode/project.rb
+36
-34
integration_spec.rb
spec/integration_spec.rb
+11
-14
project_spec.rb
spec/unit/xcode/project_spec.rb
+1
-1
No files found.
lib/cocoapods/installer.rb
View file @
35db5a85
...
@@ -118,8 +118,8 @@ module Pod
...
@@ -118,8 +118,8 @@ module Pod
'lastKnownFileType'
=>
'text.xcconfig'
'lastKnownFileType'
=>
'text.xcconfig'
})
})
app_project
.
targets
.
each
do
|
target
|
app_project
.
targets
.
each
do
|
target
|
target
.
buildConfiguration
List
.
buildConfiguration
s
.
each
do
|
config
|
target
.
buildConfigurations
.
each
do
|
config
|
config
.
baseConfiguration
Reference
=
configfile
config
.
baseConfiguration
=
configfile
end
end
end
end
app_project
.
main_group
<<
configfile
app_project
.
main_group
<<
configfile
...
@@ -131,7 +131,7 @@ module Pod
...
@@ -131,7 +131,7 @@ module Pod
'sourceTree'
=>
'BUILT_PRODUCTS_DIR'
'sourceTree'
=>
'BUILT_PRODUCTS_DIR'
})
})
app_project
.
objects
.
select_by_class
(
Xcode
::
Project
::
PBXFrameworksBuildPhase
).
each
do
|
build_phase
|
app_project
.
objects
.
select_by_class
(
Xcode
::
Project
::
PBXFrameworksBuildPhase
).
each
do
|
build_phase
|
build_phase
.
files
<<
libfile
.
build
_f
ile
build_phase
.
files
<<
libfile
.
build
F
ile
end
end
app_project
.
main_group
<<
libfile
app_project
.
main_group
<<
libfile
...
...
lib/cocoapods/xcode/project.rb
View file @
35db5a85
...
@@ -30,7 +30,7 @@ module Pod
...
@@ -30,7 +30,7 @@ module Pod
end
end
end
end
def
self
.
has_one
(
singular_attr_name
,
options
=
{})
def
self
.
belongs_to
(
singular_attr_name
,
options
=
{})
uuid_name
=
options
[
:uuid
]
||
"
#{
singular_attr_name
}
Reference"
uuid_name
=
options
[
:uuid
]
||
"
#{
singular_attr_name
}
Reference"
attribute
(
options
[
:uuid
]
||
singular_attr_name
,
uuid_name
)
attribute
(
options
[
:uuid
]
||
singular_attr_name
,
uuid_name
)
define_method
(
singular_attr_name
)
do
define_method
(
singular_attr_name
)
do
...
@@ -42,6 +42,16 @@ module Pod
...
@@ -42,6 +42,16 @@ module Pod
end
end
end
end
def
self
.
has_one
(
singular_attr_name
,
options
=
{})
klass
=
options
[
:class
]
uuid_name
=
options
[
:uuid
]
||
"
#{
singular_attr_name
}
Reference"
define_method
(
singular_attr_name
)
do
@project
.
objects
.
select_by_class
(
klass
).
find
do
|
object
|
object
.
respond_to?
(
uuid_name
)
&&
object
.
send
(
uuid_name
)
==
self
.
uuid
end
end
end
def
self
.
isa
def
self
.
isa
@isa
||=
name
.
split
(
'::'
).
last
@isa
||=
name
.
split
(
'::'
).
last
end
end
...
@@ -80,8 +90,22 @@ module Pod
...
@@ -80,8 +90,22 @@ module Pod
end
end
end
end
# Missing constants that begin with either `PBX' or `XC' are assumed to be
# valid classes in a Xcode project. A new PBXObject subclass is created
# for the constant and returned.
def
self
.
const_missing
(
name
)
if
name
=~
/^(PBX|XC)/
klass
=
Class
.
new
(
PBXObject
)
const_set
(
name
,
klass
)
klass
else
super
end
end
class
PBXFileReference
<
PBXObject
class
PBXFileReference
<
PBXObject
attributes
:path
,
:sourceTree
,
:explicitFileType
,
:includeInIndex
attributes
:path
,
:sourceTree
,
:explicitFileType
,
:includeInIndex
has_one
:buildFile
,
:uuid
=>
:fileRef
,
:class
=>
Project
::
PBXBuildFile
def
initialize
(
project
,
uuid
,
attributes
)
def
initialize
(
project
,
uuid
,
attributes
)
is_new
=
uuid
.
nil?
is_new
=
uuid
.
nil?
...
@@ -103,10 +127,6 @@ module Pod
...
@@ -103,10 +127,6 @@ module Pod
def
pathname
def
pathname
Pathname
.
new
(
path
)
Pathname
.
new
(
path
)
end
end
def
build_file
@project
.
build_files
.
find
{
|
o
|
o
.
fileRef
==
uuid
}
end
end
end
class
PBXGroup
<
PBXObject
class
PBXGroup
<
PBXObject
...
@@ -124,7 +144,7 @@ module Pod
...
@@ -124,7 +144,7 @@ module Pod
end
end
def
source_files
def
source_files
list_by_class
(
childReferences
,
PBXFileReference
,
files
.
select
{
|
file
|
!
file
.
build_file
.
nil?
}
)
list_by_class
(
childReferences
,
PBXFileReference
,
files
.
select
(
&
:buildFile
)
)
end
end
def
groups
def
groups
...
@@ -133,7 +153,7 @@ module Pod
...
@@ -133,7 +153,7 @@ module Pod
def
add_source_file
(
path
,
copy_header_phase
=
nil
,
compiler_flags
=
nil
)
def
add_source_file
(
path
,
copy_header_phase
=
nil
,
compiler_flags
=
nil
)
file
=
files
.
new
(
'path'
=>
path
.
to_s
)
file
=
files
.
new
(
'path'
=>
path
.
to_s
)
build_file
=
file
.
build
_f
ile
build_file
=
file
.
build
F
ile
if
path
.
extname
==
'.h'
if
path
.
extname
==
'.h'
build_file
.
settings
=
{
'ATTRIBUTES'
=>
[
"Public"
]
}
build_file
.
settings
=
{
'ATTRIBUTES'
=>
[
"Public"
]
}
# Working around a bug in Xcode 4.2 betas, remove this once the Xcode bug is fixed:
# Working around a bug in Xcode 4.2 betas, remove this once the Xcode bug is fixed:
...
@@ -154,17 +174,8 @@ module Pod
...
@@ -154,17 +174,8 @@ module Pod
end
end
class
PBXBuildFile
<
PBXObject
class
PBXBuildFile
<
PBXObject
attributes
:fileRef
,
:settings
attributes
:settings
belongs_to
:file
,
:uuid
=>
:fileRef
# Takes a PBXFileReference instance and assigns its uuid to the fileRef attribute.
def
file
=
(
file
)
self
.
fileRef
=
file
.
uuid
end
# Returns a PBXFileReference instance corresponding to the uuid in the fileRef attribute.
def
file
@project
.
objects
[
fileRef
]
end
end
end
class
PBXBuildPhase
<
PBXObject
class
PBXBuildPhase
<
PBXObject
...
@@ -204,8 +215,8 @@ module Pod
...
@@ -204,8 +215,8 @@ module Pod
has_many
:buildPhases
,
:class
=>
PBXBuildPhase
has_many
:buildPhases
,
:class
=>
PBXBuildPhase
has_many
:dependencies
,
:singular
=>
:dependency
# TODO :class => ?
has_many
:dependencies
,
:singular
=>
:dependency
# TODO :class => ?
has_many
:buildRules
# TODO :class => ?
has_many
:buildRules
# TODO :class => ?
has_one
:buildConfigurationList
belongs_to
:buildConfigurationList
has_one
:product
,
:uuid
=>
:productReference
belongs_to
:product
,
:uuid
=>
:productReference
def
initialize
(
project
,
*
)
def
initialize
(
project
,
*
)
super
super
...
@@ -230,11 +241,15 @@ module Pod
...
@@ -230,11 +241,15 @@ module Pod
end
end
end
end
end
end
def
buildConfigurations
buildConfigurationList
.
buildConfigurations
end
end
end
class
XCBuildConfiguration
<
PBXObject
class
XCBuildConfiguration
<
PBXObject
attribute
:buildSettings
attribute
:buildSettings
has_one
:baseConfiguration
belongs_to
:baseConfiguration
def
initialize
(
*
)
def
initialize
(
*
)
super
super
...
@@ -259,19 +274,6 @@ module Pod
...
@@ -259,19 +274,6 @@ module Pod
end
end
end
end
# Missing constants that begin with either `PBX' or `XC' are assumed to be
# valid classes in a Xcode project. A new PBXObject subclass is created
# for the constant and returned.
def
self
.
const_missing
(
name
)
if
name
=~
/^(PBX|XC)/
klass
=
Class
.
new
(
PBXObject
)
const_set
(
name
,
klass
)
klass
else
super
end
end
class
PBXObjectList
class
PBXObjectList
include
Enumerable
include
Enumerable
...
...
spec/integration_spec.rb
View file @
35db5a85
...
@@ -180,25 +180,22 @@ else
...
@@ -180,25 +180,22 @@ else
installer
=
SpecHelper
::
Installer
.
new
(
spec
)
installer
=
SpecHelper
::
Installer
.
new
(
spec
)
installer
.
install!
installer
.
install!
installer
.
configure_project
(
projpath
)
installer
.
configure_project
(
projpath
)
xcworkspace
=
temporary_directory
+
'ASIHTTPRequest.xcworkspace'
xcworkspace
=
temporary_directory
+
'ASIHTTPRequest.xcworkspace'
workspace
=
Pod
::
Xcode
::
Workspace
.
new_from_xcworkspace
(
xcworkspace
)
workspace
=
Pod
::
Xcode
::
Workspace
.
new_from_xcworkspace
(
xcworkspace
)
workspace
.
projpaths
.
sort
.
should
==
[
'ASIHTTPRequest.xcodeproj'
,
'Pods/Pods.xcodeproj'
]
workspace
.
projpaths
.
sort
.
should
==
[
'ASIHTTPRequest.xcodeproj'
,
'Pods/Pods.xcodeproj'
]
project
=
Pod
::
Xcode
::
Project
.
new
(
projpath
)
project
=
Pod
::
Xcode
::
Project
.
new
(
projpath
)
config
=
project
.
files
.
find
{
|
f
|
f
.
path
=~
/Pods.xcconfig$/
}
libPods
=
project
.
files
.
find
{
|
f
|
f
.
name
==
'libPods.a'
}
config
.
should
.
not
.
equal
nil
copy_resources
=
project
.
objects
.
select_by_class
(
Pod
::
Xcode
::
Project
::
PBXShellScriptBuildPhase
).
find
do
|
ss
|
ss
.
shellScript
[
'PodsResources.sh'
]
end
copy_resources
.
should
.
not
.
equal
nil
project
.
targets
.
each
do
|
target
|
project
.
targets
.
each
do
|
target
|
bases
=
target
.
buildConfigurationList
.
buildConfigurations
.
map
(
&
:baseConfigurationReference
)
target
.
buildConfigurations
.
each
do
|
config
|
bases
.
uniq
[
0
].
uuid
.
should
==
config
.
uuid
config
.
baseConfiguration
.
path
.
should
==
'Pods/Pods.xcconfig'
target
.
buildPhases
.
map
(
&
:uuid
).
should
.
include
copy_resources
.
uui
d
en
d
end
lib
=
project
.
files
.
find
{
|
f
|
f
.
path
=~
/libPods.a$/
}
link
=
target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXFrameworksBuildPhase
)
}
lib
.
should
.
not
.
equal
nil
link
.
files
.
map
(
&
:uuid
).
should
.
include
libPods
.
buildFile
.
uuid
project
.
objects
.
select_by_class
(
Pod
::
Xcode
::
Project
::
PBXFrameworksBuildPhase
).
each
do
|
build_phase
|
build_phase
.
files
.
map
(
&
:uuid
).
should
.
include
lib
.
build_file
.
uuid
target
.
buildPhases
.
to_a
.
last
.
shellScript
.
should
==
"${SRCROOT}/Pods/PodsResources.sh
\n
"
end
end
end
end
...
...
spec/unit/xcode/project_spec.rb
View file @
35db5a85
...
@@ -232,7 +232,7 @@ describe "Pod::Xcode::Project" do
...
@@ -232,7 +232,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
.
build
_f
ile
build_file
=
file
.
build
F
ile
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'
...
...
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