Suppress linker warning for 3rd party framework - objective-c

The Microsoft SDK for Azure Storage causes a bunch of linker errors a la
ld: warning: instance method 'AZSULLRangeValue' in category from /Users/macHack/Library/Developer/Xcode/DerivedData/PROJECT-gpihzjouhxvifqcslmywktktizer/Build/Intermediates.noindex/AZSClient.build/Debug/AZS_Mac.build/Objects-normal-asan-ubsan/x86_64/AZSCloudAppendBlob.o conflicts with same method from another category
Is there a way to suppress just the conflicts with same method from another category linker warning?
It's easy to find a list of flags for each clang warning to turn it off on a per-file basis, however I was unable to locate a similar list for linker warnings?
Obviously the idea is to disable the warning as specifically and as locally as possible and retain other warnings for the project.
Any hints appreciated!

Related

What are AUTHOR_WARNING messages in cmake?

CMake's message() directive has an AUTHOR_WARNING mode, however the documentation (v3.11.1) doesn't say anything on what the differences are between an AUTHOR_WARNING and a regular WARNING.
The documentation states these modes and their description as follows:
WARNING = CMake Warning, continue processing
AUTHOR_WARNING = CMake Warning (dev), continue processing
Author warning are meant to warn the author (developer) of a CMakeLists.txt, but not a user of it. With the CMake arguments -Wdev, -Wno-dev, and -Werror=dev you have control over how to these warnings are handled (documentation).
The idea is that users should not be scared or annoyed by warnings they cannot change anyway, because they are not supposed to modify this part (of potentially third-party) code. This includes programmers who include CMake code from others and don't want to warned about issues they cannot fix within their code.
Since CMake 3.5, the dev flags also suppress or enable deprecation warnings, following the spirit of warning only people who can fix the underlying issues.

Objective C Linker Error: Undefined Symbols

What does it mean to have undefined symbols?
There are no errors in the code files themselves and I am NOT using any external libraries.
I DID add a typedef NS_ENUM prior to this linker error occurring.
Where do I add this -v to see invocation?
Here is the error message:
Undefined symbols for architecture x86_64:
"_OBJC_IVAR_$_UIViewController._parentViewController", referenced from:
-[PEPI_LessonController setParentViewController:] in PEPI_LessonController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"Undefined Symbols"
Building source code files to an executable file consist of at least two steps:
Compile the source code files to intermediate binary files (often called xyz.o).
Link the intermediate binary files to the final executable file.
The error message "undefined symbols" is a linker message. It may appear even though the compilation process was successful without notice. The linker organizes final memory address relations and it replaces symbols that the compiler had to assume they would be valid later, if all parts of the code would be available. Without this, no modularization would be possible at all.
-v to see invocation
If you build your application in Xcode, then Xcode calls all the compile and link commands for you (CompileC, Ln, Clang ...). But remember that a typical IDE runs only the commands you could run by yourself in the shell. Theoretically, you could develop big applications only in a text editor and a shell. So I suggest take some time and try to copy paste some commands listed in the Xcode build report to a shell :-) You'll learn a lot about the backgrounds. Therefore, in my opinion, -v to see invocation is used while invoking the command in the shell - or in the build settings, if you wish permanently more information.
"External libraries"
Finally, try to clarify "external libraries". To look at the most simple example: even if you write a simple C program and you want to know something trivial like the length of a string, you'll include <glibc.h>. Now this is an external library. It's external to your program code. Are you sure you haven't included external libraries?
Solving linker problems
Linker errors are often confusing and somehow difficult, because details of the linked modules tend to be out of sight. You may find many hints if you enter the error message in a search engine. For example, have a look at here:
Undefined symbols for architecture armv7: "_SCNetworkReachabilityCreateWithAddress"
Even if all components are found for linking, all paths are known etc, they may have the wrong version or else.
It means it can't find the property parentViewController and method setParentViewController when linking your object files files. The most common cause for these types of errors is not linking a library or framework in your projects target. UIViewController is part of UIKit so I'd be surprised if it's not already linked. Is this an OSX project and your trying to use UIViewcontroller instead of NSViewController?
In my case I had forgotten to add the .m file to all the same targets as the .h and that's what caused this issue. In case it helps anyone thought I'd mention here... double check your target memberships!

Linker error when trying to use SmartfoxServer-framework with a Kobold-2D project

When trying to use the SmartfoxServer-framework inside a Kobold2d project we are getting the following error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CCAsyncObject", referenced from:
objc-class-ref in libcocos2d-extensions-ios.a(CCTextureCache+CCBigImageExtensions.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1
This happends due to the fact, that we have to include the -ObjC linker flag to have the categories loaded, which are defined in the SmartfoxServer-framework. I already read about the need to force-link a static library which contains categories here, but the SmartFoxServer-Framework isn't a static library.
Is there a way to force load a framework, so it includes all the categories without using the -ObjC linker flag? Or is there a convenient way to convert a framework to a static library? Any help is greatly appreciated!
Unless you are using CCBigImage, you can deselect the CCTextureCache+CCBigImageExtensions.h and .m files from the target.
Open the Kobold2D-Libraries project and browse to the group /Extensions/CCBigImage. From the menu choose View -> Utilities -> File Inspector. Select each file and uncheck the target checkbox in File Inspector. Now this particular class won't be compiled anymore and the error is gone.
The problem seems to be that this category uses a private class that's defined only in the implementation file. Unfortunately force loading the entire cocos2d-iphone-extensions project is not a solution because this brings up other errors.

Why am I getting "_OBJC_CLASS_$..., referenced from:" linker error when I have correctly linked frameworks?

My Problem
I getting "_OBJC_CLASS_$..., referenced from:" linker error when compiling some Xcode projects (it happens in both iOS and Mac projects) I have correctly linked frameworks and imports.
Setup
One application target
One test target
All frameworks linked correctly
On compile I get the following linker errors:
"_OBJC_CLASS_$_JGCountdownTimer", referenced from:
objc-class-ref in JGCountdownTimerTestCase.o
for many classes that are used in tests.
What I've Tried
Checked that imports are all present
Removed all non standard frameworks
If I compile a class for both the test target and the app target it fixes the issue. But then I get other warnings from the compiler.
I faced a similar problem. I got the linker error:
_OBJC_CLASS_$_MyClass
The problem was that I had declared an #interface for MyClass but had not declared its corresponding #implementation.
The fix was to simply add
#implementation MyClass
#end
Quick Answer
Copy and paste the following line into your build settings:
GCC_SYMBOLS_PRIVATE_EXTERN = NO
In the target build settings look for "Symbols Hidden by Default". For the Debug configuration you want "No".
I've had this problem on and off for many months and I've just discovered why.
Not sure if this could be the problem, but with the new compiler, any obj-c that aren't explicitly referred to/invoked will not be linked from libraries. This causes problems when you implement categories in libraries for example.
Try adding '-ObjC' to 'additional linker flags' in the build settings panel for your target. shrug
objc_class_$textfieldvalidator referenced from
Compile doesn't include those copied files in its compile list. To fix this error
select the file or folder, then go to the Build Phases panel and open the Compile Sources step, then click the + button and add them all file or folder.
Right click on a project folder, click "Add Files to ...", select the file(s), click the Options button and select the target, then click Add.

How do I disable warnings being flagged as errors in Xcode

Is there a setting Xcode that lets you treat warnings NOT as errors in Xcode? I'm doing a lot of prototyping code where I don't care if I have an unused variable for example. Xcode is treating these warnings as errors and it is seriously slowing down my productivity. Can't figure out how to disable this though.
In the build settings of your target there's an option named Treat Warnings as Errors. If it is on in your project, turn it off (even though this is the default).
If you open your project in Xcode, then right click on your target in the Targets folder. Select "Get Info" form the drop down menu and then scroll down to the section for the compiler warnings (GCC 4.0 Warnings on my box). Here you can disable the checkboxes for the various warnings you have active. Also check the value of "Other Warning Flags". This could include -Wall or -WMost which will enable other warnings. You can remove that and hopefully your warnings will not appear.
Good luck!
In your Xcode project Build Settings, search for the flag 'Treat Warnings as Errors' and set it to NO. As the name suggests, if you set it to YES, warnings in that project are counted as Errors.
If you have multiple sub projects, this flag can be toggled for each individual project.
Here is a screenshot from Xcode 13.2.1
Xcode 13.2.1 Treat Warnings as Errors
I was getting a specific warning being shown as an error in my specific workspace, The above solutions didn't work for me.
Then I dug deeper in "Build settings", as I suspected there was "Apple Clang -Warnings - All Languages" where that specified warning was being marked to be shown as error .
I had to change it to yes(Error) to yes.