lib/cocoapods-rome/post_install.rb in cocoapods-rome-0.0.4 vs lib/cocoapods-rome/post_install.rb in cocoapods-rome-0.1.0
- old
+ new
@@ -1,5 +1,9 @@
+def xcodebuild(sandbox, target, sdk='macosx')
+ Pod::Executable.execute_command 'xcodebuild', %W(-project #{sandbox.project_path.basename} -scheme #{target} -configuration Release -sdk #{sdk}), true
+end
+
Pod::HooksManager.register('cocoapods-rome', :post_install) do |installer_context|
sandbox_root = Pathname(installer_context.sandbox_root)
sandbox = Pod::Sandbox.new(sandbox_root)
build_dir = sandbox_root.parent + 'build'
@@ -7,26 +11,39 @@
Pod::UI.puts 'Building frameworks'
build_dir.rmtree if build_dir.directory?
Dir.chdir(sandbox.project_path.dirname) do
- targets = installer_context.umbrella_targets.select { |t| t.specs.any? }.map(&:cocoapods_target_label)
+ targets = installer_context.umbrella_targets.select { |t| t.specs.any? }
targets.each do |target|
- Pod::Executable.execute_command 'xcodebuild', %W(-project #{sandbox.project_path.basename} -scheme #{target} -configuration Release), true
+ if target.platform_name == :ios
+ xcodebuild(sandbox, target.cocoapods_target_label, 'iphoneos')
+ xcodebuild(sandbox, target.cocoapods_target_label, 'iphonesimulator')
+
+ target.specs.each do |spec|
+ device_lib = "#{build_dir}/Release-iphoneos/#{spec.name}.framework/#{spec.name}"
+ simulator_lib = "#{build_dir}/Release-iphonesimulator/#{spec.name}.framework/#{spec.name}"
+ `lipo -create -output "#{build_dir}/#{spec.name}" #{device_lib} #{simulator_lib}`
+
+ FileUtils.mv "#{build_dir}/#{spec.name}", device_lib
+ Pathname.new("#{build_dir}/Release-iphonesimulator/#{spec.name}.framework").rmtree
+ end
+ else
+ xcodebuild(sandbox, target.cocoapods_target_label)
+ end
end
end
raise Pod::Informative, 'The build directory was not found in the expected location.' unless build_dir.directory?
- frameworks = Pathname.glob(build_dir + 'Release*/Pods*/*.framework')
- frameworks_by_target = frameworks.group_by { |f| f.to_s =~ %r{build/Release[^/]*/Pods-?([^/]*)/} && destination + $1 }
+ frameworks = Pathname.glob(build_dir + 'Release*/*.framework').reject { |f| f.to_s =~ /Pods*\.framework/ }
Pod::UI.puts "Built #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)}"
Pod::UI.puts "Copying frameworks to `#{destination.relative_path_from Pathname.pwd}`"
destination.rmtree if destination.directory?
- frameworks_by_target.each do |dest, frameworks|
- FileUtils.mkdir_p dest
- FileUtils.cp_r frameworks, dest, :remove_destination => true
+ frameworks.each do |framework|
+ FileUtils.mkdir_p destination
+ FileUtils.cp_r framework, destination, :remove_destination => true
end
build_dir.rmtree if build_dir.directory?
end