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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
169 deletions
+55
-169
installer.rb
lib/cocoapods/installer.rb
+6
-1
project.rb
lib/cocoapods/xcode/project.rb
+0
-0
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
end
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
# 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
This diff is collapsed.
Click to expand it.
spec/unit/xcode/project_spec.rb
View file @
beb77b4a
...
...
@@ -23,6 +23,10 @@ describe "Pod::Xcode::Project" do
@project
.
to_hash
.
should
==
NSDictionary
.
dictionaryWithContentsOfFile
(
template_file
)
end
before
do
@target
=
@project
.
targets
.
new_static_library
(
'Pods'
)
end
it
"returns the objects hash"
do
@project
.
objects_hash
.
should
==
@project
.
to_hash
[
'objects'
]
end
...
...
@@ -50,6 +54,22 @@ describe "Pod::Xcode::Project" do
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
before
do
@phase
=
@project
.
objects
.
add
(
Pod
::
Xcode
::
Project
::
PBXBuildPhase
)
...
...
@@ -132,15 +152,8 @@ describe "Pod::Xcode::Project" do
end
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
@target
.
name
.
should
==
"Pods"
@target
.
productName
.
should
==
"Pods"
end
...
...
@@ -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
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
.
fileRef
.
should
==
file
.
uuid
build_file
.
isa
.
should
==
'PBXBuildFile'
...
...
@@ -250,35 +263,18 @@ describe "Pod::Xcode::Project" do
}).
should
.
not
==
nil
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
file_ref_uuids
,
build_file_uuids
=
[],
[]
group
=
@project
.
add_pod_group
(
'SomeGroup'
)
it
"adds an `m' or `c' file to the `sources build' phase list"
do
%w{ m mm c cpp }
.
each
do
|
ext
|
path
=
Pathname
.
new
(
"path/to/file.
#{
ext
}
"
)
file
=
group
.
add_source_file
(
path
)
@project
.
objects_hash
[
file
.
uuid
].
should
==
{
'name'
=>
path
.
basename
.
to_s
,
'isa'
=>
'PBXFileReference'
,
'sourceTree'
=>
'SOURCE_ROOT'
,
'path'
=>
path
.
to_s
}
file_ref_uuids
<<
file
.
uuid
file
=
@target
.
add_source_file
(
path
)
# ensure that it was added to all objects
file
=
@project
.
objects
[
file
.
uuid
]
build_file_uuid
,
_
=
find_object
({
'isa'
=>
'PBXBuildFile'
,
'fileRef'
=>
file
.
uuid
})
build_file_uuids
<<
build_file_uuid
phase
=
@target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXSourcesBuildPhase
)
}
phase
.
files
.
map
{
|
buildFile
|
buildFile
.
file
}.
should
.
include
file
group
.
childReferences
.
should
==
file_ref_uuids
_
,
object
=
find_object
(
'isa'
=>
'PBXSourcesBuildPhase'
)
object
[
'files'
].
should
==
build_file_uuids
_
,
object
=
find_object
(
'isa'
=>
'PBXHeadersBuildPhase'
)
object
[
'files'
].
should
.
not
.
include
build_file_uuid
phase
=
@target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXCopyFilesBuildPhase
)
}
phase
.
files
.
map
{
|
buildFile
|
buildFile
.
file
}.
should
.
not
.
include
file
end
end
...
...
@@ -286,7 +282,7 @@ describe "Pod::Xcode::Project" do
build_file_uuids
=
[]
%w{ m mm c cpp }
.
each
do
|
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
({
'isa'
=>
'PBXBuildFile'
,
'fileRef'
=>
file
.
uuid
,
...
...
@@ -296,37 +292,28 @@ describe "Pod::Xcode::Project" do
end
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
({
'isa'
=>
'PBXCopyFilesBuildPhase'
,
'dstPath'
=>
'$(PUBLIC_HEADERS_FOLDER_PATH)/Path/To/Source'
,
'name'
=>
'Copy SomePod Public Headers'
}).
should
.
not
==
nil
target
=
@project
.
targets
.
first
target
.
attributes
[
'buildPhases'
].
should
.
include
phase
.
uuid
@project
.
targets
.
first
.
buildPhases
.
should
.
include
phase
end
it
"adds a `h' file as a build file and adds it to the `headers build' phase list"
do
group
=
@project
.
groups
.
new
(
'name'
=>
'SomeGroup'
)
# TODO add test for the optional copy_header_phase
#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"
)
file
=
group
.
add_source_file
(
path
)
@project
.
objects_hash
[
file
.
uuid
].
should
==
{
'name'
=>
path
.
basename
.
to_s
,
'isa'
=>
'PBXFileReference'
,
'sourceTree'
=>
'SOURCE_ROOT'
,
'path'
=>
path
.
to_s
}
build_file_uuid
,
_
=
find_object
({
'isa'
=>
'PBXBuildFile'
,
'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
file
=
@target
.
add_source_file
(
path
)
# ensure that it was added to all objects
file
=
@project
.
objects
[
file
.
uuid
]
phase
=
@target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXSourcesBuildPhase
)
}
phase
.
files
.
map
{
|
buildFile
|
buildFile
.
file
}.
should
.
not
.
include
file
phase
=
@target
.
buildPhases
.
find
{
|
phase
|
phase
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXCopyFilesBuildPhase
)
}
phase
.
files
.
map
{
|
buildFile
|
buildFile
.
file
}.
should
.
include
file
end
it
"saves the template with the adjusted project"
do
...
...
@@ -341,7 +328,7 @@ describe "Pod::Xcode::Project" do
it
"returns all source files"
do
group
=
@project
.
groups
.
new
(
'name'
=>
'SomeGroup'
)
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
end
end
xcode-project-templates/cocoa-touch-static-library/Pods.xcodeproj/project.pbxproj
View file @
beb77b4a
...
...
@@ -6,41 +6,12 @@
objectVersion
=
46
;
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 */
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
;
};
515B0FBC141D52E0001DC3E6
/* Pods-Prefix.pch */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"Pods-Prefix.pch"
;
sourceTree
=
SOURCE_ROOT
;
};
/* 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 */
515B0FAA141D52E0001DC3E6
=
{
isa
=
PBXGroup
;
...
...
@@ -55,7 +26,6 @@
515B0FB6141D52E0001DC3E6
/* Products */
=
{
isa
=
PBXGroup
;
children
=
(
515B0FB5141D52E0001DC3E6
/* libPods.a */
,
);
name
=
Products
;
sourceTree
=
"<group>"
;
...
...
@@ -87,40 +57,12 @@
};
/* 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 */
515B0FAC141D52E0001DC3E6
/* Project object */
=
{
isa
=
PBXProject
;
attributes
=
{
LastUpgradeCheck
=
0420
;
};
buildConfigurationList
=
515B0FAF141D52E0001DC3E6
/* Build configuration list for PBXProject "Pods" */
;
compatibilityVersion
=
"Xcode 3.2"
;
developmentRegion
=
English
;
...
...
@@ -133,21 +75,10 @@
projectDirPath
=
""
;
projectRoot
=
""
;
targets
=
(
515B0FB4141D52E0001DC3E6
/* Pods */
,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
515B0FB1141D52E0001DC3E6
/* Sources */
=
{
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
515B0FC0141D52E0001DC3E6
/* Debug */
=
{
isa
=
XCBuildConfiguration
;
...
...
@@ -193,34 +124,6 @@
};
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 */
/* Begin XCConfigurationList section */
...
...
@@ -233,15 +136,6 @@
defaultConfigurationIsVisible
=
0
;
defaultConfigurationName
=
Release
;
};
515B0FC2141D52E0001DC3E6
/* Build configuration list for PBXNativeTarget "Pods" */
=
{
isa
=
XCConfigurationList
;
buildConfigurations
=
(
515B0FC3141D52E0001DC3E6
/* Debug */
,
515B0FC4141D52E0001DC3E6
/* Release */
,
);
defaultConfigurationIsVisible
=
0
;
defaultConfigurationName
=
Release
;
};
/* End XCConfigurationList section */
};
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