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
41391400
Commit
41391400
authored
Oct 22, 2011
by
Nolan Waite
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load/save xcworkspace
parent
384ac16a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
workspace.rb
lib/cocoapods/xcode/workspace.rb
+22
-0
workspace_spec.rb
spec/unit/xcode/workspace_spec.rb
+10
-2
No files found.
lib/cocoapods/xcode/workspace.rb
View file @
41391400
framework
'Foundation'
require
'fileutils'
module
Pod
module
Xcode
...
...
@@ -7,6 +8,20 @@ module Pod
@projpaths
=
projpaths
end
def
self
.
from_xcworkspace
(
path
)
from_s
(
File
.
read
(
File
.
join
(
path
,
'contents.xcworkspacedata'
)))
end
def
self
.
from_s
(
xml
)
doc
=
NSXMLDocument
.
alloc
.
initWithXMLString
(
xml
,
options
:
0
,
error
:nil
)
projpaths
=
doc
.
nodesForXPath
(
"/Workspace/FileRef"
,
error
:nil
).
map
do
|
node
|
node
.
attributeWithName
(
"location"
).
stringValue
.
sub
(
/^group:/
,
''
)
end
new
(
projpaths
)
end
attr_reader
:projpaths
def
<<
(
projpath
)
@projpaths
<<
projpath
end
...
...
@@ -21,6 +36,13 @@ module Pod
end
NSString
.
alloc
.
initWithData
(
doc
.
XMLData
,
encoding
:NSUTF8StringEncoding
)
end
def
save_as
(
path
)
FileUtils
.
mkdir_p
(
path
)
File
.
open
(
File
.
join
(
path
,
'contents.xcworkspacedata'
),
'w'
)
do
|
out
|
out
<<
to_s
end
end
end
end
end
spec/unit/xcode/workspace_spec.rb
View file @
41391400
...
...
@@ -3,14 +3,22 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe
"Pod::Xcode::Workspace"
do
before
do
@workspace
=
Pod
::
Xcode
::
Workspace
.
new
(
'Pods/Pods.xcodeproj'
,
'App.xcodeproj'
)
end
it
"accepts new projects"
do
@workspace
<<
'Framework.xcodeproj'
@workspace
.
projpaths
.
should
.
include
'Framework.xcodeproj'
end
before
do
@doc
=
NSXMLDocument
.
alloc
.
initWithXMLString
(
@workspace
.
to_s
,
options
:
0
,
error
:nil
)
end
it
"is the right workspace version"
do
it
"is the right
xml
workspace version"
do
@doc
.
rootElement
.
attributeForName
(
"version"
).
stringValue
.
should
==
"1.0"
end
it
"
contains the projects
"
do
it
"
refers to the projects in xml
"
do
@doc
.
nodesForXPath
(
"/Workspace/FileRef"
,
error
:nil
).
map
do
|
node
|
node
.
attributeForName
(
"location"
).
stringValue
.
sub
(
/^group:/
,
''
)
end
.
sort
.
should
==
[
'App.xcodeproj'
,
'Pods/Pods.xcodeproj'
]
...
...
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