![](/img/trans.png)
[英]XCode 6 CocoaPods error : target overrides the `OTHER_LDFLAGS` build setting
[英]The target ... overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig
我已將SpatialIite
合並到一個 Xcode 項目中,該項目使用來自Proj.4
的頭文件,只有一個頭文件。 兩者都是 Xcode 項目並具有靜態目標。
我正在嘗試從 git 子模塊遷移到 Cocoapods。 由於靜態目標似乎很難與 Cocoapods 一起使用,我只想以通常的方式構建項目。 我為 Proj.4 制作了Proj.4
。 在為SpatialLite
編寫 podfile 后,我收到了警告:
[!] The target `SpatialiteIOS [Debug]` overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The target `SpatialiteIOS [Debug]` overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The target `SpatialiteIOS [Debug - Release]` overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The target `SpatialiteIOS [Debug - Release]` overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
我讀過這個問題,但我對警告的含義以及如何修復它一無所知。
另外的問題是,當我打開工作區以及單獨打開 SpatiaLite 項目時,兩者都針對 Mac OSX 64,而它應該是一個 iOS 項目。 我的播客文件確實說“platform:ios”。
這在大多數情況下肯定有效:
轉到您的目標構建設置 -> 其他鏈接器標志 -> 雙擊 . 將$(inherited)
添加到新行。
如果您對“...目標覆蓋在...中定義的 GCC_PREPROCESSOR_DEFINITIONS 構建設置有問題”,那么您必須將 $(inherited) 添加到您的目標構建設置 -> 預處理器宏
您的構建設置與 Cocoapods 想要的默認構建設置之間存在沖突。 要查看 Cocoapods 構建設置,請查看項目中 Pods/Target Support Files/Pods-${PROJECTNAME}/ 中的 .xcconfig 文件。 對我來說,這個文件包含:
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/Commando"
OTHER_LDFLAGS = -ObjC -framework Foundation -framework QuartzCore -framework UIKit
PODS_ROOT = ${SRCROOT}/Pods
如果您對 Cocoapods 設置感到滿意,請轉到項目的 Build Settings,找到適當的設置並按 Delete 鍵。 這將使用 Cocoapods 的設置。
另一方面,如果您有需要使用的自定義設置,則將 $(inherited) 添加到該設置中。
我在終端中看到了 pod 命令的這 3 個錯誤
pod install
[!] MY_APP [Debug/Release] 目標覆蓋 HEADER_SEARCH_PATHS ...
[!] MY_APP [Debug/Release] 目標覆蓋了 OTHER_LDFLAGS ...
[!] MY_APP [Debug/Release] 目標覆蓋 GCC_PREPROCESSOR_DEFINITIONS ...
通過將$(inherited)添加到,所有這 3 個錯誤都將消失
在項目 -> 目標 -> 構建設置中
現在該命令將運行而不會出現任何錯誤
pod install
當我運行pod install
時遇到了類似的問題,我看到了以下警告/錯誤(與CLANG_CXX_LIBRARY
相關):
[!] The `Project [Debug]` target overrides the `CLANG_CXX_LIBRARY` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Project [Release]` target overrides the `CLANG_CXX_LIBRARY` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
Project
以便您可以看到Build Settings
。Target
( Targets
下的AppName
)C++ Standard Library
(它可能會以粗體顯示- 這意味着它已被覆蓋)。 該行不應再加粗,如果您運行pod install
警告/錯誤應該已經消失。
在您的項目中,找到Target -> Build Settings -> Other Linker Flags
,選擇Other Linker Flags
,按delete
(Mac Keyboard)/ Backspace
(Normal keyboard) 恢復設置。 這個對我有用。
例子:
前
后
如果 Xcode 在鏈接時抱怨,例如未找到 -lPods 的庫,它不會檢測隱式依賴項:
轉到 Product > Edit Scheme 單擊 Build 添加 Pods 靜態庫 Clean 並再次構建
下面的第一行鏈接拯救了我的一天:
要將值添加到項目構建設置中的選項,請在值列表前加上 $(inherited)。
https://github.com/CocoaPods/CocoaPods/wiki/Creating-a-project-that-uses-CocoaPods#faq
另外,不要忘記在 pod 文件的開頭插入這一行:
platform :iOS, '5.0'
我添加了 $(inherited) 但我的項目仍然沒有編譯。 對我來說,問題是標記“僅針對活動架構構建”,我必須將其設置為 YES。
不要忘記在 pod 文件的開頭插入(或取消Commanet)這一行:
platform :iOS, '9.0'
這節省了我的一天
每次我向 podfile 添加一個 pod 時都會發生這種情況。
我不斷嘗試找出問題所在,但我只是一次又一次地兜圈子!
錯誤消息范圍很廣,但是每次修復它的方法都是一樣的!
將 podfile 中的所有 pod 注釋掉 (#) 並在終端中運行 pod install。
然后...
取消 podfile 中所有 pod 的注釋,然后再次運行 pod install。
這每次都對我有用!
當我將 $(inherited) 標志添加到有問題的文件(在本例中為 LIBRARY_SEARCH_PATHS)時,它導致了另一個錯誤Undefined symbols for architecture arm64: "_swift_getTypeByMangledNameInContextInMetadataState
更改以下內容有效,我能夠構建:
>LIBRARY_SEARCH_PATHS = (
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
- "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", <--- Change this...
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.2/$(PLATFORM_NAME)\"", <--- to this
"\"$(inherited)\"",
> );
Xcode 截圖
Ankish Jain 給出了對我有用的答案。 這是該做什么的屏幕截圖,因為我花了一點時間才弄清楚到底該做什么。
在我的例子中,我需要將 $(inherited) 添加到我的“其他鏈接器標志”中,因為這就是在終端中顯示為 Overriding 的內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.