【发布时间】:2015-08-20 16:14:50
【问题描述】:
我想创建一个仅包含其他公司开放平台提供的框架和bundle资源的pod。但是我遇到了一些问题。
在 Objective-C 项目中
第一次,我只是创建了一个 podspec 文件,它只包含使用 s.ios.vendored_frameworks 和捆绑资源的框架。并且当我运行 pod spec lint 时它通过了验证。然后我将它导入到一个目标中podfie中的-C项目,当我运行pod install时它可以工作,我可以使用#import <xxx/xxx.h>将框架导入我的代码
但我发现在xcworkspace项目文件中,它自动生成了一个scheme,如上图。生成的scheme似乎是mac的目标。 称之为情况 A
如果我在 pod 中添加一个名为 Version.h 和 Version.m 的自定义新类,并使用 s.source_files = "Classes", "Version/*.{h,m}" 更新 podspec 文件,那么当我运行 pod install 时,它会生成一个静态库,这是我想要什么以及我认为应该的结果。 称之为情况 B
所以问题是:
当我没有包含任何自定义类文件时,为什么 pod 会为 mac 生成方案,这有关系吗?
当我包含自定义类时,为什么 pod 会生成静态库?
在swift项目中
第二部分是我还需要将 pod 导入 swift 项目。我也遇到了类似的问题。
此时,在podfie中我使用了use_frameworks!关键字。
情况 A:我无法导入框架,没有这样的模块 xxx,编译器出错。
情况 B:无法构建 Objective-C moulde xxx,编译器出错,我尝试清理并删除 DerivedData 目录,但没有成功。而且它不会生成modulemap和xx-umbrella.h文件。我在使用google ad sdk时发现了同样的问题
pod 'Google-Mobile-Ads-SDK', "~> 7.4.0"
在情况 A 中,当 pod 生成 pods 项目时,它不会从我的 pod 安装目标。在情况 B 中,它从我的 pod 安装目标。像下面的来自 pod 的日志
//situation b
- Creating Pods project
- Adding source files to Pods project
- Adding frameworks to Pods project
- Adding libraries to Pods project
- Adding resources to Pods project
- Linking headers
- Installing targets
- Installing target `AliPay` iOS 8.0
//situation a
- Creating Pods project
- Adding source files to Pods project
- Adding frameworks to Pods project
- Adding libraries to Pods project
- Adding resources to Pods project
- Linking headers
- Installing targets
- Installing target `Pods-NewCategory` iOS 8.0
- Generating Info.plist file at `Pods/Target Support
Files/Pods-NewCategory/Info.plist`
- Generating module map file at `Pods/Target Support
Files/Pods-NewCategory/Pods-NewCategory.modulemap`
- Generating umbrella header at `Pods/Target Support
Files/Pods-NewCategory/Pods-NewCategory-umbrella.h`
- Running post install hooks
- 那么为什么 pod 不能与 swift 项目一起使用,我是使用 pod 做一些事情还是因为框架。
我在github 上创建的 pod,在情况 A 上创建的标签 0.0.1,在情况 B 上创建的标签 0.0.2。
【问题讨论】:
-
解决了您的问题吗?
-
@Loegic 感谢您的回答。当我将这些 pod 用作我的项目的本地 pod(项目内的 pod 规范文件)时,objective-c 项目中的情况 A 解决了。但是情况B还是没有解决。
-
你做了我写的所有改变吗?你现在有什么问题?