XCode linker error : library not found for -lAdMobDevice - iphone

I am trying to build lite version of my iPhone application using AdMob. I followed the guidelines here http://www.iphonedevsdk.com/forum/iphone-sdk-development/11358-creating-lite-version-app.html and created two different targets. In the lite version I added a macro called LITEVERSION which I am checking using #ifdef and doing the appropriate things.
But when I build the lite version of the app, I get a linker error
ld: library not found for -lAdMobDevice
collect2: ld returned 1 exit status
However I am able to build the full version without any issues and also noticed that build is working fine (for the fullversion) even if I remove the #ifdef macros. This suggests that the libAdMobSimulator.a library is linking properly for the full version however it fails on the lite version.
Any pointers would be greatly appreciated!
Cheers
Jugs

When I had this problem, the cause was that I'd added the library into Xcode by dragging it in like a regular source file.
The fix was to remove it, and then add it properly using the "Add->Existing Frameworks..." dialogue.

I got similar error as I was using CocoaPods libraries
library not found for -lPods-MyApp
I got the error because I opened xcode project instead of workspace.

I was using CocoaPods, and ran pod install, and that fixed it.

I figured out what he problem was. I just removed all frameworks and libraries and added them back in for both the targets and it worked!
Cheers

I cause this because of a libray libMobClickLibrary.a which is used in youmeng sdk missed. I fix the issued after copy libMobClickLibrary.a to the project floder.

I had the same problem with Google Analytics library. My problem was that I forgot to add the path to the Library Search Paths in my target's build settings. (Target -> Build Settings -> Library Search Paths)

Related

Undefined symbols for architecture arm64: "_OBJC_CLASS_$_GADMobileAds" [duplicate]

I am getting a Apple Mach-O Linker Error everytime I import a file from CocoaPods.
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FBSession", referenced from: someFile
ld: symbol(s) not found for architecture arm64
I get about 12 of these, for the various Pods I use.
I am trying to build for the iPhone 5S using XCode 5.
I've been trying various solutions here on SO, but haven't got any of them to work yet.
How do I fix this Apple Mach-O Linker Error?
Just found another warning that might be interesting, I hope this leads me to the solution:
Ignoring file ~/Library/Developer/Xcode/DerivedData/SomeApp/Build/Products/Debug-iphoneos/libPods.a,
file was built for archive which is not the architecture being linked (arm64):~/Library/Developer/Xcode/DerivedData/someApp/Build/Products/Debug-iphoneos/libPods.a
If your Architectures and Valid Architectures are all right, you may check whether you have added $(inherited) , which will add linker flags generated in pods, to Other Linker Flags as below:
The issue is that the cocoapods have not been built for arm64 architecture yet thus they cannot be linked when you build them. Likely you cannot use those packages until they are updated and use that architecture. You can fix the linker error by going to project -> target (your project name) -> build settings and change architectures to standard architectures (armv7, armv7s), and valid architectures to armv7, armv7s.
Note though, this means you won't get the full power of the 64 bit processor. You said you are building for the 5s, so there may be some reason you need this. If you for some reason absolutely need that power (perhaps you are building a game), and desperately need those files, you could submit a pull request and then recompile the project to arm64 by setting those same fields to arm64 in the files you pulled from the open source projects. But, unless you really need these files to be 64 bit compatible, that seems like a bit of overkill for now.
EDIT: Some people also reported that setting Build For Active Architectures to YES was also necessary to solve this problem.
As of 2014-04-28 the setting should look something like this:
I solved this problem by setting that:
ARCHS = armv7 armv7s
VALID_ARCHS = armv6 armv7 armv7s arm64
I ran into the same/similar issue implementing AVPictureInPictureController and the issue was that I wasn't linking the AVKit framework in my project.
The error message was:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_AVPictureInPictureController", referenced from:
objc-class-ref in yourTarget.a(yourObject.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The Solution:
Go to your Project
Select your Target
Then, go to Build Phases
Open Link Binary With Libraries
Finally, just add + the AVKit framework / any other framework.
Hopefully this helps someone else running into a similar issue I had.
I also encountered the same problem , the above methods will not work . I accidentally deleted the files in the following directory on it .
Folder emplacement:
~/Library/Developer/Xcode/DerivedData/
Set Architectures to armv7 armv7s, Build Active Architecture Only to NO, for every target in the project, including every one in Pods
I fixed mine by checking the selected implementation files in the target membership on the right side. This is useful especially in dealing with extensions i.e. custom keyboards.
Here are some explanations why build_active_architecture is set to NO.
Xcode now detects which devices you have connected and will set the active architecture accordingly. So if you plug a 2nd generation iPod Touch into your computer, Xcode should set the active architecture to armv6. Building your target with the above Debug configuration will now only build the armv6 binary to save time (unless you have a huge project you may not notice the difference but I guess the seconds add up over time).
When you create a Distribution configuration for publishing to the App Store, you should make sure this option is not set, so that Xcode will instead build the fat universal binary
http://useyourloaf.com/blog/2010/04/21/xcode-build-active-architecture-only.html
This might be related to libz.dylib or libz.tbd, just have to add it to your targets for the linking binaries, and try to compile again.
You need to just remove arm64 from Valid Architecture and set NO to Active Architecture Only . Now just Clean, Build and Run. You will not see this error again.
:) KP
Solved after deleting the content of the DerivedData-->Build-->Products-->Debug-iphoneos
I solved it by setting valid archs to armv7 armv7s and setting build active architectures only to YES in release and then doing a new "pod install" from the command line
Following worked for me:
Remove all pods
cd ios && pod deintegrate
Comment this line in ios/Podfile -> use_flipper!()
Reinstall all pods arch -x86_64 pod install
Run your app :) npm run ios
Environment:
Node version: 14.17.1
RN version: 6.0.0
OS: macOS BigSur m1
Given an iPhone 5s and not yet having received a 64 bit version of a third party library, I had to go back to 32 bit mode with the latest Xcode (prior to 5.1 it didn't complain).
I fixed this by deleting arm64 from the Valid Architectures list and then setting Build Active Architecture Only to NO. It seems to me this makes more sense than the other way around as shown above. I'm posting in case other people couldn't get any of the above solutions to work for them.
I had the same problem after upgrading to Xcode 5.1 and fixed it by setting Architectures to armv7 armv7s
Had been stuck on this issue the whole day.
I had multiple Schemes, it was compiling fine for Demo, Internal, Release - however Debug scheme just would not compile and was complaining about the libPods.a missing.
The solution was to go to the Project -> Target -> Build Settings and change "Build Active Architecture Only" to YES. Clean and build! Finally hours of head itching solved!
Setting -ObjC to Other Linker Flags in Build Settings of the target solved the problem.
This worked for me:
ios sdk 9.3
into your build setting of app.xcodeproj
valid architecture: armv7 armv7s
Build Active architecture : No
Clean and build , worked for me.
If you faced this issue on your Flutter project while building in Release mode (or Archive) check out my this answer: https://stackoverflow.com/a/61446892/5502121
Long story short:
set your build system to New Build System in File > Project Settings…
remove ios and build_ios folders
run flutter create . to init new ios module
run pod install
run flutter pub get
check your Xcode build config (it should be Release mode and General iOS Device)
and you're good to go
The following worked for me to get GPUImage compiling without errors on Xcode 5.1 for both the 64-bit simulator and retina iPad Mini, without needing to remove arm64 from the Valid Architectures list (which defeats the purpose of owning a 64-bit device for testing 64-bit performance).
Download the .zip folder from the GitHub page: https://github.com/BradLarson/GPUImage
Unzip, and navigate to the 'framework' folder. From here, add and copy the 'Source' folder into your Xcode project. Ensure 'Copy items into destination group's folder' is ticked, and that 'Create groups for any added folders' is also ticked. This will copy the generic, iOS and Mac header/implementation files into your project.
If you don't need the Mac files because you're compiling for iOS you can delete the Mac folder either before you copy the files into your project, or simply delete the group from within Xcode.
Once you've added the Source folder to your project just use the following to begin using GPUImage's classes/methods:
#import "Source/GPUImage.h"
A few things to point out:
If you get an error saying 'Cocoa' not found, you've added the Mac folder/headers into your iOS project - simply delete the Mac group/files from your project and the warning will vanish
If you rename the Source folder (not the group in Xcode), use that name instead of "Source/GPUImage.h" in the #import instruction. So if you rename the folder to GPUImageFiles before you add to your project, use: #import "GPUImageFiles/GPUImage.h
Obviously ensure arm64 is selected in the Valid Architectures list to take advantage of the A7 64-bit processor!
This isn't a GPUImage.framework bundle (such as if you downloaded the framework from http://www.raywenderlich.com/60968/ios-7-blur-effects-gpuimage) so it may not the correct way to use GPUImage that Brad Larson intended, but it works for my current SpriteKit project.
There's no need to link to frameworks/libraries etc - just import the header and implementation source folder as described above
Hope the above helps - it seems there were no clear instructions anywhere despite the question being asked multiple times, but fear not, GPUImage definitely works for arm64 architecture!
This issue occurred for me after installing a pod via Podfile and pod install. After trying a bunch of different fixes I finally just imported the Pod manually (dragging the necessary files into my project) and that solved the problem.
As morisunshine answer pointed in right direction, a little tweak in his answer solved my problem for iOS8.2 .Thanks to him.
I solved this problem by setting that:
ARCHS = armv7
VALID_ARCHS = armv6 armv7 armv7s arm64
BUILD ACTIVE ARCHITECTURE ONLY= NO
Go to target Build Settings.
set BUILD ACTIVE ARCHITECTURE ONLY = NO for both Debug and Release
Build and run
In my case, I had to look for
C++ Standard Library and make sure that the libc++ was the one selected.
For me, I use opencv 2.4.9 in xcode 7.2 for iOS and the errors above occurred, and I solve the errors by using the opencv through pod install rather than offline opencv framework.
You can have a try by adding the opencv pod text below and delete the offline opencv framework if you have used.
pod 'OpenCV', '2.4.9'
None of the solutions fix this error in my case(Xcode 9), with TesseractOCRiOS. After hours of trial and error, I came up with a good solution. I just delete 'pod 'TesseractOCRiOS', '~> 4.0.0' in the Podfile, run pod install. And then, add pod 'TesseractOCRiOS', '~> 4.0.0' back to Podfile and run pod install again.
Bang! It works!
"The OPN [Debug] target overrides the OTHER_LDFLAGS build setting". This was the main issue. After adding $(inherited) in new line in other linker flags solved my issue.
in some case, if you define one more interface in a .h file, but did not implementation all these interface, this error occurred.
The linker can't found the implementation in .m file, so you need to implementation it in your .m file for every interface.
To resolve this error:
1.in .m file, supply the implementation for each interface.
2.rebuild
I faced the same issue.
My solution I found here: Why linker link static libraries with errors? iOS
Adding $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) to the library search paths fixed the problem.
This error consumed my whole day so thought of writing what really worked for me
delete .xworkspace
delete podfile.lock
delete the Pods folder/directory
"DO NOT DELETE PODFILE"
After all this, CLEAN(OPTION + SHIFT + CMD + K) --> BUILD(CMD + B) --> RUN(CMD + R)
I hope this really works for you :)

Cocoapods: dyld library not loaded

So since a few days I have this issue: I create an empty command line project and set up Cocoapods, but then I always get this runtime error:
dyld: Library not loaded: #rpath/Alamofire.framework/Versions/A/Alamofire
Referenced from: /Users/...
Reason: image not found
Program ended with exit code: 9
This happens regardless of the pod I want to use and also in already existing projects. Windowed Cocoa applications and iOS apps are not affected. I tried setting the pods.framework to Optional as suggested elsewhere, but this doesn't help. I tried it with the newest Cocoapods beta and the stable release and reinstalled Xcode, but without success. I noticed under Build Phases there is no 'Embed Cocoapods framework' as usual, so I tried adding that manually; didn't work either.
I've run out of ideas, so does anybody have any idea what might cause this? Otherwise I'll file a bug report. Thanks.
As it turns out, this behaviour is expected, as there is no easy way (for CP) to link libraries to a command line tool.

Getting dyld_fatal_error after updating to Xcode 6 beta 4 using swift

I just recently downloaded Xcode 6 beta 4, and my swift project compiles with no errors but before it gets to my code I get a dyld_fatal_error just above start in the call stack.
and a breakpoint in some assembly code with a nop instruction
The console error I get is
dyld: lazy symbol binding failed: Symbol not found: __TFSsa6C_ARGVGVSs13UnsafePointerGS_VSs4Int8__
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/Sudoku
Expected in: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/../Frameworks/libswift_stdlib_core.dylib
dyld: Symbol not found: __TFSsa6C_ARGVGVSs13UnsafePointerGS_VSs4Int8__
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/Sudoku
Expected in: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/../Frameworks/libswift_stdlib_core.dylib
Just so you know the project still compiles, and runs fine with Xcode 6 beta 3.
Most extremely weird problems like this can be solved with a Clean & Build (or perhaps relaunch Xcode). You might also consider deleting the relevant folders from ~/Library/Developer/Xcode/DerivedData.
For sure this error is very unhelpful:
dyld`dyld_fatal_error:
-> 0x1200ad088 <+0>: brk #0x3
This of course occurs only on device, not the simulator. Another good reason to always test on a device.
Anyway, having had the same issue, a clean didn't work for me. Deleting DerivedData didn't help either. Also tried synchronising the Deployment Target versions. That didn't seem make any difference but I did it anyway.
Solution was to add any dynamic frameworks to Embedded Binaries setting under Target -> General:
Now I know that has been mentioned in other answers. However, if I can supplement by saying that any dependent dynamic frameworks must also be included.
So for example if you have a dynamic framework A that depends upon dynamic framework B, then it's necessary to have A and B added to Embedded Binaries.
Note that if the dynamic framework A depends upon any static library or framework, you will almost certainly be forced to create A as an umbrella framework that includes the dependant binaries.
Other considerations that may or may not be important. However did personally for me result in success were;
paths of each dynamic library in the Inspector were set to "Relative
to Group". In the screen grab above the path of the embedded binary
appears correct terminating with "build/Debug-iphoneos".
dynamic frameworks are in embedded binaries section. Static libs and
static libs wrapped up as frameworks are in Linked Frameworks
and Libraries. Nothing appears in both sections.
In setting this up XCode behaved strangely. The following proved successful:
Add the dynamic framework to the embedded binaries.
Find the new framework in XCode groups on the left and update the path to be
"Relative to Group" as described previously.
Delete the dynamic framework from embedded binaries.
Add the dynamic framework to the embedded binaries again. The path should now appear correctly.
Delete all references to the dynamic framework from the Linked Frameworks
and Libraries section.
I have just had this problem trying to link a custom iOS framework to my project, so for anyone out there who has this problem, it's to do with the copy files build phase.
I think that this error results when a file cannot be found. So create a copy files build phase in the appropriate target in your project. Then add the file (in my case the custom framework) to this phase (if it's a framework make sure to select the 'Frameworks' destination).
Cleaning, restarting, deleting etc didn't work for me.
I have a project containing another project. When I ran the project on iOS 7 and the contained project was accessed in code, the app stopped at the line below:
After many days, I saw that the deployment target for the container project was 7.0 (as can be seen below).
The contained project on the other hand, had a deployment target of 8.1 (as can be seen below).
Changing the deployment target of the contained project to 7.0 solved my problem!
The project was working fine on iOS 8 devices.
I had this issue recently and the problem for me was that I had added a library from the same project which wasn't listed in 'Embedded Binaries' from the 'General' section.
NOTE: If you add it in Embedded Binaries it will also add to the Linked Libraries section, possibly adding the same one twice.
Clean and build won't work. You'll need to delete he cache in ~/Library/Caches/com.apple.dt.Xcode* directories. Delete these and rebuild.
Do this every time you upgrade the beta.
I also faced the same issue and tried all the solution given above without any luck.
then what I have done to resolve that I really don’t have much I idea about. So there is Certificated called “apple worldwide developer relations certificate authority” in System group in keychain Access and due to some profile and certificate issue I randomly mark this certificate “Always trusted” from “Use System Defaults”. So this is causing this “dyld_fatal_error” crash to me. when I revert it back to “Use System Defaults” crash got resolved.
So guys if you are tried all the possible option to resolve this crash and didn’t succeed yet, try this also. It helped me, may help you as well.
Found this about this certificate.
This problem still occurs in Xcode 7, and it can happen for a variety of reasons (it seems). In my case, the iOS app with an included framework:
ran on the simulator fine
gave the error you described on the device
The answer was to NOT use linked libraries but rather Embedded Binaries under General.
Also see here: https://stackoverflow.com/a/34052368/8047
Adding the non-system Framework to "Embedded Binaries" inside the general tab of the main project worked for me.
As stated by bitwit, this will also add your framework to "Linked Frameworks and Libraries", so watch out for those duplicates.
Tested with Xcode 7.3.
Xcode 8.
Clean and build didn't work. I deleted the cache, deleted Derived data. After that, my pods configuration was broken, so i needed to install pods again. Pods Target configuration was set to a very old Valid architectures. setting to armv7 and armv7s, was ok to compile and no problems
You'll get this if your scheme has "Guard Edges" enabled in diagnostics when running on an actual device. "Guard Edges" only works in the simulator.
I was using cocoapods and had this problem as well when I updated to deploy target iOS 8 and added use_frameworks! to my Podfile. I was able to fix it by adding the following line to my Podfile:
link_with 'TargetName1', 'TargetName2', etc.
Might work with ProjectName as well

Library not found for -lXXX

If your trying to run an iphone project downloaded from the internet in Xcode and you encounter "Library not found for -lxxx", where -xxx is some third party library where would you look to set the library path? I am not sure where this is setup, in the SCM->library path is blank and everything else seems to match the configuration window for other working projects
When I look at the build log i see the following in the linker output:
-ObjC -ljson
How can i configure the project to not try to link in that library at build time?
if using cocoapods and getting this error, try updating the cococapods$ sudo gem update cocoapods Then update the pod for the project$ pod updateI don't know the exact reason but I think it was because the old version didn't set the libraries properly for the new XCode.Hope this helps.
Within the build tab of project settings there is a field for linker options, I removed the -ljson from here to solve the issue.
Either you need to add that library to add your project or you can remove from the project and delete all the reference.
This may help you, just click on the library and change the 'required' option.
This might be helpful in some cases:
Xcode > Preferences > Locations > Locations > Advanced, select Unique.
I was facing a similar issue and chaging to "unique" from "legacy" solved the problem

Core-plot configuration error

I am trying to use core-plot and I followed the instruction from the following project page to use it.
http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications, which is
You can install the SDK with a standard Mac installer package, or by hand. Here is how you install by hand.
Copy the CorePlotSDK directory to ~/Library/SDKs/
Add to your project's .PCH file:
#import < CorePlot/CorePlot.h >
Open Project -> Edit Project Settings and for All Configurations:
3a. Add to Additional SDKS:
$HOME/Library/SDKs/CorePlotSDK/${PLATFORM_NAME}.sdk
3b. Add to Other Linker Flags:
-ObjC -all_load -lCorePlot
Add the QuartzCore framework to the project.
Add a CPGraph to your application.
I went with the SDK install options: I installed it with Mac installer Package, it got installed in the following location /Library/SDKs/iphoneos.sdk and /Library/SDKs/iphonesimulator.sdk
Then i did step 2 as mentioned.
For 3a i added /Library/SDKs/iphonesimulator.sdk
Then i did 3b and then 4.
After that I tried to do a build and see how does it works and i get the following errors:
:1:0 :1:1: warning: "__IPHONE_OS_VERSION_MIN_REQUIRED" redefined
:1:0 :1:1: warning: this is the location of the previous definition
/var/folders/+r/+rBG+BziF1OqK12XNyw1ak+++TM/-Caches-/com.apple.Xcode.502/CompositeSDKs/iphonesimulator-iPhoneSimulator4.1-cztutytisanvsqaptkdkpoyyctln/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:250:0 /var/folders/+r/+rBG+BziF1OqK12XNyw1ak+++TM/-Caches-/com.apple.Xcode.502/CompositeSDKs/iphonesimulator-iPhoneSimulator4.1-cztutytisanvsqaptkdkpoyyctln/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:250: error: syntax error before '^' token
/var/folders/+r/+rBG+BziF1OqK12XNyw1ak+++TM/-Caches-/com.apple.Xcode.502/CompositeSDKs/iphonesimulator-iPhoneSimulator4.1-cztutytisanvsqaptkdkpoyyctln/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:250:0 /var/folders/+r/+rBG+BziF1OqK12XNyw1ak+++TM/-Caches-/com.apple.Xcode.502/CompositeSDKs/iphonesimulator-iPhoneSimulator4.1-cztutytisanvsqaptkdkpoyyctln/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:250: error: 'type name' declared as function returning a function
This appears 20 times. and it points all to UIView.h
There are same question in the stackoverflow and people suggested to change the compiler to 4.2 and for lot of people it worked, but for me the compiler was always set to 4.2 and still I get the same error.
On 3a if do /Library/SDKs/iphoneos.sdk
I get the following error
error: Composite SDK failed: The base SDK uses platform 'iphonesimulator', but an additional SDK uses platform 'iphoneos'. All SDKs must use the same platform (PLATFORM_NAME).
Please help
Finally, I have figured out the solution for this error:
Thanks to the developer on core-plot project and sebastien.leduc a google code user for their help.
I am using CorePlotInstaller_0.2.2.zip, and one important steps that is missing on the installation guide is you have to use LLVM GCC 4.2 and not GCC 4.2.
The other important steps which was little confused me was 3a.
Add to Additional SDKS: $HOME/Library/SDKs/CorePlotSDK/${PLATFORM_NAME}.sdk
Here you have to literally add the above line, I was changing the ${PLATFORM_NAME} with iphoneos or iphonesimulator, but no we don't have to do that.
One last thing if you don't find the sdk on the following path $HOME/Library/SDKs/CorePlotSDK
Check out /Library/SDKs/CorePlotSDK.
I hope this will help people, it took me about a week to figure out with the help of all the people who came forward to help.
I just posted a new version of the Core Plot installer that should resolve this issue. You can download it from http://code.google.com/p/core-plot/downloads/list.
You can choose to install Core Plot for all users or just your account. If you install for all users, change the Additional SDKs path from $HOME/Library/SDKs/CorePlotSDK/${PLATFORM_NAME}.sdk to /Library/SDKs/CorePlotSDK/${PLATFORM_NAME}.sdk.
I integrated core-plot into my application yesterday so it's fresh on my mind. I tried installing the SDK the same way you are and hit the same error. Comments in the google-group recommended NOT going this route, so I went back and installed the source code.
I ended up using the tutorial HERE for the basic steps and sample code. The code doesn't work anymore, but all the broken parts are answered in the comments (including a complete reposting of the code which works on the latest version).
Some stumbling points were that the "-ObjC" and "-all_load" flags were both needed, and when I added the header path the "search recursively" option wasn't checked off. Both these questions and many more are answered in the comments.