Last active
October 14, 2017 16:59
-
-
Save jongraves/21098de2ccea18265fb87adb791fad3c to your computer and use it in GitHub Desktop.
carthage copy-frameworks conditionally Xcode build step
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
built_products_dir = ENV["BUILT_PRODUCTS_DIR"] | |
frameworks_folder_path = ENV["FRAMEWORKS_FOLDER_PATH"] | |
srcroot = ENV["SRCROOT"] | |
dest = File.join(built_products_dir, frameworks_folder_path) | |
platform = ENV["PLATFORM_DISPLAY_NAME"] | |
carthage_frameworks_dir = File.join(srcroot, 'Carthage', 'Build', platform) | |
input_file_count = ENV["SCRIPT_INPUT_FILE_COUNT"].to_i | |
env = {"SCRIPT_INPUT_FILE_COUNT" => "0"} | |
for n in 0...input_file_count do | |
input_file = ENV["SCRIPT_INPUT_FILE_" + n.to_s] | |
framework_name = File.basename(input_file) | |
destination = File.join(dest, framework_name) | |
if File.exists?(destination) && File.mtime(input_file) <= File.mtime(destination) | |
puts "#{framework_name} already exists and is not older than the source. Skipping copy." | |
else | |
puts "Copying #{framework_name}." | |
current_count = env["SCRIPT_INPUT_FILE_COUNT"].to_i | |
env["SCRIPT_INPUT_FILE_" + current_count.to_s] = input_file | |
env["SCRIPT_INPUT_FILE_COUNT"] = (current_count + 1).to_s | |
end | |
end | |
system(env, "carthage copy-frameworks") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using carthage with a significant number of dependencies, the
carthage copy-frameworks
build step can take some time. This script only copies the frameworks that have been updated or are missing.Usage: Add this as a script build step to your Xcode target and set the shell to "/usr/bin/ruby". Add the frameworks you need copied as Input Files.