我正在做一个用Cocoapods构建的遗留项目。
我们正试图找到一种方法来迭代更新项目以使用SPM,而不必对整个项目进行“大爆炸”式的更改。
Podfile定义了多个“目标”,这些目标都添加到
.xcworkspace
作为单独的“子项目”。
我们有一个“根”项目,它是主要的应用程序项目。
我添加了一个Package.swift文件,它有一个非常简单的配置,比如。。。
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "My-App",
platforms: [.iOS(.v13)],
products: [
.library(name: "MyFeature", targets: ["MyFeature"]),
],
dependencies: [
],
targets: [
.target(name: "MyFeature"),
]
)
这与我之前提到的“根”项目是一致的。
到目前为止,这一切看起来都应该起作用。SPM模块在一些子项目中使用,但我可以通过在子项目的框架/库中添加“MyFeature”模块来实现这一点。
然而新的SPM模块使用在其他子项目/内部茧之一中定义的类型。
Xcode似乎找不到导入它的框架,即使它是自动完成的,并且可以在“常规”项目代码中导入。
目录结构类似于。。。
Root Dir
-> Package.swift
-> MainApp Dir
-> MyApp.xcworkspace
-> MyApp Dir
-> MyApp.xcodeproj <- this is the "main app" target
-> OtherFeature Dir
-> OtherFeature.xcodeproj <- this is the "internal cocoapod" target I want to import
-> OtherFeature Dir
-> other feature code
-> Sources Dir
-> MyFeature Dir
-> my feature code... <- this is where the `import OtherFeature` doesn't work
我在网上找到的大多数来源都使用SPM和Cocoapods来分发框架,但他们没有将Cocoapod与SPM一起使用,我想知道这是否可能。
如果没有额外的导入,看起来一切都应该正常。如果我能克服下一个障碍,我觉得我们已经解决了这个问题。
谢谢