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

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.

Related

Xcode project giving pod file error for FIRAnalyticsConnector.framework . How to solve it?

I'm working on a book project and the project is connected by API . I'm working on the book app which has different libraries imported from the various places.
Recently, i cloned the project from bitbucket in Xcode and tried to run it. The result i got i error as follows:
enter image description here
It shows :
ld: in /Users/ishinfoservices/Documents/vadltaldhambooks/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRAnalyticsConnector_a8eeba373b74508311b8b22b8d3202a6.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/ishinfoservices/Documents/vadltaldhambooks/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Help needed to fix the error, as the project has lots of mixes of old libraries along with .h and .m files, the swift files with wireframes
According to the image I saw that you are trying run the app on the iOS simulator, then you could try to add the arm64 to the Excluded Architectures on the Build Settings section of your project or target, it would be like:
Take in mind that if you use Cocoa Pods is possible that also you should add the arm64 to the Exclude Architectures into the Pods project
After the above, clean, build and run the project on the iOS simulator, is possible that on your physical device you must remove the arm64 from the Exclude Architectures, it could depend on what you use in your project.
On the other hand, you can try the following: Select the project -> Select the target -> Go to the Build Phases -> Expand the Link Binary with libraries and add all pod libraries (remove if they exist in embedded binaries or Remove the old FrameWorks), after that, clean and build the project

Xcode 9.1 - Missing required architecture x86_64 in file

I am using the library SwipeCellKit and having problems since the update to Xcode 9.1. I've recompiled the library with Xcode 9.1 and reimported the .framework in my Project. But I still can't use the classes from the library. I am getting this warning:
ld: warning: ignoring file /Users/.../Frameworks/SwipeCellKit/SwipeCellKit.framework/SwipeCellKit, missing required architecture x86_64 in file /Users/.../Frameworks/SwipeCellKit/SwipeCellKit.framework/SwipeCellKit (2 slices)
I've tried what is suggested here and set Build Active Architecture Only to No when building the library. But it doesn't help. I've also cleaned the build folder many times, which doesn't solve the problem either.
Please always use Cocoapods to install libraries for your project, it will automatically manage all dependencies.
To setup you project for cocoapods please follow steps mentioned in http://cocoapods.org/ it will make your life easier believe me.
Once you setup cocoapods successfully,
then add
pod 'SwipeCellKit'
to your Podfile
and run terminal and goto your root project directory using cd ....
then type pod install
then open your root project folder using finder
and open YOUR_PROJECT_NAME.xcworkspace file and the issue will be gone gone,
let me know if you encounter any issue installing pods.
Thanks

weird error when trying to install ParseUI via CocoaPods

I'm trying to build an App using Parse as my backend and Xcode 7.0 & Swift 2. So in order to use PFQueryTableView, I need to use CocoaPods to install ParseUI first. I did this and used .xcworkspace to re-enter the project and then tried to compile and run it. But instantly I got this very nasty error:
ld: 823 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
These 2 lines are just the bottom 2 lines of the error messages, because there are a lot and they all start with something like:
duplicate symbol _OBJC_METACLASS_$_PFUserFileCodingLogic in:
or anything like that
I have many frameworks installed like Bolts, and it seems not a lot of people get this like me.
I had this same issue. I'd both installed Parse via Pods as well as by dragging the libraries into my Frameworks directory manually.
I removed the Pods directory and everything that said Pods from my app's build phases and it seemed to work out.

Cannot Archive when a library is included in my own iOS custom framework

I created my own iOS framework by following this tutorial, https://code.google.com/p/ios-static-framework/, which uses a static library template and aggregate target with a custom run script to create a framework.
At first it works fine. After including another library in the framework project creates the error when archive or build for device. I think the problem is with some wrong settings for that library. But I just don't know what to try. I have tried setting some sensible Other Linker Flags from https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ld.1.html , but no luck. Can anyone help please ;(
What steps will reproduce the problem?
Follow the tutorial, but change the Aggregate script architecture from armv6 armv7 to armv7 armv7s. Here is the part of the aggregate target script I changed. Everything else is the same.
if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
then
SF_OTHER_PLATFORM=iphonesimulator
SF_ARCHS=i386
else
SF_OTHER_PLATFORM=iphoneos
SF_ARCHS="armv7 armv7s"
fi
Add an external library to the project, here I use libBlocksKit.a.
Build the framework, success.
In another child project. Include my built framework.
Add -ObjC in the app Target > Build Settings > Other Linker Flags
Archive and get error. Building for device (iPhone5) gives error too. But building for simulator seems to work.
What is the error?
This error, basically "ld: warning: directory not found for option ... ld: lto: could not merge in ... symbol multiply defined!".
ld: warning: directory not found for option '-L/Users/hlung/Dropbox/- Notes/stackoverflow/RealFrameworkApp/RealFrameworkApp/External/BlocksKit'
ld: lto: could not merge in /Users/hlung/Library/Developer/Xcode/DerivedData/RealFrameworkTest-evagqzwzyyolhjenkkjbvzibxppf/Build/Products/Debug-iphonesimulator/RealFrameworkTest.framework/RealFrameworkTest(NSObject+BlockObservation.o) because 'Linking globals named 'OBJC_CLASS_$_BKObserver': symbol multiply defined!', using libLTO version 'LLVM version 3.2svn, from Apple Clang 4.2 (build 425.0.28)' for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I archive my child project with only one architecture (like armv7), it works. It shows this error with armv7 armv7s architectures ( $(ARCHS_STANDARD_32_BIT) ).
What version of the product are you using? On what operating system?
OS X 10.8.5, XCode 4.6.3
== Update 1 ==
Posted an issue at the tutorial's code.google.com page Update: 2 weeks no answer.
I found a set of useful suggestions from this answer. Update: Doesn't work
I have created a project so you can run and see for yourself here
Linking against a static library from within a framework can create some interesting challenges... It sounds like you may be linking to BlocksKit from both your framework and your application projects.
You should link in only one of those places. Try removing libBlocksKit.a from the Link Libraries build phase of your framework, but leave it in the other project.
You can do like this:
Click on your project (targets)
Click on Build Settings
Under Library Search Paths, delete the paths
I hope it can help you.

Linker error building project with Facebook SDK

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!

Resources