一)
具體方法在
iOS 如何在一個存在多個project的workspace中引入cocoapods管理第三方類庫
二)Question && Solution
Cocoapods 版本1.0.1
我在按上述鏈接轉換的時候,遇到的問題:
1,
[!] `xcodeproj` was renamed to `project`. Please update your Podfile accordingly.
Solution:
xcodeproj 'MyProj/MyProj.xcodeproj'
just replace xcodeproj to project
project 'MyProj/MyProj.xcodeproj'
2,eg:
[!] The `Ecosphere [Debug]` target overrides the `HEADER_SEARCH_PATHS` build setting defined in `../Pods/Target Support Files/Pods-Ecosphere/Pods-Ecosphere.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Ecosphere [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `../Pods/Target Support Files/Pods-Ecosphere/Pods-Ecosphere.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
......
這種警告是不能忽視的,它帶來的直接后果就是無法通過編譯。
而產生此警告的原因是項目 Target 中的一些設置,CocoaPods 也做了默認的設置,如果兩個設置結果不一致,就會造成問題。
我想要使用 CocoaPods 中的設置,分別在我的項目中定義`PODS_ROOT` 和 `Other Linker Flags`的地方,把他們的值用`$(inherited)`替換掉,
進入終端,執行 pod update
警告沒了,回到 Xcode,build通過。
網上還流行另外一種簡單粗暴的方法
點擊項目文件 project.xcodeproj,右鍵`顯示包內容`,用文本編輯器打開`project.pbxproj`,刪除`OTHER_LDFLAGS`的地方,保存,回到 Xcode,編譯通過。
因為我的工程已經對 "HEADER_SEARCH_PATHS" 和"OTHER_LDFLAGS"做過配置,
所以 在對應的工程Build Settings中對應的地方填上:
$(inherited) ,解決;
3,
在使用cocospods的時候,如果修改了導入的第三方庫源文件,那么當使用pod update的時候修改的代碼會被作者的原文件覆蓋掉。
所以問題來了,遇到確實需要修改源代碼的時候,解決方案
1. 不用cocoapods改用手動導入第三方庫
2. 將需要修改的第三方庫fork一份到自己的github,在里面做完修改之后,將podfile修改為:
platform :ios, '7.0'
pod '要導入的庫', :git => 'https://github.com/我的github/要導入的庫'
前言:
一種新的第三方庫管理工具:Carthage
如何使用Carthage管理iOS依賴庫
Podfile Syntax Reference v1.1.0.rc.3
https://guides.cocoapods.org/syntax/podfile.html