cocapods duplicate symbols for architecture x86_64 - xcode

I've just updated my App to iOS9 and Xcode 7 and after that I always get the message:
1332 duplicate symbols for architecture x86_64
I'm using cocoapods for dependencies resolution, and if I edit Pods.xcconfig I get rid of the message but I get exceptions in my application.
I also modified Podfile and included directive use_frameworks! but I still have problems with the linker.
Updating cocoapods to last version 0.39.4 didn't help either.
Thanks in advance for your help

Related

CMake correct way to add a MacOSX framework [duplicate]

Does anyone know how to do specify the Mac OS X SDK to build against with CMake? I have searched for cmake mac "base sdk" but this turned up nothing.
I am using CMake to generate Unix makefiles.
Update
On my 10.6 install, I see that /Developer/SDKs has the following:
MacOSX10.4u.sdk
MacOSX10.5.sdk
MacOSX10.6.sdk
Perhaps I can get CMake to pass one of these paths to the compiler somehow?
Also, my 10.7 install only has:
MacOSX10.6.sdk
MacOSX10.7.sdk
Does this mean that it can only build for these platforms?
Update 2
Damn, I just realised that actually I'm not using Xcode -- so this may affect some answers. Also, I am now trying with Mac OS X 10.8 developer preview (with some weird results, see my answer).
After trying sakra's valid answer (valid as far as CMake is suposed to behave) unsucessfully, I had a dig around and found that if I specify the --sysroot flag to the compiler, it seems to use the correct SDK!
However, I now see this error when I compile against 10.7 (which I don't see with 10.8):
Undefined symbols for architecture i386:
"_NXArgv", referenced from:
execSelfNonDaemonized() in libarch.a(CArchDaemonUnix.o)
CArchDaemonUnix::daemonize(char const*, int (*)(int, char const**)) in libarch.a(CArchDaemonUnix.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/synergyc] Error 1
make[1]: *** [src/cmd/synergyc/CMakeFiles/synergyc.dir/all] Error 2
make: *** [all] Error 2
Note: CArchDaemonUnix is a class in Synergy (an open source project I'm working on).
Update:
Just tried this on my 10.6 install, and I was getting a linker error when trying to compile for 10.5 -- turns out you also need to specify the MACOSX_DEPLOYMENT_TARGET environment variable!
Anyway, here's what I'm doing when running on Mountain Lion (OSX 10.8) to compile for 10.7:
Command line:
MACOSX_DEPLOYMENT_TARGET=10.7
cmake -G "Unix Makefiles" -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.7.sdk/ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 ../..
CMakeLists.txt:
set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}")
I hope this helps someone! :-)
Add the following commands on your CMakeLists.txt
set(CMAKE_OSX_SYSROOT macosx10.10)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5")
This should be fine.
You can set the variable CMAKE_OSX_SYSROOT to the chosen SDK upon configuring the project. E.g.:
cmake -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.4u.sdk/ ..
See the documentation here.
Also note that CMake versions before 2.8.8 do not support Xcode 4.3.

Xcode 7 - How to remove ld: warning: -read_only_relocs cannot be used with x86_64

I have recently updated to Xcode 7 and now receive the following warning when I compile:
ld: warning: -read_only_relocs cannot be used with x86_64
I don't think I changed anything in the build settings or code to create this. Does anyone know what is causing this warning and how to remove it?
I have found the problem for those interested. As mentioned in the comment, I'm using the Twilio API and if you install this via cocoapods it adds the -read_only_relocs flag to the Other Linker Flags in Xcode (found under Build Settings). Not only does this generate the warning above (on the simulator) but it wont compile on an actual device because you can't have both BITCODE = YES and this flag. If you want to compile, you will need to set Enable Bitcode to No in the Build Options.

Xcode 6 throws clang error while compiling

I have recently updated my Xcode to version 6.0 (6A313). Now, during the compilation I get the following error:
clang: error: unknown argument: '-wall'
From Clang Compiler User's Manual, I found out that this flag is responsible for enabling all warnings. I have also read many posts on the temporary fix for Apple LLVM Compiler for Xcode 5.1, where users would downgrade all clang errors to warnings with:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install ExtensionName
However, that does not help me, as there is no such extension as "all". So I am stuck at this point and any suggestions would be appreciated.
Also, I have upgraded to Ruby 2.1.1 (from 2.0.x), but that did not seem to help either.
The argument is -Wall, not -wall.

dyld: Library not loaded, Reason: image not found

I used gdb normally until this week. Now running gdb I see:
(gdb) r
Starting program: /Volumes/MyProg
dyld: Library not loaded: #rpath/libCore.so
Referenced from: /Volumes/MyProg
Reason: image not found
(gdb)
How to fix it?
I have:
OSX 10.9
GNU gdb (GDB) 7.6 installed with MacPorts
P.S.
I have reinstalled gdb and Xcode. This does not help.
I see a lot of questions about dyld issues, but obviously I lack experience with libraries on OSX, and they appears to be useless for me.
For example this topic: dyld issues library not loaded
But how to download library again?
Or this topic: Dyld: Library not loaded
But how to find out install name? What is #rpath?
I solved this issue with "Embedded Binaries" in the General project settings.
i have solved this issue by changing the following settings
Go to Project Setting Your_Target->General->Embedded Binaries-> Click on + button and add your library here
How I fixed it:
libCore.so is a library from ROOT framework, which MyProg uses.
If I understand correctly, the message Library not loaded: #rpath/libCore.so Referenced from: /Volumes/MyProg Reason: image not found means that linker found the library, but can't use it.
Root, during installation uses clang by default. Meanwhile as I prefer gcc and MyProg uses gcc.
I have reinstalled root with gcc compiler:
./configure --with-cxx=g++ --with-cc=gcc --with-ld=g++
I have recompiled MyProg.
and now I can debug it with gdb.
You can find more information about rpath here: link
So you need to point the path to your libCore.so, but honestly I have not faced with this library so I don't know where is it located.
You can check also this answer to understand what it is rpath: answer
For Xcode 11 or above, there is another simpler solution which worked for me if you are using Cocoapods.
In your Podfile, add use_frameworks! after your Target line like this -
target 'YourAppName' do
use_frameworks!
Basically it adds all your pods as a framework in your framework folder.

Error when trying to archive xcode project

My project runs fine when I run it using the iPhone simulator, and when I run it on a device. When I try to archive it for submission, I get this error:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This was directly before the error and I'm not sure if it's related:
ld: file is universal (2 slices) but does not contain a(n) armv7s slice: /Volumes/Macintosh HD/Users/dog94a/Google Drive/Capstone/Backups/Approach/Approach/GMaps/GoogleMaps.framework/GoogleMaps for architecture armv7s
The default behavior of the Debug build configuration is to only build the active architecture (Build Active Architecture Only build setting is YES). This is not the case for the Release build configuration, which will build all architectures supported by your Valid Architectures build setting. What this means is that you're likely not targeting an armv7s device during your Debug builds (iPhone 5, latest iPad, etc), so you're not attempting to build that architecture until you do an archive which uses the Release build configuration by default.
The error indicates that your project is configured to create a binary that has armv7s instructions for when it runs on devices of that type, but the GoogleMaps.framework binary you're trying to link against was not built with an armv7s slice. To fix this, you either have to update to the latest version of the GoogleMaps.framework and hope they built it with armv7s enabled, or remove armv7s from your Valid Architectures build setting (obviously the former is preferable).
Once I have included a framework and at compile time nagged the linker for armv7. Now you have armv7s, which is the iphone5?
Solution to my problem it was: remove all files from that framework.
Compile that framework ( double check at Valid architectures settings to be there the desired architecture
Re-add the newly compiled framework.
Try and maybe it helps or even solve your problem too!

Resources