254

I have incorporate SpatialIite into a Xcode project which uses a header file from Proj.4, just one header. Both are Xcode projects and have static targets.

I'm trying to migrate from git submodule to Cocoapods. Since static targets seems to be difficult to use with Cocoapods, I just want to have the project built in the usual way. I made podspec for Proj.4. After writing podfile for SpatialLite I got the warnings:

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

I read this issue but I'm pretty clueless to what the warnings mean and what can I do to fix it.

Additionally problem, when I open the workspace as well as opening SpatiaLite project alone, both are targeted to Mac OSX 64, when it is suppose to be an iOS project. My podfile does say "platform :ios".

Bista
  • 7,869
  • 3
  • 27
  • 55
huggie
  • 17,587
  • 27
  • 82
  • 139
  • 2020 - for anyone struggling with this annoying problem. It is really only caused by (Surprise! :) ) facebook. As explained HERE, https://firebase.google.com/docs/auth/ios/firebaseui **"If you prefer, you can add only the Auth component and the providers you want to use..."** once you eliminate the facebook option, there's no problem. :/ – Fattie May 16 '20 at 20:48

13 Answers13

579

This definitely works most of the time:

Go to your target Build Settings -> Other linker flags -> double click . Add $(inherited) to a new line.

If you have problem with "...target overrides the GCC_PREPROCESSOR_DEFINITIONS build setting defined in..." then you must add $(inherited) to your target Build Settings -> Preprocessor Macros

Idan
  • 9,880
  • 10
  • 47
  • 76
Ankish Jain
  • 11,305
  • 5
  • 36
  • 34
  • Does anyone know where actually the settings inherited from? – Junlynn Jan 08 '15 at 06:20
  • your projects has certain flags , another target such as POD dependencies has other flags. You might be using POD.xcworkspace to run . In that case the flags which your main project holds is not neglected , its inherited and used too. – Ankish Jain Jan 08 '15 at 10:24
  • 30
    I would extend this answer. If you have problem with "... target overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting defined in ..." then you must add $(inherited) to your target Build Settings -> Preprocessor Macros – Libor Zapletal Mar 08 '15 at 16:23
  • 1
    i suspect that "... target overrides the INSERT_YOUR_MISSING_DEFINITION..." then you must add $(inherited) to it. oddly though, my xcode was showing $(inherited) a bit faint as by default. i edited and simply retyped the same thing. error disappeared.. – joe Feb 09 '16 at 22:23
  • Do we need to re-install the pod afterwards? Now, I'm getting a linker error in Xcode -ld: library not found for -lEZAudio clang: error: linker command failed with exit code 1 (use -v to see invocation) – William GP Mar 04 '16 at 06:08
  • try reinstalling pod after added $(inherited) – Ankish Jain Mar 04 '16 at 11:49
  • You might have 4 settings in Other Linker flags for the project that is trying to use the Pods. These must all include $(inhereited). For me, there is Debug, and under Debug is Any Architecture | Any SDK. Same for Release. The Debug and Release for me were blank, but the subkeys had the $(inhereted) value. The easiest way to check is to make sure the top level does not say – Nick May 17 '16 at 21:30
  • 5
    @joe Still not working for me. I tried all these suggestions, but when I rerun pod install, the errors persist. I made the changes to both other linker flags and to preprocessor macros. In both cases, nothing shows until you double click on each of the lines in other linker flags and preprocessor macros. Then you can see that $(inherited) has been added. I tried deleting and readding. I tried closing and reopening xcode. Nothing fixes the error messages when I type in pod install. – JeffB6688 Sep 08 '17 at 14:58
  • 3
    @msmq It's been a long time now, but do you remember the workaround that you tried and got it working? `$(inherited)` is already there at the top line but it doesn't work for me :/ – Kostas Dimakis Aug 27 '19 at 21:57
  • @msmq Can you remove that line and add it again, then try pod install. Hope it works. – Ankish Jain Aug 29 '19 at 04:38
  • 1
    i have added it stil pod install throws the same error. – rohitwtbs Sep 16 '19 at 14:24
  • Difficult to debug without seeing it. – Ankish Jain Sep 17 '19 at 15:37
  • "Add $(inherited) to a new line.".. it's worked! thanks you – Uthen Apr 02 '20 at 18:40
79

There is a conflict between your build settings and the default build settings that Cocoapods wants. To see the Cocoapods build settings, view the .xcconfig file(s) in Pods/Target Support Files/Pods-${PROJECTNAME}/ in your project. For me this file contains:

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

If you are happy with the Cocoapods settings, then go to Build Settings for your project, find the appropriate setting and hit the Delete key. This will use the setting from Cocoapods.

On the other hand, if you have a custom setting that you need to use, then add $(inherited) to that setting.

jscs
  • 63,694
  • 13
  • 151
  • 195
phatmann
  • 18,161
  • 7
  • 61
  • 51
  • I had this problem as well, I was able to remove the -ObjC and that fixed this problem. However, when I attempted to build the project, I get an error suggesting that the target specific pod library can not be found: "ld: library not found for -lPods-MyProject". Did you see something similar? – Roderic Campbell Nov 01 '13 at 23:42
  • 3
    I'm run into this again. I'm not sure $(inherited) means. Where do I add it? – huggie Nov 03 '13 at 15:54
  • @RodericCampbell I have found that removing -ObjC from the project works fine for me and I don't see your error. – huggie Nov 04 '13 at 02:04
  • 1
    Hmm, but I need the -ObjC flag for it at runtime since I got categories. – huggie Nov 04 '13 at 09:03
  • Yes, I'd also probably run into issues with my categories in the frameworks. In the meantime I'm stuck not being able to figure out how to link this project. – Roderic Campbell Nov 04 '13 at 22:16
  • Do I have to do this after every 'pod update'? Because it seems that 'pod update' removes all my changes in Pods.xcconfig and it is not nice... – pawel.kalisz Aug 26 '14 at 08:53
  • @pawel.kalisz you should not be editing Pods.xcconfig. Instead, follow my instructions above and make changes to your project's settings. – phatmann Aug 27 '14 at 13:56
  • @phatmann, I have quite complicated workspace with additional projects, specific HEADER_SEARCH_PATHS and so on, which I can't easily change... – pawel.kalisz Aug 27 '14 at 18:35
  • One solution is to create an xcconfig for your own projects that overrides the Pod version. – phatmann Sep 02 '14 at 09:29
  • how do you find the 'appropriate setting' for deletion? It just says 'OTHER_LDFLAGS' without regard to what those might be. I tried deleting 'Other Linker Flags' from the build settings but it doesn't seem possible. If you mean to clear the entire 'Other Linker Flags' section out then that didn't work for me either. – kraftydevil Sep 27 '14 at 05:33
  • 3
    OTHER_LDFLAGS = Other Linked Flags, HEADER_SEARCH_PATHS = Header Search Paths, GCC_PREPROCESSOR_DEFINITIONS = Preprocessor Macros. @kraftydevil, what setting are you trying to delete? – phatmann Sep 29 '14 at 16:41
  • Had the same problem and this fixed it. deleting OTHER_LDFLAGS xcode change the row with the correct one! – ikanimo Mar 10 '17 at 16:04
32

I've seen these 3 errors for pod command in terminal

pod install

[!] The MY_APP [Debug/Release] target overrides the HEADER_SEARCH_PATHS ...
[!] The MY_APP [Debug/Release] target overrides the OTHER_LDFLAGS ...
[!] The MY_APP [Debug/Release] target overrides the GCC_PREPROCESSOR_DEFINITIONS ...

All these 3 errors would be gone by adding $(inherited) to

  1. Header Search Paths
  2. Other Linker Flags
  3. Preprocessor Macros

in Project -> Target -> Build Settings

And now the command would run without giving any errors

pod install
zeeawan
  • 6,667
  • 2
  • 50
  • 56
  • The above worked for me, when simply changing the flag for `Other Linker Flags` wasn't sufficient. – JaredH Sep 11 '15 at 23:23
23

Just had a similar issue when I ran pod install, I saw the following warnings/errors (related to CLANG_CXX_LIBRARY):

The Error/Warning from 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.

The Fix

  1. Select your Project so you can see the Build Settings.
  2. Select your Target (AppName under Targets)
  3. Find C++ Standard Library (It will probably be in BOLD - This means it's overridden).
  4. Select the Line (So it's highlighted Blue), and press ⌘ + DELETE (Command + Backspace)

The line should not be bolded anymore and if you run pod install the warnings/errors should have disappeared.


Visual Aid

CLANG_CXX_LIBRARY Error/Warning with Cocoapods

Anil
  • 21,730
  • 9
  • 73
  • 100
21

In your project, find Target -> Build Settings -> Other Linker Flags, select Other Linker Flags, press delete(Mac Keyboard)/Backspace(Normal keyboard) to recover the setting. It works for me.

Example:

Before enter image description here

After enter image description here

SamirChen
  • 1,209
  • 1
  • 12
  • 22
  • 1
    do we remove the settings already located in Other Linker Flags ? or do we keep them and also add $(inherited) ?? – isJulian00 Dec 11 '18 at 23:04
13

If Xcode complains while linking, e.g. Library not found for -lPods, it doesn't detect the implicit dependencies:

Go to Product > Edit Scheme Click on Build Add the Pods static library Clean and build again

Amit Saxena
  • 596
  • 7
  • 18
  • I tried the way you suggested, but its not showing the recent installed frameworks by pod file, any more suggestions to fix linker flag errors. @Amit Saxena – Anilkumar iOS - ReactNative Nov 03 '17 at 07:00
  • This worked for me when getting the same types of errors with the Pods for the cordova-plugin-facebook4 plugin in My Ionic 5/Cordova 9 app. I added all three of the Facebook frameworks, cleaned an presto! Works now on Xcode simulators but not yet on actual devices (I'm using an iPhone 6 with iOS 12.4.8 and Xcode 11.6). – Russ Aug 06 '20 at 05:37
13

For me the problem was with my targets tests. I already had the $(inherited) flag in my main app target.

I added it to MyAppTests Other Linker flags. After that when I ran pod install the warning message was gone. enter image description here

Andreas Olsson
  • 347
  • 4
  • 11
6

The first line of link below saved my day:

To add values to options from your project’s build settings, prepend the value list with $(inherited).

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

Also, do not forget to insert this line at the beginning of your pod file:

platform :iOS, '5.0'
newenglander
  • 2,019
  • 24
  • 55
Nikolay Shubenkov
  • 3,133
  • 1
  • 29
  • 31
  • in my case this saves my day : do not forget to insert this line at the beginning of your pod file: platform :iOS, '5.0' – Amer Alzibak Jul 14 '20 at 15:11
6

I added $(inherited) but my project was still not compiling. For me problem was flag "Build for active Architecture only", I had to set it to YES.

sanjana
  • 3,034
  • 2
  • 25
  • 31
2

Xcode Screenshot

Xcode Screenshot

Ankish Jain had the answer that worked for me. Here is a screenshot of what to do, as it took me a little bit to find out what exactly to do.

In my case i needed to add $(inherited) to my 'Other Linker Flags' because that is what showed up as Overriding in terminal.

udi
  • 3,672
  • 2
  • 12
  • 33
0

do not forget to insert (or unCommanet) this line at the beginning of your pod file:

platform :iOS, '9.0'

that saves my day

Amer Alzibak
  • 1,489
  • 15
  • 16
0

This happens to me every time I add a pod to the podfile.

I constantly try and find the problem but I just go round in circles again and again!

The error messages range, however the way to fix it is the same every time!

Comment out(#) ALL of the pods in the podfile and run pod install in terminal.

Then...

Uncomment out all of the pods in the podfile and run pod install again.

This has worked for me every single time!

daj mi spokój
  • 248
  • 1
  • 2
  • 8
0

When I added the $(inherited) flag to the file in question (in this case it was LIBRARY_SEARCH_PATHS) it led to another error Undefined symbols for architecture arm64: "_swift_getTypeByMangledNameInContextInMetadataState

Changing the following worked and I was able to build:

>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)\"",
> );
NathanNovak
  • 105
  • 1
  • 4