Linker error building project with Facebook SDK - ios

I just added the latest Facebook SDK code from Github to my project. Because I'm using ARC, I used their supplied shell script to build the static library. I added it to my project and made sure the static library is being linked, but I'm receiving this linker error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_FBFrictionlessRequestSettings", referenced from:
objc-class-ref in libfacebook_ios_sdk.a(Facebook.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here are the linker settings:
Any ideas?

The head revision has some recent changes that seem to have broken ARC builds (static library). The static library builds ok, but then when used in my project I get the linker errors. What I did to fix the problem was to revert to the previous version of the Facebook sdk and these linker errors went away.
See https://github.com/facebook/facebook-ios-sdk/commits/master
I used the version checked in on the 24th Feb (not 25th Feb, sorry Jason Clark!)
https://github.com/facebook/facebook-ios-sdk/tree/9acf74345bb248d698966eac9a3057a4b4be1b0f

The Feb 25th commit has FBFrictionlessRequestSettings.m missing from the xcode project so it is not included in the static link library eventhough the header is.
1.- Clone the latest repo, at the time of this post the latest commit is: https://github.com/facebook/facebook-ios-sdk/commit/4e3567c40e3b7f8156a82f18e5a2f5cd18e077eb
2.- Open the xcode project facebook-ios-sdk.xcodeproj under the src directory
3.- Add FBFrictionlessRequestSettings.m under FBConnect.
4.- Using the project Navigator, make suer FBFrictionlessRequestSettings.m is listed in build phases under compile sources
5.- Save and close xcode project
6.- Run scripts/build_facebook_ios_sdk_static_lib.sh to build most recent static linked library and follow installation instructions, you should be able to compile and link your project without any issues.
Better yet, clone this repo and build it. All ready to go https://github.com/alvarezm50/facebook-ios-sdk

Looks like something whent wrong when building your fb-ios-sdk … Everything up2date and there were no errors when building the static lib?
I have no problems getting the latest version of the SDK up & running in the simulator or on my iOS5 device.
Here's what I did (OS X 10.7.3, Xcode 4.2.1, iOS5 ARC)
Grab the lastest source files: https://github.com/facebook/facebook-ios-sdk/zipball/master
Unzip files & build it cd ~/facebook-ios-sdk/scripts/ && ./build_facebook_ios_sdk_static_lib.sh
Now grab the facebook-ios-sdk folder inside ~/facebook-ios-sdk/lib/, put into your Xcode project foler like this: http://cl.ly/1X3B203f272z2l0w2t39 & link against libfacebook_ios_sdk.a in Xcode
Add ${SOURCE_ROOT}/facebook-ios-sdk to your Header Search Paths

I have tried this procedure and able to fix it.
Select Your project Target -> build phases ->compile Sources
add all the .m files from facebook static library also json static library.
Now if you run the app it wont throw any linker errors.

I had the same issue. It turned out to be fairly trivial. I do use XCode's support for git, preferring to use the command line. However, this means that I need to make sure that every time I pull from git I also add any new files and remove all deleted files. In this case, FBFrictionlessRequestSettings.* did the trick.
File->Add Files to "My Project"

This has been fixed in master as of 2/27. Please pull the master and that should take care of this issue.
https://github.com/facebook/facebook-ios-sdk/commit/e10bdc15b31ab23b229f1f3e77b0e8d7affe60af
Thanks!

Related

1Password Pods iOS library not found

I resume an project from someone else in my company who make a iOS apps using 1password pods.
i have a build error , i search on the web but i dont found a solution.
maybe can you help me.
here the error :
ld: library not found for -l1PasswordExtension
clang: error: linker command failed with exit code 1 (use -v to see invocation)
thanks in advance
I've run into this problem a few times when using cocoapods. Some of the solutions on this SO post have helped me before Cocoapods ld: library not found for -lPods-Projectname
Also, the official cocoapods site has some help for this issue on their troubleshooting page https://guides.cocoapods.org/using/troubleshooting.html:
If Xcode complains when linking, e.g. Library not found for -lPods, it doesn't detect the implicit dependencies:
Go to Product > Edit Scheme
Click on Build
Add the Pods static library, and make sure it's at the top of the list
Clean and build again
If that doesn't work, verify that the source for the spec you are trying to include has been pulled from GitHub. Do this by looking in /Pods/. If it is empty (it should not be), verify that the ~/.cocoapods/master//.podspec has the correct git hub url in it.
If still doesn't work, check your Xcode build locations settings. Go to Preferences -> Locations -> Derived Data -> Advanced and set build location to "Relative to Workspace".
If all else fails, you can always try deleting the Xcode workspace and the Pods directory, then re-running 'pod install' to see if that clears things up.
Thanks Rob T, i edit the scheme and now it's work.
just before to run i made a pod install.

Static library and cocoapods with Xcode 6.1.1 - ld: library not found Error

Not sure it is related to Xcode 6.1.1 or Cocoapods 0.35.0.
I have generated new static iOS library with Xcode 6.1.1.
SUCCESS (without cocoapods)
Generate simulator and Device library
Lipo to both and generate FAT MyLib.a static final lib
Create new View Application project. (I haven't changed any default setting. e.g. Base SDK, Valid Architecture.)
Add MyLib.a and necessary header files to application project manually.
Build the app project and IT WORKS FINE !! NO ERROR NO WARNING.
ERROR
Upload same MyLib.a & headers (generated above) to HTTP direct download server(kind of artifact server).
Generate specs & podfile.
Remove all dependency (lib and header) from app project which i have done manually earlier.
Add pod file and local specs
"Pod install" command pull out MyLib.a and header properly in /Pods folder.
But while building the app project gives me
Ld Build/Products/Debug-iphonesimulator/LibTest.app/LibTest normal x86_64
cd /Users/admin/Cocoapods/Project/Library/TestProject/LibTest
export IPHONEOS_DEPLOYMENT_TARGET=8.1
ld: library not found for -lMyLib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When i fire "lipo" command on MyLib.a
Architectures in the fat file: /Users/admin/Cocoapods/Project/Library/Libs/Final/MyLib.a are: armv7 armv7s i386 x86_64 arm64
Its not really architecture issue otherwise it should get failed in my first attempt which doesn't have cocoapods. Cocoapods does some build configuration changes and that creates this issue.
Help me to resolve this issue.
After spending 2 days to figure out the exact issue, i found very silly fix. Its basically issue with static library naming convention issue.
If you have static library in artifact/media http server and wanted to integrate with Cococapods, make sure library name should be lib(your name).a along with headers.
In my case i have kept MyLib and it got dowloaded currently while "pod install" but during app building it was failing.
After renaming to libMyLib.a, every thing works for me. :)
Very easy to apply yet difficult to find such solution]
Not sure whether cocoapods has documented this in there any guide or not.

Debug scheme won't build - Apple Mach-O Linker Error. Linker command failed with exit code 1

ld: library not found for -lPods-AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I get this error way too often and it's driving me (and the team nuts). The project was building just fine last week and I did nothing to the project in the mean time, just opened it yesterday and now I'm getting this error when building using the Debug scheme only; Adhoc builds fine. I'm running the latest Yosemite, Xcode 6.1 (but this has plagued me for many months anyway). My instructions to resolve it work occasionally, like black magic:
Clean
Restart Xcode
Delete derived data (check preferences/locations)
Pod update
Open project using the Workspace file
Delete the workspace file and run pod install
But unfortunately this time it's just not working! I've done this process over and over. I'm so frustrated with this PoS Xcode. Next step would be to re-download the project from Git, but there must be a better way! I have gone through a number of other stack overflow posts but found nothing to help (nor anything very recent). Thanks!
The same error drove me nuts for two days. I fixed through the following :
Project > Targets > Build Settings > Packaging > Product Name - Check if the product name has changed.
Also try setting the Build Active Architecture to NO in your project..
Project/Pods > Build Settings > Architectures > Build Active Architecture Only
Just delete the build folder of your project and rebuild it again. Always works for me!

Linker errors after upgrading Xcode to 4.5.2 and OpenCV to 2.4.3

My project was working just fine until this morning. I was using xcode 4.3, and an older version of OpenCV (I'm not sure about the exact version). OSX was already 10.7.x, but not 10.7.5
Today, after upgrading OSX to 10.7.5, xcode to 4.5.2, and downloading OpenCV 2.4.3, I am getting the following linker errors when trying to build the project:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ALAssetsLibrary", referenced from:
objc-class-ref in opencv2(cap_ios_video_camera.o)
"cv::FeatureDetector::create(std::string const&)", referenced from:
-[ImageAnalyzer detectBlobs:] in ImageAnalyzer.o
"cv::FeatureDetector::detect(cv::Mat const&, std::vector >&, cv::Mat const&) const", referenced from:
-[ImageAnalyzer detectBlobs:] in ImageAnalyzer.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
In order to use the new opencv framework I removed the reference to the old framework, and referenced the project to the official prebuilt opencv2.framework downloaded from here.
I also removed the reference to libz.dylib, and added a reference to libc++.dylib instead.
Last step was to update the prefix file to the new framework. The relevant part in the prefix file now looks like this:
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
It all narrowed down to these 4 linker errors I can't seem to get rid of. I tried using libstdc++.dylib, but I am getting even more errors. I also tried building OpenCV myself as explained here, but I am still getting the same errors as the prebuilt framework.
What did I miss? Is there anything else I need to change in my project?
UPDATE:
As seen here, setting the "C++ Standard Library" to "libc++ (LLVM C++ standard libray with C++ 11 support" yielded only one error:
clang: error: invalid deployment target for -stdlib=libc++ (requires iOS 5.0 or later)
Changing the deployment target to iOS 5 finally got my project to run again.
Does this mean OpenCV 2.4.3 doesn't work on iOS versions older than 5?
steps to compile and run c++ opencv 2.4.4 on mac os x lion 10.7.5 with cmake 2.8.10 and xcode 4.6.1
Having the right tools
download opencv-unix from http://sourceforge.net/projects/opencvlibrary/files/ and untar it wherever
download cmake .dmg from http://www.cmake.org/cmake/resources/software.html and install it
i am assuming you have xcode 4.6 on os x lion which includes the ios sdk 6.1
go to xcode preferences to download and install the Command Line Tools so you have g++ etc.
Use cmake to compile opencv
go to the extracted opencv folder
create a build directory
mkdir build
cd build
cmake -D WITH_TBB=OFF -D BUILD_NEW_PYTHON_SUPPORT=OFF -D BUILD_FAT_JAVA_LIB=OFF -D BUILD_TBB=OFF -D BUILD_EXAMPLES=ON -D CMAKE_CXX_COMPILER=g++ CMAKE_CC_COMPILER=gcc -D CMAKE_OSX_ARCHITECTURES=x86_64 -D BUILD_opencv_java=OFF -G "Unix Makefiles" ..
make -j8
sudo make install
from the build folder, go to bin/ and run one of the tests
./opencv_test_stitching
Create your own c++ opencv xcode project
fire up xcode and create a new xcode project
select Command Line Tool for the type of project under os x
open your project's build settings
under Architectures, set Architecture to 64-bit intel. also set Valid Architectures to x86_64
under Build Options, set Compiler for C/C++ to Default Compiler
under Search Paths, set Header Search Paths to /usr/local/include
also under Search Paths, set Library Search Paths to /usr/local/lib
under Apple LLVM compiler 4.2 - Language set C++ Standard Library to libstd++ (For OpenCV 2.4.6, Xcode 5, LLVM 5.0, and 10.8.5, set both language dialect and std library to "Compiler Default" instead of "libstd++")
Add the compiled opencv libraries to your project
go the the Build Phases tab next to Build Settings tab you were in
inside Link Binary With Libraries, click on the + sign and choose Add Other
hit the front slash / on your keyboard and enter /usr/local/lib
hit enter and select the libraries you want to use in your project
make sure you always select libopencv_core.2.4.4.dylib
hit enter and you will see the selected dylibs under your project
write some code
first lets organize the files, right click on your project blueprint icon and select New Group
name the new group opencv or whatever
drag the dylibs and drop them in that group
open main.cpp
copy code from any of the sample tests that came with opencv and paste it here
make sure all the required dylibs are added, for example, if you copied the opencv_test_stitching.cpp code into main.cpp, you will need to add the following libraries in the previous steps
libopencv_core.2.4.4.dylib
libopencv_highgui.2.4.4.dylib
libopencv_stitching.2.4.4.dylib
Cheers.
It seems that your project is missing the framework AssetsLibrary.
Select the top node in the project navigator. (The project and targets page with the build settings appears.)
Select the target.
Select Summary.
Scroll down to Linked Frameworks and Libraries.
Click the Plus icon at the end of the table and select AssetsLibrary.framework.
Click Add.
Then try to build it again.
Since I can't seem to get an answer regarding the versions (neither here nor at the OpenCV Q&A site), I'm going to post this as an answer, as it at least solved the issue. This is described here.
In your project's Build Settings, go down to the section Apple LLVM compiler 4.1-Language.
There:
Set C++ Language Dialect to Compiler Default
Set C++ Standard Libray to libc++ (LLVM C++ standard libray with C++ 11 support
After doing the above, I stopped getting those linker errors, and only got one error instead, which stated that only iOS 5 and above is supported. Changing the Deployment Target to 5.0 in the project summery did the trick.
On a final note, I'm still not sure what it means, regarding OpenCV 2.4.3's compatibility with iOS versions older than 5.
clang: error: invalid deployment target for -stdlib=libc++ (requires iOS 5.0 or later) to remove this error.
GoTo BuildSettings. Set c++ standard library to compiler default. The
error will get removed surely.
Just to get this into the postings somewhere in case someone else runs into the same thing. If you follow all the great advice aboutsetting the proper c++ library to link against for building an iOS app BUT still get the link errors for undefined symbols make sure your code files are set to compile as c++! That is rename your .m to .mm and .h to .hpp. It's the little things...
Instead of using terminal commands given in the opencv installation guide in official website, use the following commands to build opencv from terminal. Worked for me.
cd OpenCV-2.3.1
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
sudo make install
Go Xcode/General/Linked Frameworks and Libraries
Press "+" button
type: AssetsLibrary
Select "AssetsLibrary.framework" and import it
Done
Good luck!

clang: error: linker command failed with exit code 1, only when testing on device

I was just about to test my app on a device when I ran into this problem, I'm getting this Linker Error.
I've already checked all my compile sources and Build Phases, but there's no sign of my importing things twice.
ld: duplicate symbol _calculateNextSearchPage in /Users/wouter/Sites/test/FastPdfKit.embeddedframework/FastPdfKit.framework/FastPdfKit(FastPdfKit) and /Users/wouter/Sites/test/FastPdfKit.embeddedframework/FastPdfKit.framework/FastPdfKit(FastPdfKit) for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This only happens when testing on a device, not in the simulator.
Alright guys I had the same problem. Seems like I fixed it.
I am using cocapods therefor the described standard procedure can not be properly executed.
Steps to do to properly add FastPDFKit with Cocoapods.
Download FastPDFKit
In your project Add Files to "Your Project"
go to FastPDFKit folder you just have downloaded
locate 1 folder and 1 project file. Press and hold Command key and add these in to your project
FastPdfKit.xcodeproj
FastPdfKit.embeddedframework
(Note: FastPdfKit.embeddedframework is the actual Framework and you
might want to open FastPdfKit.xcodeproj standalone before adding it
to your project, delete FastPdfKit.embeddedframework folder from
your disk and Build FastPdfKit target in the project. You should see
newly created FastPdfKit.embeddedframework folder)
Go to your Project Settings > Your target > Build Phases > Link Binary with Libraries
Make sure FastPdfKit.framework is there.
If not, drag it from the project and put it there.
Clean the project, delete derived data
Add #import <FastPdfKit/FastPdfKit.h> where you need it and you are good to go.
Here is how my Link Binary with Libraries look like
Please let me know if you have any troubles I might've missed something.
Try to delete duplicate files/images which are in target-> Build phase -> Compile files, Copy bundle resources

Resources