From c79a205339a150ef3000985cc542ccb6564f8a4f Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Wed, 27 Jun 2018 22:18:12 +1000 Subject: [PATCH] don't code sign target dependencies by default --- Sources/ProjectSpec/Dependency.swift | 19 ++++-------------- Sources/XcodeGenKit/PBXProjGenerator.swift | 20 ++++++++++++++++--- .../Project.xcodeproj/project.pbxproj | 10 +++++----- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Sources/ProjectSpec/Dependency.swift b/Sources/ProjectSpec/Dependency.swift index 82f2fcd4..18324eb0 100644 --- a/Sources/ProjectSpec/Dependency.swift +++ b/Sources/ProjectSpec/Dependency.swift @@ -7,7 +7,7 @@ public struct Dependency: Equatable { public var type: DependencyType public var reference: String public var embed: Bool? - public var codeSign: Bool = true + public var codeSign: Bool? public var removeHeaders: Bool = true public var link: Bool = true public var implicit: Bool = false @@ -16,12 +16,14 @@ public struct Dependency: Equatable { type: DependencyType, reference: String, embed: Bool? = nil, + codeSign: Bool? = nil, link: Bool = true, implicit: Bool = false ) { self.type = type self.reference = reference self.embed = embed + self.codeSign = codeSign self.link = link self.implicit = implicit } @@ -31,17 +33,6 @@ public struct Dependency: Equatable { case framework case carthage } - - public var buildSettings: [String: Any] { - var attributes: [String] = [] - if codeSign { - attributes.append("CodeSignOnCopy") - } - if removeHeaders { - attributes.append("RemoveHeadersOnCopy") - } - return ["ATTRIBUTES": attributes] - } } extension Dependency: JSONObjectConvertible { @@ -61,13 +52,11 @@ extension Dependency: JSONObjectConvertible { } embed = jsonDictionary.json(atKeyPath: "embed") + codeSign = jsonDictionary.json(atKeyPath: "codeSign") if let bool: Bool = jsonDictionary.json(atKeyPath: "link") { link = bool } - if let bool: Bool = jsonDictionary.json(atKeyPath: "codeSign") { - codeSign = bool - } if let bool: Bool = jsonDictionary.json(atKeyPath: "removeHeaders") { removeHeaders = bool } diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index dcc2fa70..9a8a8f65 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -393,7 +393,20 @@ public class PBXProjGenerator { for dependency in target.dependencies { + var embedAttributes: [String] = [] + let embed = dependency.embed ?? target.shouldEmbedDependencies + let codeSign = dependency.codeSign ?? (dependency.type != .target) + + if codeSign { + embedAttributes.append("CodeSignOnCopy") + } + if dependency.removeHeaders { + embedAttributes.append("RemoveHeadersOnCopy") + } + + let embedSettings = ["ATTRIBUTES": embedAttributes] + switch dependency.type { case .target: let dependencyTargetName = dependency.reference @@ -431,11 +444,12 @@ public class PBXProjGenerator { if (dependency.embed ?? target.type.isApp) && !dependencyTarget.type.isLibrary { + let embedFile = createObject( id: dependencyFileReference + target.name, PBXBuildFile( fileRef: dependencyFileReference, - settings: dependency.buildSettings + settings: embedSettings ) ) @@ -479,7 +493,7 @@ public class PBXProjGenerator { if embed { let embedFile = createObject( id: fileReference + target.name, - PBXBuildFile(fileRef: fileReference, settings: dependency.buildSettings) + PBXBuildFile(fileRef: fileReference, settings: embedSettings) ) copyFrameworksReferences.append(embedFile.reference) } @@ -502,7 +516,7 @@ public class PBXProjGenerator { if target.platform == .macOS && embed { let embedFile = createObject( id: fileReference + target.name, - PBXBuildFile(fileRef: fileReference, settings: dependency.buildSettings) + PBXBuildFile(fileRef: fileReference, settings: embedSettings) ) copyFrameworksReferences.append(embedFile.reference) } diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index 469af7b6..0dae4350 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -33,7 +33,7 @@ BF_334778067417 = {isa = PBXBuildFile; fileRef = FR_783122899910 /* App_iOS_Tests.xctest */; }; BF_360196406184 /* TestProjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_722239415598 /* TestProjectTests.swift */; }; BF_425679397292 /* MyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = FR_183521624014 /* MyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BF_441538117869 /* App_watchOS Extension.appex in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR_507023492251 /* App_watchOS Extension.appex */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + BF_441538117869 /* App_watchOS Extension.appex in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR_507023492251 /* App_watchOS Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BF_447782698339 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FR_752394658615 /* Alamofire.framework */; }; BF_456457948943 /* FrameworkFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_172952167809 /* FrameworkFile.swift */; }; BF_470396236719 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FR_410645050443 /* Alamofire.framework */; }; @@ -47,7 +47,7 @@ BF_563614389392 = {isa = PBXBuildFile; fileRef = FR_618687462494 /* iMessageExtension.appex */; }; BF_612351978356 /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = VG_264279911176 /* Interface.storyboard */; }; BF_624802436672 /* FrameworkFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_172952167809 /* FrameworkFile.swift */; }; - BF_647038614509 /* iMessageApp.app in Resources */ = {isa = PBXBuildFile; fileRef = FR_935153865209 /* iMessageApp.app */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + BF_647038614509 /* iMessageApp.app in Resources */ = {isa = PBXBuildFile; fileRef = FR_935153865209 /* iMessageApp.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BF_670499288392 /* Model.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = VG_229021855709 /* Model.xcdatamodeld */; settings = {COMPILER_FLAGS = "-Werror"; }; }; BF_681504666330 = {isa = PBXBuildFile; fileRef = FR_825232110500 /* App_iOS.app */; }; BF_703054643820 /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_310979699934 /* MessagesViewController.swift */; }; @@ -55,17 +55,17 @@ BF_729846993631 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FR_410645050443 /* Alamofire.framework */; }; BF_732745079658 = {isa = PBXBuildFile; fileRef = FR_324671077936 /* App_watchOS.app */; }; BF_734036107922 /* MyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = FR_183521624014 /* MyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BF_747443236192 /* App_watchOS.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR_324671077936 /* App_watchOS.app */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + BF_747443236192 /* App_watchOS.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR_324671077936 /* App_watchOS.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BF_757906110813 = {isa = PBXBuildFile; fileRef = FR_662315837182 /* Framework.framework */; }; BF_813358525536 /* MyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = FR_183521624014 /* MyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; BF_828878846239 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = VG_201160695646 /* MainInterface.storyboard */; }; BF_830383951771 /* NotificationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_304712043717 /* NotificationController.swift */; }; BF_854463933379 = {isa = PBXBuildFile; fileRef = FR_438704538506 /* Framework.framework */; }; BF_860391087135 /* StandaloneAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FR_408537768279 /* StandaloneAssets.xcassets */; }; - BF_870702193513 /* iMessageExtension.appex in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR_618687462494 /* iMessageExtension.appex */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + BF_870702193513 /* iMessageExtension.appex in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR_618687462494 /* iMessageExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BF_892119987440 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_854336462818 /* AppDelegate.swift */; settings = {COMPILER_FLAGS = "-Werror"; }; }; BF_901390118565 /* FrameworkFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_172952167809 /* FrameworkFile.swift */; }; - BF_905038616071 /* Framework.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR_472296042419 /* Framework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + BF_905038616071 /* Framework.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = FR_472296042419 /* Framework.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BF_905617636654 /* Headers in Headers */ = {isa = PBXBuildFile; fileRef = FR_815403394914 /* Headers */; settings = {ATTRIBUTES = (Public, ); }; }; BF_940936137577 = {isa = PBXBuildFile; fileRef = FR_123503999387 /* App_iOS_UITests.xctest */; }; /* End PBXBuildFile section */