Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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
Expand Down
32 changes: 30 additions & 2 deletions Scripts/xctask/build_framework_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -64,6 +65,8 @@ def build
build_ios_framework
when FrameworkType::OSX
build_osx_framework
when FrameworkType::WATCHOS
build_watchos_framework
end
end

Expand Down Expand Up @@ -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
Expand Down