在已有的工程中沒有使用 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會不會出現類似的問題