Skip to content

Commit

Permalink
Fix CocoaPods-generated projects support when running archive action
Browse files Browse the repository at this point in the history
Such projects have unexpected `CONFIGURATION_BUILD_DIR` build setting which is appending a target name to a common `CONFIGURATION_BUILD_DIR` value. That is problematic for our path building.
  • Loading branch information
ikesyo committed Oct 13, 2017
1 parent ff76d20 commit 94a0fc6
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions Source/CarthageKit/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,33 @@ public struct BuildSettings {
let r1 = self["TARGET_NAME"]
guard let schemeOrTarget = arguments.scheme?.name ?? r1.value else { return r1 }

let r2 = self["CONFIGURATION"]
guard let configuration = r2.value else { return r2 }

// A value almost certainly beginning with `-` or (lacking said value) an
// empty string to append without effect in the path below because Xcode
// expects the path like that.
let effectivePlatformName = self["EFFECTIVE_PLATFORM_NAME"].value ?? ""

// e.g.,
// - ArchiveIntermediates/Archimedes Mac/BuildProductsPath/Release
// - ArchiveIntermediates/Archimedes iOS/BuildProductsPath/Release-iphoneos
let path = "ArchiveIntermediates/\(schemeOrTarget)/BuildProductsPath/\(configuration)\(effectivePlatformName)"
let basePath = "ArchiveIntermediates/\(schemeOrTarget)/BuildProductsPath"
let pathComponent: String

if
let buildDir = self["BUILD_DIR"].value,
let builtProductsDir = self["BUILT_PRODUCTS_DIR"].value,
builtProductsDir.hasPrefix(buildDir)
{
// This is required to support CocoaPods-generated projects.
// See https://github.com/AliSoftware/Reusable/issues/50#issuecomment-336434345 for the details.
pathComponent = String(builtProductsDir[buildDir.endIndex...]) // e.g., /Release-iphoneos/Reusable-iOS
} else {
let r2 = self["CONFIGURATION"]
guard let configuration = r2.value else { return r2 }

// A value almost certainly beginning with `-` or (lacking said value) an
// empty string to append without effect in the path below because Xcode
// expects the path like that.
let effectivePlatformName = self["EFFECTIVE_PLATFORM_NAME"].value ?? ""

// e.g.,
// - Release
// - Release-iphoneos
pathComponent = "\(configuration)\(effectivePlatformName)"
}

let path = (basePath as NSString).appendingPathComponent(pathComponent)
return .success(path)
}

Expand Down

0 comments on commit 94a0fc6

Please sign in to comment.