Commit 14cb718f authored by Eloy Duran's avatar Eloy Duran

Actually create a new PBXNativeTarget instance and set the defaults.

parent 183f2551
...@@ -86,13 +86,20 @@ module Pod ...@@ -86,13 +86,20 @@ module Pod
def initialize(project, uuid, attributes) def initialize(project, uuid, attributes)
is_new = uuid.nil? is_new = uuid.nil?
super super
self.name ||= pathname.basename.to_s self.path = path if path # sets default name
self.sourceTree ||= 'SOURCE_ROOT' self.sourceTree ||= 'SOURCE_ROOT'
if is_new if is_new
@project.build_files.new.file = self @project.build_files.new.file = self
end end
end end
alias_method :_path=, :path=
def path=(path)
self._path = path
self.name ||= pathname.basename.to_s
path
end
def pathname def pathname
Pathname.new(path) Pathname.new(path)
end end
...@@ -190,6 +197,8 @@ module Pod ...@@ -190,6 +197,8 @@ module Pod
end end
class PBXNativeTarget < PBXObject class PBXNativeTarget < PBXObject
STATIC_LIBRARY = 'com.apple.product-type.library.static'
attributes :productName, :productType attributes :productName, :productType
has_many :buildPhases, :class => PBXBuildPhase has_many :buildPhases, :class => PBXBuildPhase
...@@ -198,12 +207,28 @@ module Pod ...@@ -198,12 +207,28 @@ module Pod
has_one :buildConfigurationList has_one :buildConfigurationList
has_one :product, :uuid => :productReference has_one :product, :uuid => :productReference
def initialize(project, uuid, attributes) def initialize(project, *)
super super
self.buildPhaseReferences ||= [] self.buildPhaseReferences ||= []
# TODO self.buildConfigurationList ||= new list?
self.buildRuleReferences ||= [] self.buildRuleReferences ||= []
self.dependencyReferences ||= [] self.dependencyReferences ||= []
unless buildConfigurationList
self.buildConfigurationList = project.objects.add(XCConfigurationList)
# TODO or should this happen in buildConfigurationList?
buildConfigurationList.buildConfigurations.new('name' => 'Debug')
buildConfigurationList.buildConfigurations.new('name' => 'Release')
end
unless product
self.product = project.objects.add(PBXFileReference, 'sourceTree' => 'BUILT_PRODUCTS_DIR')
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
end end
......
...@@ -133,10 +133,13 @@ describe "Pod::Xcode::Project" do ...@@ -133,10 +133,13 @@ describe "Pod::Xcode::Project" do
describe "a new PBXNativeTarget" do describe "a new PBXNativeTarget" do
before do before do
@target = @project.targets.first @target = @project.targets.new({
'productName' => 'Pods',
'productType' => Pod::Xcode::Project::PBXNativeTarget::STATIC_LIBRARY
})
end end
it "returns the product name, which is the name of the binary" do it "returns the product name, which is the name of the binary (minus prefix/suffix)" do
@target.productName.should == "Pods" @target.productName.should == "Pods"
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment