fix legacy targets dependencies

This commit is contained in:
yonaskolb 2020-02-07 09:36:53 +11:00
parent ef9076ce56
commit d966e9d610
3 changed files with 13 additions and 4 deletions

View File

@ -4,6 +4,7 @@
#### Fixed
- Validate scheme test action and test coverage target references before generating. [#775](https://github.com/yonaskolb/XcodeGen/pull/775) @liamnichols
- Fixed using legacy targets as dependencies [#778](https://github.com/yonaskolb/XcodeGen/pull/778) @yonaskolb
#### Internal
- Updated to XcodeProj 7.8.0 [#777](https://github.com/yonaskolb/XcodeGen/pull/777) @yonaskolb

View File

@ -622,14 +622,13 @@ public class PBXProjGenerator {
return !linkingAttributes.isEmpty ? ["ATTRIBUTES": linkingAttributes] : nil
}
func processTargetDependency(_ dependency: Dependency, dependencyTarget: Target, embedFileReference: PBXFileElement) {
func processTargetDependency(_ dependency: Dependency, dependencyTarget: Target, embedFileReference: PBXFileElement?) {
let dependencyLinkage = dependencyTarget.type.defaultLinkage
let link = dependency.link ??
((dependencyLinkage == .dynamic && target.type != .staticLibrary) ||
(dependencyLinkage == .static && target.type.isExecutable))
if link {
let dependencyFile = embedFileReference
if link, let dependencyFile = embedFileReference {
let buildFile = addObject(
PBXBuildFile(file: dependencyFile, settings: getDependencyFrameworkSettings(dependency: dependency))
)
@ -682,7 +681,7 @@ public class PBXProjGenerator {
let targetDependency = generateTargetDependency(from: target.name, to: dependencyTargetName)
dependencies.append(targetDependency)
guard let dependencyTarget = project.getTarget(dependencyTargetName) else { continue }
processTargetDependency(dependency, dependencyTarget: dependencyTarget, embedFileReference: targetFileReferences[dependencyTarget.name]!)
processTargetDependency(dependency, dependencyTarget: dependencyTarget, embedFileReference: targetFileReferences[dependencyTarget.name])
case .project(let dependencyProjectName):
let dependencyTargetName = dependencyTargetReference.name
let (targetDependency, dependencyTarget, dependencyProductProxy) = try generateExternalTargetDependency(from: target.name, to: dependencyTargetName, in: dependencyProjectName, platform: target.platform)

View File

@ -262,6 +262,15 @@ class ProjectGeneratorTests: XCTestCase {
try expect(nativeTargets.contains { $0.name == optionalFramework.name }).beTrue()
}
$0.it("generates legacy target") {
let target = Target(name: "target", type: .application, platform: .iOS, dependencies: [.init(type: .target, reference: "legacy")])
let legacyTarget = Target(name: "legacy", type: .none, platform: .iOS, legacy: .init(toolPath: "path"))
let project = Project(name: "test", targets: [target, legacyTarget])
let pbxProject = try project.generatePbxProj()
try expect(pbxProject.legacyTargets.count) == 1
}
$0.it("generates target attributes") {
var appTargetWithAttributes = app
appTargetWithAttributes.settings.buildSettings["DEVELOPMENT_TEAM"] = "123"