目标……重写“Pods/Pods.xcconfig”中定义的“OTHER_LDFLAGS”构建设置

我已经将SpatialIite合并到一个Xcode项目中,该项目使用来自Proj.4的头文件,只有一个头文件。两者都是Xcode项目,都有静态目标。

我试图从git子模块迁移到Cocoapods。由于静态目标似乎很难与Cocoapods一起使用,我只想以通常的方式构建项目。我为Proj.4做了podspec。在为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项目。我的播客文件上写着“平台:ios”。

147853 次浏览

您的构建设置和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)。

下面的第一行链接拯救了我:

要向项目构建设置中的选项添加值,请在值列表前面加上$(inherited)。

https://github.com/CocoaPods/CocoaPods/wiki/Creating-a-project-that-uses-CocoaPods#faq

另外,不要忘记在pod文件的开头插入这一行:

platform :iOS, '5.0'

如果Xcode在链接时报错,例如Library not found for -lPods,它不会检测隐式依赖:

去产品>编辑计划 点击构建 添加Pods静态库 清理并再次构建

这在大多数情况下都是有效的:

转到你的目标构建设置->其他链接标志->双击。将$(inherited)添加到新行。

如果你对“…目标覆盖GCC_PREPROCESSOR_DEFINITIONS构建设置定义在…"然后你必须添加$(继承)到你的目标构建设置->预处理器宏

在你的项目中,找到Target -> Build Settings -> Other Linker Flags,选择Other Linker Flags,按delete(Mac键盘)/Backspace(普通键盘)来恢复设置。这对我很管用。

例子:

< p >之前 enter image description here

< p >后 enter image description here

当我运行pod install时也有类似的问题,我看到了以下警告/错误(与CLANG_CXX_LIBRARY有关):

Cocoapods的错误/警告

[!] 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.

修复

  1. 选择你的Project,这样你就可以看到Build Settings
  2. 选择你的Target (Targets下的AppName)
  3. 找到C++ Standard Library(它可能在大胆的中-这意味着它被覆盖)。
  4. 选择行(所以它是突出显示的蓝色),并按⌘+删除 (Command + Backspace)

该行不应该再加粗,如果你运行pod install,警告/错误应该已经消失。


视觉教具

CLANG_CXX_LIBRARY Error/Warning with Cocoapods

我在终端中看到了这3个pod命令错误

pod install
< p > [!MY_APP [Debug/Release]目标覆盖 HEADER_SEARCH_PATHS…< br > [!MY_APP [Debug/Release]目标 覆盖OTHER_LDFLAGS…
[!MY_APP [Debug/Release]目标 覆盖GCC_PREPROCESSOR_DEFINITIONS…

$(继承)添加到

  1. 页眉搜索路径
  2. 其他链接标志
  3. 预处理器宏

项目->目标->构建设置

现在该命令将运行而不会出现任何错误

pod install

我添加了$(inherited),但我的项目仍然没有编译。对我来说,问题是标记“仅为活动架构构建”,我必须将其设置为YES。

对我来说问题出在我的目标测试上。我已经在我的主应用程序目标中有$(inherited)标志。

我把它添加到MyAppTests其他链接标志。之后,当我运行pod install时,警告信息消失了。 enter image description here < / p >

不要忘记在pod文件的开头插入(或取消命令)这一行:

platform :iOS, '9.0'

这救了我

每当我向podfile中添加一个pod时,都会发生这种情况。

我一直在试着找出问题所在,但我只是一次又一次地在兜圈子!

错误消息范围,但是每次修复的方法都是相同的!

注释掉(#)podfile中的所有pod,并在终端中运行pod install。

然后……

取消pod文件中的所有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)\"",
> );