-
-
Save edwardean/0c18159b03992e24742062f72c4a1c95 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