ios 如何在Xcode扩展目标中访问swift包?

mccptt67  于 2023-03-09  发布在  iOS
关注(0)|答案(1)|浏览(155)

我创建了一个swift包CommonPackage,其中包含两个目标所共有的文件。

  • 主应用程序
  • MainApp的Safari扩展目标

现在,我在两个目标的Frameworks,Libraries部分添加了这个包,我可以在主应用目标中使用这个包,但是当我在Safari Extension target中导入这个包时,它给我提供了
No such module CommonPackage错误。
该包文件非常通用:

let package = Package(
    name: "CommonPackage",
    platforms: [
      .iOS(.v14)
    ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "CommonPackage",
            targets: ["CommonPackage"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "CommonPackage",
            dependencies: []),
        .testTarget(
            name: "CommonPackage Tests",
            dependencies: ["CommonPackage"]),
    ]
)

不知道为什么我不能在safari扩展目标中使用这个包。
我错过了什么关键步骤吗?

mzsu5hc0

mzsu5hc01#

我的扩展目标CONFIG_BUILD_DIR似乎设置为build,当我将其更改为$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)时,我能够成功地构建。

相关问题