diff --git a/.travis.yml b/.travis.yml index d4ac925..017e319 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ env: matrix: - TEST_TYPE=iOS - TEST_TYPE=CocoaPods + - TEST_TYPE=Package script: - | if [ "$TEST_TYPE" = iOS ]; then @@ -20,6 +21,8 @@ script: elif [ "$TEST_TYPE" = CocoaPods ]; then pod lib lint ParseFacebookUtilsV4.podspec pod lib lint --use-libraries ParseFacebookUtilsV4.podspec + elif [ "$TEST_TYPE" = Package ]; then + bundle exec rake package:frameworks fi after_success: - | diff --git a/Gemfile b/Gemfile index be60713..0f746f3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,6 @@ source 'https://rubygems.org' +gem 'naturally' +gem 'rake' gem 'xcpretty' -gem 'cocoapods', '~> 0.39.0.rc.1' +gem 'cocoapods', '~> 0.39' diff --git a/Gemfile.lock b/Gemfile.lock index dd785de..537fb5e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.4) + activesupport (4.2.5) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -41,10 +41,12 @@ GEM fuzzy_match (2.0.4) i18n (0.7.0) json (1.8.3) - minitest (5.8.2) + minitest (5.8.3) molinillo (0.4.0) nap (1.0.0) + naturally (2.1.0) netrc (0.7.8) + rake (10.4.2) rouge (1.10.1) thread_safe (0.3.5) tzinfo (1.2.2) @@ -60,7 +62,9 @@ PLATFORMS ruby DEPENDENCIES - cocoapods (~> 0.39.0.rc.1) + cocoapods (~> 0.39) + naturally + rake xcpretty BUNDLED WITH diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..180fbf2 --- /dev/null +++ b/Rakefile @@ -0,0 +1,95 @@ +# +# Copyright (c) 2015-present, Parse, LLC. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. An additional grant +# of patent rights can be found in the PATENTS file in the same directory. +# + +require_relative 'Vendor/xctoolchain/Scripts/xctask/build_task' +require_relative 'Vendor/xctoolchain/Scripts/xctask/build_framework_task' + +script_folder = File.expand_path(File.dirname(__FILE__)) +build_folder = File.join(script_folder, 'build') +release_folder = File.join(build_folder, 'release') + +xcworkspace_name = 'ParseFacebookUtils.xcworkspace' +framework_name = 'ParseFacebookUtilsV4.framework' + +namespace :build do + desc 'Build iOS framework.' + task :ios do + task = XCTask::BuildFrameworkTask.new do |t| + t.directory = script_folder + t.build_directory = File.join(build_folder, 'iOS') + t.framework_type = XCTask::FrameworkType::IOS + t.framework_name = framework_name + + t.workspace = xcworkspace_name + t.scheme = 'ParseFacebookUtilsV4-iOS' + t.configuration = 'Release' + end + result = task.execute + unless result + puts 'Failed to build iOS Framework.' + exit(1) + end + end + + desc 'Build tvOS framework.' + task :tvos do + task = XCTask::BuildFrameworkTask.new do |t| + t.directory = script_folder + t.build_directory = File.join(build_folder, 'tvOS') + t.framework_type = XCTask::FrameworkType::TVOS + t.framework_name = framework_name + + t.workspace = xcworkspace_name + t.scheme = 'ParseFacebookUtilsV4-tvOS' + t.configuration = 'Release' + end + result = task.execute + unless result + puts 'Failed to build tvOS Framework.' + exit(1) + end + end +end + +namespace :package do + ios_package_name = 'ParseFacebookUtils-iOS.zip' + tvos_package_name = 'ParseFacebookUtils-tvOS.zip' + + desc 'Build and package all frameworks' + task :frameworks do + rm_rf build_folder, :verbose => false + mkdir_p build_folder, :verbose => false + + Rake::Task['build:ios'].invoke + ios_framework_path = File.join(build_folder, 'iOS', framework_name) + make_package(release_folder, [ios_framework_path], ios_package_name) + + Rake::Task['build:tvos'].invoke + tvos_framework_path = File.join(build_folder, 'tvOS', framework_name) + make_package(release_folder, [tvos_framework_path], tvos_package_name) + end + + def make_package(target_path, items, archive_name) + temp_folder = File.join(target_path, 'tmp') + `mkdir -p #{temp_folder}` + + item_list = '' + items.each do |item| + `cp -R #{item} #{temp_folder}` + + file_name = File.basename(item) + item_list << " #{file_name}" + end + + archive_path = File.join(target_path, archive_name) + `cd #{temp_folder}; zip -r --symlinks #{archive_path} #{item_list}` + rm_rf temp_folder + puts "Release archive created: #{File.join(target_path, archive_name)}" + end +end