在已有的工程中没有使用 pod, 新建一个demo手动导入protobuf时报错GPB文件找不到,直接使用pod导入没有出现类似错误,所以就在项目工程中引入pod去集成protobuf
platform :ios, '8.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
target 'Project' do
pod 'Protobuf'
end
直接运行 pod install 安装成功,出现了 感叹号❗️,并且编译工程失败,framework not found Protobuf
[!] The `CarShare [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-CarShare/Pods-CarShare.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `CarShare [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-CarShare/Pods-CarShare.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
尝试消除 感叹号❗️
- Target - > building settings中搜索 “ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES”,值类型是bool,点击other,把值换成 $(inherited) 之后 运行 pod update / pod install 依然出现 感叹号❗️
- 在Build Setting中的Search Path下的Framework Search Paths与Header Search Paths中添加
$(inherited)
。 工程里已经是了 - 在Build Setting中的Linking下的Other Linker Flags下也要添加
$(inherited) ----感叹号
❗️就此消失,但是工程还是编译失败 framework not found Protobuf
然后解决 framework not found的问题。搜到了一些方法
- Target->BuildSetting->Library Search Path添加以
$(PROJECT_DIR)/
开始的相对路径 - Other Linker Flag发现多余的头文件并删除
- 在product-》edit scheme中-》build里面添加pods的所有的库
- 删除pod的四个文件,重新创建
- 在cocoapods的官网Troubleshooting找解决办法
- 更改pods-》project-》architectures-》build active architecture only都为NO,
1.使用相对路径无效;2.Other Linker Flag里没有多余的文件;3.在scheme中添加pods的库没有尝试;4.删除pod重新添加无效;5. 6.解决问题。
之后我把项目回滚到引入 pod之前,然后pod install,依然会出现感叹号❗️ 但工程编译成功,跑了一遍流程,没任何问题,好吧pod给我开了一个玩笑, 在 other linker flags 下添加 $(inherited) 消除 感叹号
❗️,pod有时候就爱开玩笑,回头尝试一下
Carthage会不会出现类似的问题