lib/ib/project.rb in ib-0.2.1 vs lib/ib/project.rb in ib-0.2.2
- old
+ new
@@ -1,46 +1,44 @@
class IB::Project
def write app_path = "app", resources_path = "resources", pods_headers_path = "vendor/Pods/Headers"
project = Xcodeproj::Project.new
- target = project.targets.new_static_library(:ios, 'ui')
+ target = project.new_target(:static_library, 'ib', :ios)
- resources = project.groups.new('path' => resources_path, 'name' => 'Resources')
- support = project.groups.new('name' => 'Supporting Files', 'path' => 'ib.xcodeproj')
- pods = project.groups.new('name' => 'Pods')
+ resources = project.new_group("Resources")
+ resources.path = resources_path
- IB::Generator.new.write(app_path, "ib.xcodeproj")
- support.files.new 'path' => 'Stubs.h', 'sourceTree' => '<group>'
+ support = project.new_group("Supporting Files")
+ support.path = "ib.xcodeproj"
- path = Pathname.new("Stubs.m")
- desc = Xcodeproj::Project::PBXNativeTarget::SourceFileDescription.new(path, nil, nil)
- file = target.add_source_files([desc]).first
- file.source_tree = '<group>'
- support.files << file
+ pods = project.new_group("Pods")
+ pods.path = pods_headers_path
+ IB::Generator.new.write(Motion::Project::App.config.files, "ib.xcodeproj")
+
+ support.new_file "ib.xcodeproj/Stubs.h"
+ file = support.new_file "ib.xcodeproj/Stubs.m"
+ target.add_file_references([ file ])
+
resource_exts = %W{xcdatamodeld png jpg jpeg storyboard xib lproj}
Dir.glob("#{resources_path}/**/*.{#{resource_exts.join(",")}}") do |file|
- file = file.gsub(/^#{resources_path}\//, '')
if file.end_with? ".xcdatamodeld"
- obj = resources.groups.new('isa' => 'XCVersionGroup', 'path' => file, 'sourceTree' => '<group>', 'versionGroupType' => 'wrapper.xcdatamodel')
- file = obj.files.new('path' => file.gsub(/xcdatamodeld$/, 'xcdatamodel'), 'sourceTree' => '<group>', 'lastKnownFileType' => 'wrapper.xcdatamodel')
- obj.attributes['currentVersion'] = file.uuid
+ relative_file_path = file.split("/").last
+ obj = resources.new_xcdatamodel_group(relative_file_path)
+ internal_file = obj.files.first
+ internal_file.path = relative_file_path.gsub(/xcdatamodeld$/, 'xcdatamodel')
+ internal_file.source_tree = "<group>"
+ resources.children << obj
else
- resources.files.new('path' => file, 'sourceTree' => '<group>')
+ resources.new_file(file)
end
end
Dir.glob("#{pods_headers_path}/**/*.h") do |file|
- pods.files.new('path' => file)
+ pods.new_file(file)
end
- # Add Basic System Frameworks
- # frameworks = ["UIKit", "QuartzCore", "CoreGraphics", "CoreData"]
- # doesn't work with UIKit
-
- frameworks = ["QuartzCore", "CoreGraphics", "CoreData"]
- frameworks.each do |framework|
- file = project.add_system_framework framework
- target.frameworks_build_phases.first << file
+ %W{QuartzCore CoreGraphics CoreData}.each do |framework|
+ project.add_system_framework framework
end
project.save_as("ib.xcodeproj")
end
end
\ No newline at end of file