TUIST。如果我添加自定义配置,则框架未编译用于测试

问题描述 投票:0回答:1

在子模块上拆分大型整体项目时,我遇到了非常奇怪的问题。 我正在尝试构建 EventTracking 框架并向其添加测试。

我们有几个不同的服务器,需要配置不同的

Configurations = .debug(name: "Develop-Debug"), .debug(name: "Stage-Debug")... etc.

我们有一个单独的网络管理框架和一些额外的帮助程序(相应地命名为 Internal_Framework_With_HelpersInternal_Networking_Framework

框架的

Project.swift
文件(Internal_Framework_With_HelpersInternal_Networking_Framework)也包含自定义配置的完整列表。

所有项目均成功生成并构建,没有错误。 但是当我尝试为 EventTracking 子模块编写一些测试并将

@testable
宏添加到
import EventTracking
时,我收到错误 模块“EventTracking”未编译用于测试 enter image description here

我尝试从 EventTracking 子模块的

Project.swift
文件中删除自定义配置并生成项目。 在这种情况下,我没有收到错误模块“EventTracking”未编译用于测试 但我的整个项目完全停止构建,并且我收到很多错误

这是我的 EventTracking 子模块

Project.swift
文件

let project = Project(
    name: "EventTracking",
    organizationName: "com.organizationName",
    options: .options(
        automaticSchemesOptions: Project.Options.AutomaticSchemesOptions.enabled(
            targetSchemesGrouping: .byNameSuffix(
                build: [
                    "",
                    "Interface",
                    "Testing"
                ],
                test: ["Tests"],
                run: []
            ),
            codeCoverageEnabled: true,
            testingOptions: []
        )
    ),
    settings: .settings(
        base: [
            "OTHER_LDFLAGS": "$(inherited) -ObjC"
        ],
        configurations: [
            .debug(name: "Develop-Debug"),
            .debug(name: "Stage-Debug"),
            .debug(name: "Prod-Debug"),
            .debug(name: "Test1-Debug"),
            .debug(name: "Test2-Debug"),
            .debug(name: "Test3-Debug"),
            .debug(name: "Test4-Debug"),
            .release(name: "Develop-Release"),
            .release(name: "Stage-Release"),
            .release(name: "Prod-Release"),
            .release(name: "Test1-Release"),
            .release(name: "Test2-Release"),
            .release(name: "Test3-Release"),
            .release(name: "Test4-Release"),
            ],
        defaultSettings: .recommended
    ),
    targets: [
        .target(
            name: "EventTracking",
            destinations: [
                .iPhone,
                .macWithiPadDesign
            ],
            product: .framework,
            bundleId: "com.organizationName.EventTracking",
            deploymentTargets: DeploymentTargets.iOS("15.0"),
            sources: .paths(
                ["Sources/**/*.swift"]
            ),
            dependencies: [
                TargetDependency.package(
                    product: "AppsFlyerLib"
                ),
                TargetDependency.project(
                    target: "Internal_Framework_With_Helpers",
                    path: .relativeToRoot("Projects/Internal_Framework_With_Helpers")
                ),
                TargetDependency.project(
                    target: "Internal_Networking_Framework",
                    path: .relativeToRoot("Projects/Internal_Networking_Framework")
                )
            ],
            settings: .settings(
                base: [
                    "DEVELOPMENT_ASSET_PATHS" : [""]
                ],
                configurations: [],
                defaultSettings: .recommended
            )
        ),
        .target(
            name: "EventTrackingTests",
            destinations: [
                .iPhone,
                .macWithiPadDesign
            ],
            product: .unitTests,
            bundleId: "com.organizationName.EventTrackingTests",
            deploymentTargets: DeploymentTargets.iOS("15.0"),
            sources: .paths(
                ["Tests/**/*.swift"]
            ),
            dependencies: [
                TargetDependency.project(
                    target: "EventTracking",
                    path: .relativeToRoot("Projects/Data/EventTracking")
                ),
                TargetDependency.project(
                    target: "Internal_TestingSupport_Framework",
                    path: .relativeToRoot("Projects/Data/Internal_TestingSupport_Framework")
                )
            ],
            settings: .settings(
                base: [
                    "DEVELOPMENT_ASSET_PATHS" : [""]
                ],
                configurations: [],
                defaultSettings: .recommended
            )
        )
        
    ],
    additionalFiles: [],
    resourceSynthesizers: [
        .assets(),
        .files(extensions: ["json"]),
    ]
)

任何人都可以解释一下我做错了什么以及如何使我的 EventTracking 子模块可以使用自定义配置进行测试 谢谢

ios swift xcode fastlane tuist
1个回答
0
投票

我在这里注意到的主要问题是

EventTracking
目标与
EventTrackingTests
目标位于同一项目中。 您是否尝试过将其(从
EventTrackingTests
目标)消耗为:

.target("EventTracking")

而不是

 TargetDependency.project(
   target: "EventTracking",
   path: .relativeToRoot("Projects/Data/EventTracking")
),
© www.soinside.com 2019 - 2024. All rights reserved.