payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Carthage/Carthage/pulls/comments/286203196","pull_request_review_id":240273156,"id":286203196,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI4NjIwMzE5Ng==","diff_hunk":"@@ -0,0 +1,238 @@\n+\n+import Foundation\n+import Result\n+import ReactiveSwift\n+import Tentacle\n+import XCDBLD\n+import ReactiveTask\n+\n+public final class InputFilesInferrer {\n+    \n+    typealias LinkedFrameworksResolver = (URL) -> Result<[String], CarthageError>\n+    \n+    /// For test-use only\n+    var executableResolver: (URL) -> URL? = { Bundle(url: $0)?.executableURL }\n+    \n+    /// For test-use only\n+    var builtFrameworkFilter: (URL) -> Bool = { url in\n+        if\n+            let executableURL = Bundle(url: url)?.executableURL,\n+            let header = MachHeader.headers(forMachOFileAtUrl: executableURL).single()?.value\n+        {\n+            return header.fileType == MH_DYLIB\n+        }\n+        return false\n+    }\n+    \n+    private let builtFrameworks: SignalProducer<URL, CarthageError>\n+    private let linkedFrameworksResolver: LinkedFrameworksResolver\n+    \n+    // MARK: - Init\n+    \n+    init(builtFrameworks: SignalProducer<URL, CarthageError>, linkedFrameworksResolver: @escaping LinkedFrameworksResolver) {\n+        self.builtFrameworks = builtFrameworks\n+        self.linkedFrameworksResolver = linkedFrameworksResolver\n+    }\n+\n+    public convenience init(projectDirectory: URL, platform: Platform, frameworkSearchPaths: [URL]) {\n+        let allFrameworkSearchPath = InputFilesInferrer.allFrameworkSearchPaths(\n+            forProjectIn: projectDirectory,\n+            platform: platform,\n+            frameworkSearchPaths: frameworkSearchPaths\n+        )\n+        let enumerator = SignalProducer(allFrameworkSearchPath).flatMap(.concat, frameworksInDirectory)\n+        \n+        self.init(builtFrameworks: enumerator, linkedFrameworksResolver: linkedFrameworks(for:))\n+    }\n+    \n+    // MARK: - Inferring\n+\n+    public func inputFiles(for executableURL: URL, userInputFiles: SignalProducer<URL, CarthageError>) -> SignalProducer<URL, CarthageError> {\n+        let userFrameworksMap = userInputFiles.reduce(into: [String: URL]()) { (map, frameworkURL) in\n+            let name = frameworkURL.deletingPathExtension().lastPathComponent\n+            map[name] = frameworkURL\n+        }\n+\n+        let builtFrameworksMap = builtFrameworks\n+            .filter(builtFrameworkFilter)\n+            .reduce(into: [String: URL]()) { (map, frameworkURL) in\n+                let name = frameworkURL.deletingPathExtension().lastPathComponent\n+                // Framework potentially can be presented in multiple directories from FRAMEWORK_SEARCH_PATHS.\n+                // We're only interested in the first occurrence to preserve order of the paths.\n+                if map[name] == nil {\n+                    map[name] = frameworkURL\n+                }\n+            }\n+        \n+        return SignalProducer.combineLatest(userFrameworksMap, builtFrameworksMap)\n+            .flatMap(.latest) { userFrameworksMap, builtFrameworksMap -> SignalProducer<URL, CarthageError> in\n+                let availableFrameworksMap = userFrameworksMap.merging(builtFrameworksMap) { (lhs, rhs) in\n+                    // user's framework path always takes precedence over default Carthage's path.\n+                    return lhs\n+                }\n+                \n+                if availableFrameworksMap.isEmpty {\n+                    return .empty\n+                }\n+                \n+                return SignalProducer(result: self.resolveFrameworks(at: executableURL, frameworksMap: availableFrameworksMap))\n+                    .flatten()\n+                    .filter { url in\n+                        // We have to omit paths already specified by User.\n+                        // Can't use direct URLs comparison, because it is not guaranteed that same framework will have\n+                        // same URL all the time. i.e. '/A.framework/' and '/A.framework' will lead to the same result but are not equal.\n+                        let name = url.deletingPathExtension().lastPathComponent\n+                        return userFrameworksMap[name] == nil\n+                    }\n+            }\n+    }\n+    \n+    private func resolveFrameworks(at executableURL: URL, frameworksMap: [String: URL]) -> Result<[URL], CarthageError> {\n+        var resolvedFrameworks: Set<String> = []\n+        do {\n+            try collectFrameworks(at: executableURL, accumulator: &resolvedFrameworks, frameworksMap: frameworksMap)\n+        } catch let error as CarthageError {\n+            return .failure(error)\n+        } catch {\n+            return .failure(CarthageError.internalError(description: \"Failed to infer linked frameworks\"))\n+        }\n+        \n+        return .success(resolvedFrameworks.compactMap { frameworksMap[$0] })\n+    }\n+    \n+    private func collectFrameworks(at executableURL: URL, accumulator: inout Set<String>, frameworksMap: [String: URL]) throws {\n+        let name = executableURL.deletingPathExtension().lastPathComponent\n+        if !accumulator.insert(name).inserted {\n+            return\n+        }\n+        \n+        switch linkedFrameworksResolver(executableURL) {\n+        case .success(let values):\n+            let frameworksToCollect = values\n+                .filter { !accumulator.contains($0) }\n+                .compactMap { frameworksMap[$0] }\n+                .compactMap(executableResolver)\n+\n+            try frameworksToCollect.forEach {\n+                try collectFrameworks(at: $0, accumulator: &accumulator, frameworksMap: frameworksMap)\n+            }\n+            \n+        case .failure(let error):\n+            throw error\n+        }\n+    }\n+    \n+    // MARK: - Utility\n+    \n+    static func allFrameworkSearchPaths(forProjectIn directory: URL, platform: Platform, frameworkSearchPaths: [URL]) -> [URL] {\n+        // Carthage's default framework search path should always be presented. Under rare circumstances\n+        // framework located at the non-default path can be linked against Carthage's framework.\n+        // Since we're allowing user to specify only first-level frameworks, App might not link nested framework,","path":"Source/CarthageKit/InputFilesInferrer.swift","position":null,"original_position":130,"commit_id":"99b1f4870540a734be02cd9170d759c2d1f2b361","original_commit_id":"2229832ae6d18dd15a4e16d66875cb86c7128b46","user":{"login":"dimazen","id":829562,"node_id":"MDQ6VXNlcjgyOTU2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/829562?v=4","gravatar_id":"","url":"https://api.github.com/users/dimazen","html_url":"https://github.com/dimazen","followers_url":"https://api.github.com/users/dimazen/followers","following_url":"https://api.github.com/users/dimazen/following{/other_user}","gists_url":"https://api.github.com/users/dimazen/gists{/gist_id}","starred_url":"https://api.github.com/users/dimazen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimazen/subscriptions","organizations_url":"https://api.github.com/users/dimazen/orgs","repos_url":"https://api.github.com/users/dimazen/repos","events_url":"https://api.github.com/users/dimazen/events{/privacy}","received_events_url":"https://api.github.com/users/dimazen/received_events","type":"User","site_admin":false},"body":"\"Nested\" replaced by \"transitive\".","created_at":"2019-05-21T20:10:42Z","updated_at":"2019-05-21T20:10:42Z","html_url":"https://github.com/Carthage/Carthage/pull/2731#discussion_r286203196","pull_request_url":"https://api.github.com/repos/Carthage/Carthage/pulls/2731","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/comments/286203196"},"html":{"href":"https://github.com/Carthage/Carthage/pull/2731#discussion_r286203196"},"pull_request":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/2731"}},"in_reply_to_id":285945723},"pull_request":{"url":"https://api.github.com/repos/Carthage/Carthage/pulls/2731","id":260663352,"node_id":"MDExOlB1bGxSZXF1ZXN0MjYwNjYzMzUy","html_url":"https://github.com/Carthage/Carthage/pull/2731","diff_url":"https://github.com/Carthage/Carthage/pull/2731.diff","patch_url":"https://github.com/Carthage/Carthage/pull/2731.patch","issue_url":"https://api.github.com/repos/Carthage/Carthage/issues/2731","number":2731,"state":"open","locked":false,"title":"Automate copy-frameworks","user":{"login":"dimazen","id":829562,"node_id":"MDQ6VXNlcjgyOTU2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/829562?v=4","gravatar_id":"","url":"https://api.github.com/users/dimazen","html_url":"https://github.com/dimazen","followers_url":"https://api.github.com/users/dimazen/followers","following_url":"https://api.github.com/users/dimazen/following{/other_user}","gists_url":"https://api.github.com/users/dimazen/gists{/gist_id}","starred_url":"https://api.github.com/users/dimazen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimazen/subscriptions","organizations_url":"https://api.github.com/users/dimazen/orgs","repos_url":"https://api.github.com/users/dimazen/repos","events_url":"https://api.github.com/users/dimazen/events{/privacy}","received_events_url":"https://api.github.com/users/dimazen/received_events","type":"User","site_admin":false},"body":"This PR resolves https://github.com/Carthage/Carthage/issues/2605. \r\nTested on a test project as well as two production projects - works as expected. However, I need your advise on: \r\n- How to better write tests for this case? For integration testing we would need a project with couple of frameworks and an executable to run `otool -L`. I don't know for sure, but MachO format seems to be quite stable, so no changes from otool expected.\r\n- I'm not sure whether check for static frameworks is reliable or not. `frameworksInDirectory` returns both static and dynamic frameworks. Attempt to filter them out by checking their MachHeader.fileType doesn't help, because both return `MH_EXECUTE`. I end up checking whether framework nested in the `Static` folder or not but is that ok?","created_at":"2019-03-13T08:17:53Z","updated_at":"2019-05-21T20:10:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b1c8d31810d173d6768a587f0af305ef5db87d86","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Carthage/Carthage/pulls/2731/commits","review_comments_url":"https://api.github.com/repos/Carthage/Carthage/pulls/2731/comments","review_comment_url":"https://api.github.com/repos/Carthage/Carthage/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Carthage/Carthage/issues/2731/comments","statuses_url":"https://api.github.com/repos/Carthage/Carthage/statuses/99b1f4870540a734be02cd9170d759c2d1f2b361","head":{"label":"dimazen:master","ref":"master","sha":"99b1f4870540a734be02cd9170d759c2d1f2b361","user":{"login":"dimazen","id":829562,"node_id":"MDQ6VXNlcjgyOTU2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/829562?v=4","gravatar_id":"","url":"https://api.github.com/users/dimazen","html_url":"https://github.com/dimazen","followers_url":"https://api.github.com/users/dimazen/followers","following_url":"https://api.github.com/users/dimazen/following{/other_user}","gists_url":"https://api.github.com/users/dimazen/gists{/gist_id}","starred_url":"https://api.github.com/users/dimazen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimazen/subscriptions","organizations_url":"https://api.github.com/users/dimazen/orgs","repos_url":"https://api.github.com/users/dimazen/repos","events_url":"https://api.github.com/users/dimazen/events{/privacy}","received_events_url":"https://api.github.com/users/dimazen/received_events","type":"User","site_admin":false},"repo":{"id":175292799,"node_id":"MDEwOlJlcG9zaXRvcnkxNzUyOTI3OTk=","name":"Carthage","full_name":"dimazen/Carthage","private":false,"owner":{"login":"dimazen","id":829562,"node_id":"MDQ6VXNlcjgyOTU2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/829562?v=4","gravatar_id":"","url":"https://api.github.com/users/dimazen","html_url":"https://github.com/dimazen","followers_url":"https://api.github.com/users/dimazen/followers","following_url":"https://api.github.com/users/dimazen/following{/other_user}","gists_url":"https://api.github.com/users/dimazen/gists{/gist_id}","starred_url":"https://api.github.com/users/dimazen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimazen/subscriptions","organizations_url":"https://api.github.com/users/dimazen/orgs","repos_url":"https://api.github.com/users/dimazen/repos","events_url":"https://api.github.com/users/dimazen/events{/privacy}","received_events_url":"https://api.github.com/users/dimazen/received_events","type":"User","site_admin":false},"html_url":"https://github.com/dimazen/Carthage","description":"A simple, decentralized dependency manager for Cocoa","fork":true,"url":"https://api.github.com/repos/dimazen/Carthage","forks_url":"https://api.github.com/repos/dimazen/Carthage/forks","keys_url":"https://api.github.com/repos/dimazen/Carthage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimazen/Carthage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimazen/Carthage/teams","hooks_url":"https://api.github.com/repos/dimazen/Carthage/hooks","issue_events_url":"https://api.github.com/repos/dimazen/Carthage/issues/events{/number}","events_url":"https://api.github.com/repos/dimazen/Carthage/events","assignees_url":"https://api.github.com/repos/dimazen/Carthage/assignees{/user}","branches_url":"https://api.github.com/repos/dimazen/Carthage/branches{/branch}","tags_url":"https://api.github.com/repos/dimazen/Carthage/tags","blobs_url":"https://api.github.com/repos/dimazen/Carthage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimazen/Carthage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimazen/Carthage/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimazen/Carthage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimazen/Carthage/statuses/{sha}","languages_url":"https://api.github.com/repos/dimazen/Carthage/languages","stargazers_url":"https://api.github.com/repos/dimazen/Carthage/stargazers","contributors_url":"https://api.github.com/repos/dimazen/Carthage/contributors","subscribers_url":"https://api.github.com/repos/dimazen/Carthage/subscribers","subscription_url":"https://api.github.com/repos/dimazen/Carthage/subscription","commits_url":"https://api.github.com/repos/dimazen/Carthage/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimazen/Carthage/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimazen/Carthage/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimazen/Carthage/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimazen/Carthage/contents/{+path}","compare_url":"https://api.github.com/repos/dimazen/Carthage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimazen/Carthage/merges","archive_url":"https://api.github.com/repos/dimazen/Carthage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimazen/Carthage/downloads","issues_url":"https://api.github.com/repos/dimazen/Carthage/issues{/number}","pulls_url":"https://api.github.com/repos/dimazen/Carthage/pulls{/number}","milestones_url":"https://api.github.com/repos/dimazen/Carthage/milestones{/number}","notifications_url":"https://api.github.com/repos/dimazen/Carthage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimazen/Carthage/labels{/name}","releases_url":"https://api.github.com/repos/dimazen/Carthage/releases{/id}","deployments_url":"https://api.github.com/repos/dimazen/Carthage/deployments","created_at":"2019-03-12T20:39:26Z","updated_at":"2019-05-21T20:09:55Z","pushed_at":"2019-05-21T20:09:52Z","git_url":"git://github.com/dimazen/Carthage.git","ssh_url":"git@github.com:dimazen/Carthage.git","clone_url":"https://github.com/dimazen/Carthage.git","svn_url":"https://github.com/dimazen/Carthage","homepage":"","size":18932,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Carthage:master","ref":"master","sha":"c47beba3e243ca8ba4d85065ae9da9279a3043bf","user":{"login":"Carthage","id":9146792,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDY3OTI=","avatar_url":"https://avatars1.githubusercontent.com/u/9146792?v=4","gravatar_id":"","url":"https://api.github.com/users/Carthage","html_url":"https://github.com/Carthage","followers_url":"https://api.github.com/users/Carthage/followers","following_url":"https://api.github.com/users/Carthage/following{/other_user}","gists_url":"https://api.github.com/users/Carthage/gists{/gist_id}","starred_url":"https://api.github.com/users/Carthage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carthage/subscriptions","organizations_url":"https://api.github.com/users/Carthage/orgs","repos_url":"https://api.github.com/users/Carthage/repos","events_url":"https://api.github.com/users/Carthage/events{/privacy}","received_events_url":"https://api.github.com/users/Carthage/received_events","type":"Organization","site_admin":false},"repo":{"id":25050844,"node_id":"MDEwOlJlcG9zaXRvcnkyNTA1MDg0NA==","name":"Carthage","full_name":"Carthage/Carthage","private":false,"owner":{"login":"Carthage","id":9146792,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDY3OTI=","avatar_url":"https://avatars1.githubusercontent.com/u/9146792?v=4","gravatar_id":"","url":"https://api.github.com/users/Carthage","html_url":"https://github.com/Carthage","followers_url":"https://api.github.com/users/Carthage/followers","following_url":"https://api.github.com/users/Carthage/following{/other_user}","gists_url":"https://api.github.com/users/Carthage/gists{/gist_id}","starred_url":"https://api.github.com/users/Carthage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carthage/subscriptions","organizations_url":"https://api.github.com/users/Carthage/orgs","repos_url":"https://api.github.com/users/Carthage/repos","events_url":"https://api.github.com/users/Carthage/events{/privacy}","received_events_url":"https://api.github.com/users/Carthage/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Carthage/Carthage","description":"A simple, decentralized dependency manager for Cocoa","fork":false,"url":"https://api.github.com/repos/Carthage/Carthage","forks_url":"https://api.github.com/repos/Carthage/Carthage/forks","keys_url":"https://api.github.com/repos/Carthage/Carthage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Carthage/Carthage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Carthage/Carthage/teams","hooks_url":"https://api.github.com/repos/Carthage/Carthage/hooks","issue_events_url":"https://api.github.com/repos/Carthage/Carthage/issues/events{/number}","events_url":"https://api.github.com/repos/Carthage/Carthage/events","assignees_url":"https://api.github.com/repos/Carthage/Carthage/assignees{/user}","branches_url":"https://api.github.com/repos/Carthage/Carthage/branches{/branch}","tags_url":"https://api.github.com/repos/Carthage/Carthage/tags","blobs_url":"https://api.github.com/repos/Carthage/Carthage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Carthage/Carthage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Carthage/Carthage/git/refs{/sha}","trees_url":"https://api.github.com/repos/Carthage/Carthage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Carthage/Carthage/statuses/{sha}","languages_url":"https://api.github.com/repos/Carthage/Carthage/languages","stargazers_url":"https://api.github.com/repos/Carthage/Carthage/stargazers","contributors_url":"https://api.github.com/repos/Carthage/Carthage/contributors","subscribers_url":"https://api.github.com/repos/Carthage/Carthage/subscribers","subscription_url":"https://api.github.com/repos/Carthage/Carthage/subscription","commits_url":"https://api.github.com/repos/Carthage/Carthage/commits{/sha}","git_commits_url":"https://api.github.com/repos/Carthage/Carthage/git/commits{/sha}","comments_url":"https://api.github.com/repos/Carthage/Carthage/comments{/number}","issue_comment_url":"https://api.github.com/repos/Carthage/Carthage/issues/comments{/number}","contents_url":"https://api.github.com/repos/Carthage/Carthage/contents/{+path}","compare_url":"https://api.github.com/repos/Carthage/Carthage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Carthage/Carthage/merges","archive_url":"https://api.github.com/repos/Carthage/Carthage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Carthage/Carthage/downloads","issues_url":"https://api.github.com/repos/Carthage/Carthage/issues{/number}","pulls_url":"https://api.github.com/repos/Carthage/Carthage/pulls{/number}","milestones_url":"https://api.github.com/repos/Carthage/Carthage/milestones{/number}","notifications_url":"https://api.github.com/repos/Carthage/Carthage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Carthage/Carthage/labels{/name}","releases_url":"https://api.github.com/repos/Carthage/Carthage/releases{/id}","deployments_url":"https://api.github.com/repos/Carthage/Carthage/deployments","created_at":"2014-10-10T19:54:55Z","updated_at":"2019-05-21T18:11:11Z","pushed_at":"2019-05-21T20:09:54Z","git_url":"git://github.com/Carthage/Carthage.git","ssh_url":"git@github.com:Carthage/Carthage.git","clone_url":"https://github.com/Carthage/Carthage.git","svn_url":"https://github.com/Carthage/Carthage","homepage":"","size":18988,"stargazers_count":12860,"watchers_count":12860,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1254,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":146,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1254,"open_issues":146,"watchers":12860,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/2731"},"html":{"href":"https://github.com/Carthage/Carthage/pull/2731"},"issue":{"href":"https://api.github.com/repos/Carthage/Carthage/issues/2731"},"comments":{"href":"https://api.github.com/repos/Carthage/Carthage/issues/2731/comments"},"review_comments":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/2731/comments"},"review_comment":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/2731/commits"},"statuses":{"href":"https://api.github.com/repos/Carthage/Carthage/statuses/99b1f4870540a734be02cd9170d759c2d1f2b361"}},"author_association":"CONTRIBUTOR"}}
other: {"actor":{"display_login":"dimazen"}}