ChenYilong / ChenYilong/iOSBlog

记一次 CocoaPods 配置错误:新创建Lib,用户手动集成可以,但 CocoaPods 不行

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
note
Dominant language
Objective-C
Stars
1.1k
Forks
184
PR merge metrics
No merged PRs in 30d

Description

我创建了一个Lib,同时支持手动集成和CocoaPods,但是集成者发现手动集成可以,但是 CocoaPods 不行。最后找到了原因。

对比 | 旧 | 新
-------------|-------------|-------------
目录结构 | ![enter image description here](https://ws4.sinaimg.cn/large/006tNbRwly1ffv5ob64lij30eg0tyq3s.jpg)| ![enter image description here](https://ws3.sinaimg.cn/large/006tNbRwly1ffv5obi6tbj30ea0ue3zi.jpg)
spec写法 | 将 bundle 文件写在了 s.vendored_frameworks | 将 bundle 文件写在 s.resources 下
分析 | 旧的目录结构是这种,会报错误:Apple Mach-O Linker Error Group: Linker command failed with exit code 1 (use -v to see invocation)![enter image description here](https://ws2.sinaimg.cn/large/006tNbRwgy1ffv60sd0o8j306m027aa9.jpg) | 新的结构不会报错
错误原因 | 错误地将bundle文件作为了framework文件,你可以打开[cp]Copy Pods Resources 里面的对应的sh文件,发现是空的![enter image description here](https://ws4.sinaimg.cn/large/006tNbRwgy1ffv5tpnmmqj31kw113wfu.jpg) |而这样的结构,对应sh文件非空,负责把bundle文件作为资源倒入到项目中。

![all-reward](https://ws2.sinaimg.cn/large/006tKfTcly1fnhitzq3yhj30i80cj0uj.jpg)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.