I'm building a framework target to be used across multiple apps I am developing and I'm trying to include the Twilio SDK (TwilioCommon & TwilioConversationsClient) in this common framework target.
To do so, I had to create a modulemap to define a module from the headers. Ok, great. Everything seems to work fine. Except I'm getting an excessive number of warnings when following this model:
ld: warning: ignoring linker optimzation hint at _cftmdl_128_neon+0xF0 because ldrInfoC.offset == 0
ld: warning: ignoring linker optimzation hint at _cftmdl_128_neon+0xFC because ldrInfoC.offset == 0
ld: warning: ignoring linker optimzation hint at _cftmdl_128_neon+0x108 because ldrInfoC.offset == 0
....
....
I believe I've adhered to the Manual install for iOS page fairly well and I've created a minimal project on github to replicate this behavior.
Anyone able to spot mistakes? Is this a bug in the way the library was linked?
Versions and things:
XCode 7.2.1, Swift 2
TwilioCommon 0.2.0
TwilioConversationsClient 0.22.0
This question is remarkably similar to this one:
How do I resolve linker warning "ignoring linker optimzation hint at" in XCode?
If you're compiling the WebRTC library by yourself using build
scripts, the warnings are generated because of a missing parameter in
GYP_DEFINES.
In order to fix the warnings, the WebRTC library needs to be compiled
again with the parameter clang_xcode=1 in the GYP_DEFINES setting,
like below (only an example):
export GYP_DEFINES="$GYP_DEFINES OS=ios target_arch=arm64
clang_xcode=1" More about the issue can be found here, on the Chromium
forums: https://bugs.chromium.org/p/webrtc/issues/detail?id=5182
--
If you're not compiling the WebRTC library yourself, and instead
installing the WebRTC library from a 3rd party source, I don't believe
there is a fix as the warnings are stemming from the static library.
Related
I have upgraded to XCode 8.0 and it is giving me grief. The first issue was to do with code signing. Which I fixed by selecting a provisioning profile for debug and release from the General project settings. Weird not sure why it couldn't just work as it was compiling perfectly with the previous XCode. Previously XCode would say there is not provisional profile and prompt to fix it and would fix it. Seems a step back here. Anyways, went passed that issue.
The issue I have been facing all day is this error when I compile
Undefined symbols for architecture arm64:
"_write_ret", referenced from:
_dwsl in libtestlib.a(testlib.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I searched for write_ret and it is only a prototype in a header file, this function isn't called anywhere at all!! (Background the static library is part of a bigger project I brought only the files/code I needed to compile the static library for iOS). This was compiling perfectly before for years. I went back to the static libary source code and to humour myself I deleted the write_ret prototype and compiled it and updated the library in the my project and rebuilt. Same error again!. What is going on here?? I confirmed it was definitely using the correct built library.
I then decided I'll just built for armv7 only as this is an enterprise app. I went back to the static library project file and got rid of armv7s and arm64 from "valid architectures". I change "architectures" to armv7. I rebuilt the library and updated the project with the new library.
I also went into the main project and change the valid architectures to build for only armv7.
This time when I built my project I get this error
ld: warning: ignoring file /Users/rrr/Library/Developer/Xcode/DerivedData/P-eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a,
file was built for archive which is not the architecture being linked (armv7):
/Users/rrr/Library/Developer/Xcode/DerivedData/P-eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a
In the terminal I ran lipo libtestlib.a -info I get this:
input file libtestlib.a is not a fat file
Non-fat file: libtestlib.a is architecture: armv7
So it is built for armv7, so what is XCode complaining about really?
I am out of ideas now. Can anyone shed some light here?
I would like to get it to work with all the architectures as it was doing before the XCode upgrade I did on Friday. But worst case atleast compile to work only for armv7. My understanding is that it will still run on anything iPhone 5s and newer anyway.
At first, As you already know, you should support arm64 in order to support 64 bit architecture following Apple's rule.
At second, let's talk about undefined symbol issue, your first question.
I am not sure exactly from your situation description but, one thing to my mind reading the question is that your static library may depend on some dylib(dynamic or shared library) which is deprecated from Xcode 7.The possible scenario is your dylib library was red-marked in the project from Xcode 8 update version because this was replaced with tbd instead of dylib. So, this library is now missing status, and you did remove it in the library list and you forgot it. That's why your _write_ret symbol in libtestlib.a cannot be linked for architecture arm64 anymore.(dylib is missing status.)
if this scenario is true, import tbd instead of dylib.(text-based stub libraries).
let's talk about your second question related to error log.
ld: warning: ignoring file /Users/rrr/Library/Developer/Xcode/DerivedData/P- eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a,
file was built for archive which is not the architecture being linked (armv7):
/Users/rrr/Library/Developer/Xcode/DerivedData/P- eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a
This log can be about Build Active Architecture Only in Xcode build setting.
check 'Build Active Architecture Only' from Yes to No.
It error log could be generated when Build Active Architecture Only is set to YES in your build setting situation.
and, if it does not work, Have you ever clean your DerivedData directory and project?
If you already tried, it could be possible that your static library is actually not in the /Users/rrr/Library/Developer/Xcode/DerivedData/P-eaxegvaceikvgqgllfiardmoorbv/Build/Products/Debug-iphoneos/libtestlib.a.
so, you can move your static library output into this project and try it again.
These are just scenario for your situation as I got your question.
I wish it became a little help.
Thanks.
I am trying to integrate PSPDFKit for iOS in my project and I have not been yet able to success. After downloading the Demo version, adding the framework to my project, adding all the required libraries and placing
#import <PSPDFKit/PSPDFKit.h>
on the 'prefix' file, I get an linker error:
ld: section __objc_const (address=0x00613EA8, size=4651232504) would make the output executable exceed available address range for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
NOTE: My project uses PSTCollectionView and I have successfully compiled PSPDFKit on a test project (created only for that effect).
I would really appreciate any help. Thanks in advance.
Apparently, you have too many included files in your PCH file.
Try removing some of them, and include those files only where you need them, not globally.
As far as I understand it, this is a bug in Apple's compiler/linker chain. Please file a radar at radar.apple.com with your failing project. A workaround is to use the source code as a subproject instead of the precompiled binary.
As soon as I can get my hands on such a project, I can experiment with the settings to see if there's any workaround. Seems to only happen under very specific combinations with other 3rd party code.
My project uses some Cocoa static libraries, one of which is a Zxing Project. I am getting a lot of errors while trying to incorporate this project. Weirdly enough, I was able to create a demo with Zxing in a separate project, without any errors. My main project builds and runs ok, as long as I do not include the Cocoa static library for Zxing.
So the question is, how do I include the ZXing static library to my Cocoa project? How do I configure library (e.g. how do I set the Header Search Paths~~).
Thanks.
Some detail about my project
The Structure
EnjoyMobile
-CustomStaticLibrary.xcodeproj
-ZXingWidegt.xcodeproj
Header search Paths in my -CustomStaticLibrary Target
./zxing/iphone/ZXingWidget/Classes
./zxing/cpp/core/src
The error
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_QRCodeReader", referenced from:
objc-class-ref in libCustomerLibrary.a(CustomerViewController.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Zxing is kind of a painfull integration, also in the newer versions of Xcode Apple added more error checks. I would suggest you to use cococapods for a better integration or this ObjectiveC wrapper here
It's not seeing some of the lib classes. Double check the steps in the README, particularly step 2. If it still fails, post the link command that fails.
I recently just upgraded to the new XCode. After I upgraded, some of my apps won't build. I get this error:
ld: cannot link directly with /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/system/libcommonCrypto.dylib. Link against the umbrella framework 'System.framework' instead. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've tried everything - cleaning, reimporting, changing architectures...
Please help
I resolved this issue in a diffent way after I tried both the above where neither worked for me.
The problem was that when I was adding the library from the main interface (main build-settings...etc) I was searching initially for crypto and then two libs comes back libcorecrypto.dylib and liblibcommonCrypto.dylib, if you notice, both exists in gray-color unlike the usually yello-colored libs that you normally add. Adding these causes the compiler to report back (some other libs are missing, such as the libz, or another lib that will be needed the more functions you take on.
If you notice the above two libs would normally sit under JavaScriptCore.framework library (which is the yellow one), therefore, by removing the above two and adding JavaScriptCore.framework instead, the problem was resolved, and build successful showed
Also to mention that based on the gray-libs existing as a bundle inside JavaScriptCore.framework, the libcrypto and the other one will not exists under the /Library/.../system/path as mentioned above, i.e. you didn't delete them from your system, they're just not there.
Again, the solution is:
*From your main XCODE project settings, don't add:*dd
libcorecrypto.dylib
liblibcommonCrypto.dylib
Instead, add:
JavaScriptCore.framework
In your .m (code), just source them normally by doing:
#include <CommonCrypto/CommonDigest.h> (or any of your other libs as needed in code)...
It should work fine.
I hope this helps.
Kind Regards
I just solved this as follows:
It turns out that the libcommonCrypto.dylib error was a red herring.
After removing libcommonCrypto.dylib as suggested above, I got 9 new errors.
At first glance, I assumed they were Crypto errors, but in fact they were not; for me, it actually traced back to zLib not being included, which was "imported" in a deeper part of the overall implementation (of which crypto is a part).
For me specifically, it traced back to ASIDataDecompressor.h, #import < zlib.h>
I fixed it by including the missing libz.dylib framework; ultimately, I did not have to explicitly include libcommonCrypto.dylib.
So, be sure to check the errors closely after toggling libcommonCrypto, and make sure some OTHER libraries are not missing, instead.
I'm using cocoapods for library management. One of the libraries (you can simple search in your workspace) contained reference to CommonCrypto.framework which was red in the list of frameworks in its project settings.
In my case I had to remove the dependency on CommonCrypto.framework, but this solution lasts just to another update of your pods.
Btw I'd like to know a command to list the graph of dependencies among the libraries in the Podfile.
I had the same error,
ld: in '/usr/lib/system/libcommonCrypto.dylib', missing required architecture arm64 in file /usr/lib/system/libcommonCrypto.dylib (2 slices) for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I solved this problem by checking my $PATH. It was a missing file.
Using find / -type f -name libcommonCrypto.dylib
Comparing my libs with my friends mac systems, it shows that this file was not present on my computer :
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/system/libcommonCrypto.dylib
Xcode using $PATH fallback on /usr/lib/system/libcommonCrypto.dylib but it's not the good built (i386 insteadof arm stuff).
I copied the version of my friend, move in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/system/ and then I was able to build my projects again.
There is a vicious problem here cause there is a lot same file for this lib depending of your architecture and most of them are not intended to be used for ios builds. But the $PATH env var will fallback on /usr/lib when no files are found on dedicated dirs.
Xcode fallback on /usr/lib/system/libcommonCrypto.dylib but this is definitely not the correct lib cause it not a built for ios, but a built for my mac.
Better Solution ,as it says remove libcommonCrypto.dylib,and replace by adding SystemConfiguration.framework.It worked for me,might be useful to someone.I was getting Linker Error saying gettingLink against the umbrella framework 'System.framework' instead.
I'm adding adMob provide by google to my iOS app and I'm stuck on this part of the installation:
Add -all_load under Other Linker Flags in the project build info
If I add that flag, then another third party library breaks giving me the error message:
ld: duplicate symbol _vw_chartype_table_p in /Users/josh/ Projects/app/libs/libvt_universal.a(vw_ctype-3279EF26D0C25F3A.o) and / Users/josh/Projects/app/libs/ libvt_universal.a(vw_ctype-34AB9EC0B46D954C.o) for architecture i386
Is there any way to use the adMob library without using -all_load? For example, I've tried -force_load $(SOURCE_ROOT)/adMob/libGoogleAdMobAds.a
but
ld: file not found: /Users/USERNAME/Desktop/latest/bbbb/APPNAME/adMob/libGoogleAdMobAds.a
The reason Google suggests using -all_load is that they are using categories in their code, and Objective-C libraries with categories are not properly loaded by the llvm linker (well that was the case in 4.3 xcode, not sure about 4.4 with the newer clang).
So, I guess if you are brave you can try to just remove the all_load flag. It should build fine. If the bug is NOT fixed, what will happen is when you run your code, it will crash, since none of the categories the library uses will have been loaded. This might be a good thing to do in any case, as your project should build, and if it does not you can fix those problems first.
What I do suggest you do is use -force_load, which has llvm load the categories in the adMob library (among other things). To use it you MUST have a fully qualified path (ie starts at '/') to the library. Obviously if you use Terminal and run:
ls -l /Users/USERNAME/Desktop/latest/bbbb/APPNAME/adMob/libGoogleAdMobAds.a
its going to fail. So enter the proper path - hard coded - for now to just see if you can get the project to first build, then run. If it does you can later figure out what is the appropriate $(VAR) to use to find it inside your project.