duplicate symbol in Pods (Flipper) and external libraries - xcode

I know there are tons of questions regarding this issue, but i didn't come up with solution.
We have in my project (react-native) a static library: let's call it externalLib_v1.1r.a that we added manually to my project. It always worked fine. It's a security library and we have no access to the source code.
With the new version of Flipper, that comes with latest versions of react-native, i have the following issue when building with Xcode:
duplicate symbol 'fileExists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)' in:
/Users/myuser/project/myproject/ios/externalLib_v1.1r.a(utility.o)
/Users/myuser/Library/Developer/Xcode/DerivedData/proj-duwrxsmkbkccvdfykaajqslcqijq/Build/Products/Debug-iphonesimulator/Flipper/libFlipper.a(ConnectionContextStore.o)
ld: 1 duplicate symbol for architecture x86_64
There are 2 methods (1 inside externalLib_v1.1r.a and 1 inside ConnectionContextStore.cpp (Flipper)) with the same name.
If i manually rename the fileExists method inside the Flipper Pod it all works...
Is there a way to avoid this workaround?
Note: I have the -ObjC flag in "Other Linker Flags" of my project.

Related

xcode 10.1 Undefined symbols for architecture arm64

I already gone so many SO threads with similar issue but none of them seems to resolve my error.
In our project we have multiple "TARGETS". Only one of the target - the very first target created ever - is archiving properly. When I try to archive other target we encounter this error
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_DynamicEventData", referenced from:
objc-class-ref in DataManager.o
objc-class-ref in DataReader.o
"_OBJC_CLASS_$_DynamicDataService", referenced from:
objc-class-ref in DataManager.o
"_OBJC_CLASS_$_DynamicDataConfig", referenced from:
objc-class-ref in DataManager.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I did compare the Build Setting of the working target to the other targets but all of them are equal. I checked the header files and they exists in our project directory. I tried to manually add the header files' path to Header Search Paths but same result still getting the error.
Any idea? I really need to resolve this to export an ipa file.
Thanks!
I scan manually check the Build Phases > Link Binary With Libraries of the working target vs the defected targets. I found a one framework/library that was only added to the working target the said framework isn't manage by pod that may explain why the other target doesn't have it. I think it was added manually in the project.
I add the said framework to all targets and now I can build without the said error.
Thanks!
I encountered the same problem and the solution I found is so simple (man....).
Search in the project for the classes that are mentioned in the error.
Go to the "File Inspector" and simply check V for the rest of the targets in the "Targets Membership".
That's it! It took me Two Hours (wasted time) to find out.
Hope my solution will save time for anyone with similar problem.

linking std::experimental::filesystem with Xcode 9

I am using std::experimental::filesystem with Xcode 9.0 beta. The compiler phase completes OK but the linker complains of undefined symbols:
std::experimental::filesystem::v1::path::__filename() const
std::experimental::filesystem::v1::path::__filename() const
std::experimental::filesystem::v1::path::__stem() const
std::experimental::filesystem::v1::__status(std::experimental::filesystem::v1::path const&, std::__1::error_code*)
I am also using std::experimental::filesystem::canonical(), but the linker isn't complaining about that being missing.
How can I configure the project to include these missing references?
UPDATE:
I have been experimenting with a simpler program. If I just use canonical() then the linker complains that it is missing.
I can use std::experimental::optional - everything compiles, links and runs OK. But 'optional' is a template and so probably doesn't involve a library.
Are you compiling with any -std= option ("C++ Language Dialect" option in Xcode)?

OpenCV undefined error in Xcode

I am working on an OpenCV-based project on Xcode 5.02, OS X 10.9.
My OpenCV was installed using homebrew.
I get the following error
Undefined symbols for architecture x86_64:
"cv::namedWindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)"
I have added Header Search Paths /usr/local/include nonrecursive and /usr/local/include/opencv2 nonrecursive;
I have added Library Search Paths /usr/local/lib;
I have added all .dylib file under /usr/local/Cellar/opencv/2.4.3/lib to the project.
From what I can see, you are trying to run an Objective-C++ project, right? I presume that because cv::nameWindow is a c++ function of OpenCV.
You can have a look on this question, where I had a similar issue and solved it configuring the project properly.
This error means your XCode project is not finding the cv::namedWindow function. Are u sure OpenCV is properly installed in your PC? Can you run the C++ opencv functions from a standard c++ project? If so, the problem is just about your project configuration.

Unity project. Undefined symbols for architecture armv7

I make a build for iPhone for the first time and got a problem.
I already checked a lot of posts and didnt find answer.
When i make a build on device a get:
Undefined symbols for architecture armv7:
"RegisterAllStrippedInternalCalls()", referenced from:
RegisterAllInternalCalls() in libiPhone-lib.a(MonoICallRegistration.o)
"RegisterAllClasses()", referenced from:
InitializeEngineNoGraphics() in libiPhone-lib.a(SaveAndLoadHelper.o)
"RegisterMonoModules()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
On simulator ok.
libiPhone-lib.a added to link libraries.
Can somebody tell what it is? Please
Your unity version is not compatible, just download the latest version of unity which I believe is 4.3.1 and try recompiling. Here is the link if you need it. http://unity3d.com/unity/download/download-mac
The new version is compatible with armv7.
ok if anyone else is experiencing the same problem here's a way out:
those 3 methods mentioned are declared in the RegisterMonoModules.cpp in the Libraries folder, usually. so take that cpp file and add it to your target's Build Phases > Compile Sources
then if you have additional SDK's integrated that are not added to the 'Compile Sources' the new build will throw some other errors. just make sure to add the wrapper .mm files from the sdk's to your Compile Sources. Usually one .mm file per sdk. (e.g. for unity facebook sdk it's FbUnityInterface.mm file)
hope this helps

XCode file not compiling

I'm getting the following two errors via xcode:
Warning: no rule to process file '$(PROJECT_DIR)/SQLite Toolbox/en.lproj/MainWindowController.m' of type file for architecture x86_64
Followed by:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MainWindowController", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
Previously my project was building just fine, but I attempted to do some localization. I had my MainWindowController.xib highlighted and choose the localize option.
After that, the project stopped compiling. It looks to me that for some reason XCode is refusing to compile my MainWindowController.m, but i'm not sure how to go about fixing that. (I have confirmed it does exist in the Build Phase Compile Source steps.
Any ideas on how I could fix this?
That sounds as if you inadvertently have localized the "MainWindowController.m" file.
The following steps worked in my test project to fix that situation:
Remove "MainWindowController.m" from your project (using the "Remove Reference" option!)
In the Finder, move "MainWindowController.m" from the "en.lproj" folder back to the main folder.
Drag "MainWindowController.m" onto the Xcode project to add it again.

Resources