diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 11cd2787..916f0855 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -172,7 +172,7 @@ Settings are merged in the following order: groups, base, configs. - [ ] **dependencies**: **[[Dependency](#dependency)]** - Dependencies for the target - [ ] **templates**: **[String]** - A list of target templates that will be merged in order - [ ] **transitivelyLinkDependencies**: **Bool** - If this is not specified the value from the project set in [Options](#options)`.transitivelyLinkDependencies` will be used. -- [ ] **directlyEmbedCarthageDependencies**: **Bool** - If this is `true` Carthage dependencies will be embedded using an `Embed Frameworks` build phase instead of the `copy-frameworks` script. Defaults to `true` for `macOS` `platform`. +- [ ] **directlyEmbedCarthageDependencies**: **Bool** - If this is `true` Carthage dependencies will be embedded using an `Embed Frameworks` build phase instead of the `copy-frameworks` script. Defaults to `true` for `macOS` `platform` targets and all tests. - [ ] **requiresObjCLinking**: **Bool** - If this is `true` any targets that link to this target will have `-ObjC` added to their `OTHER_LDFLAGS`. This is required if a static library has any catagories or extensions on Objective-C code. See [this guide](https://pewpewthespells.com/blog/objc_linker_flags.html#objc) for more details. Defaults to `true` if `type` is `library.static`. If you are 100% sure you don't have catagories or extensions on Objective-C code (pure Swift with no use of Foundation/UIKit) you can set this to `false`, otherwise it's best to leave it alone. - [ ] **prebuildScripts**: **[[Build Script](#build-script)]** - Build scripts that run *before* any other build phases - [ ] **postbuildScripts**: **[[Build Script](#build-script)]** - Build scripts that run *after* any other build phases diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 554b5bae..c67da102 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -436,7 +436,7 @@ public class PBXProjGenerator { let targetDependencies = (target.transitivelyLinkDependencies ?? project.options.transitivelyLinkDependencies) ? getAllDependenciesPlusTransitiveNeedingEmbedding(target: target) : target.dependencies - let directlyEmbedCarthage = target.directlyEmbedCarthageDependencies ?? (target.platform == .macOS) + let directlyEmbedCarthage = target.directlyEmbedCarthageDependencies ?? (target.platform == .macOS || target.type.isTest) for dependency in targetDependencies { diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index e4992247..0a214855 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -671,7 +671,6 @@ buildConfigurationList = CL_123503999387 /* Build configuration list for PBXNativeTarget "App_iOS_UITests" */; buildPhases = ( SBP_12350399938 /* Sources */, - SSBP_3150067808 /* Carthage */, ); buildRules = ( ); @@ -832,7 +831,6 @@ buildConfigurationList = CL_783122899910 /* Build configuration list for PBXNativeTarget "App_iOS_Tests" */; buildPhases = ( SBP_78312289991 /* Sources */, - SSBP_6451525835 /* Carthage */, ); buildRules = ( ); @@ -1006,22 +1004,6 @@ shellPath = /bin/sh; shellScript = "echo \"You ran a script\"\n"; }; - SSBP_3150067808 /* Carthage */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework", - ); - name = Carthage; - outputPaths = ( - "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Alamofire.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "carthage copy-frameworks\n"; - }; SSBP_3886691194 /* MyScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1080,22 +1062,6 @@ shellPath = /bin/sh; shellScript = "echo \"You ran a script\"\n"; }; - SSBP_6451525835 /* Carthage */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework", - ); - name = Carthage; - outputPaths = ( - "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Alamofire.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "carthage copy-frameworks\n"; - }; SSBP_8106229290 /* Carthage */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index a1f912d4..aa7fedf4 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -477,7 +477,8 @@ class ProjectGeneratorTests: XCTestCase { Dependency(type: .target, reference: app.name), Dependency(type: .target, reference: iosFrameworkB.name), Dependency(type: .carthage, reference: "CarthageD"), - ] + ], + directlyEmbedCarthageDependencies: false ) expectedResourceFiles[appTest.name] = Set([ resourceBundle.filename,