diff --git a/Rakefile b/Rakefile index 0ee43f433..295c8e70f 100644 --- a/Rakefile +++ b/Rakefile @@ -77,6 +77,25 @@ namespace :build do end end + desc 'Build watchOS framework.' + task :watchos do + task = XCTask::BuildFrameworkTask.new do |t| + t.directory = script_folder + t.build_directory = build_folder + t.framework_type = XCTask::FrameworkType::WATCHOS + t.framework_name = 'Parse.framework' + + t.workspace = 'Parse.xcworkspace' + t.scheme = 'Parse-watchOS' + t.configuration = 'Release' + end + result = task.execute + unless result + puts 'Failed to build watchOS Framework.' + exit(1) + end + end + desc 'Build OS X framework.' task :osx do task = XCTask::BuildFrameworkTask.new do |t| @@ -246,6 +265,7 @@ namespace :test do desc 'Run Deployment Tests' task :deployment do |_| + Rake::Task['build:watchos'].invoke Rake::Task['package:frameworks'].invoke Rake::Task['package:starters'].invoke end diff --git a/Scripts/xctask/build_framework_task.rb b/Scripts/xctask/build_framework_task.rb index d847f39b9..9b8f4af57 100755 --- a/Scripts/xctask/build_framework_task.rb +++ b/Scripts/xctask/build_framework_task.rb @@ -16,10 +16,11 @@ module XCTask class FrameworkType IOS = 'ios' OSX = 'osx' + WATCHOS = 'watchos' def self.verify(type) - if type.nil? || (type != IOS && type != OSX) - fail "Unknown framework type. Available types: 'ios', 'osx'." + if type.nil? || (type != IOS && type != OSX && type != WATCHOS) + fail "Unknown framework type. Available types: 'ios', 'osx', 'watchos'." end end end @@ -64,6 +65,8 @@ def build build_ios_framework when FrameworkType::OSX build_osx_framework + when FrameworkType::WATCHOS + build_watchos_framework end end @@ -92,6 +95,31 @@ def build_ios_framework result end + def build_watchos_framework + framework_paths = [] + framework_paths << build_framework('watchos') + framework_paths << build_framework('watchsimulator') + final_path = final_framework_path + + system("rm -rf #{final_path} && cp -R #{framework_paths[0]} #{final_path}") + + binary_name = File.basename(@framework_name, '.framework') + system("rm -rf #{final_path}/#{binary_name}") + + lipo_command = 'lipo -create' + framework_paths.each do |path| + lipo_command += " #{path}/#{binary_name}" + end + lipo_command += " -o #{final_path}/#{binary_name}" + + result = system(lipo_command) + unless result + puts 'Failed to lipo watchOS framework.' + exit(1) + end + result + end + def build_osx_framework build_path = build_framework('macosx') final_path = final_framework_path