How to solve this error ”_OBJC_CLASS_$_MBProgressHUD", referenced from:? - ios

I have an existing project with different project name & workspace name. There is no podfile in the application folder. It has Pods folder with Pods.xcodeproj file. All other files are missing. But we can open and run the project using workspace file. Third party libraries are added manually. I have installed pod and created workspace with same name. I can open and run the application.
I have removed MBProgressHUD library and installed it using Cocoapods. After that I can’t run the application and got the following error message.
"_OBJC_CLASS_$_MBProgressHUD", referenced from: objc-class-ref in
BlackboardGroupController.o objc-class-ref in MenuController.o ld:
symbol(s) not found for architecture x86_64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)

Remove all CocoaPods and Integrate again. Please do the following steps to remove Cocoapods.
1.Delete the standalone files (Podfile Podfile.lock and your Pods directory)
2.Delete the generated xcworkspace
3.Open your xcodeproj file, delete the references to Pods.xcconfig and libPods.a (in the Frameworks group)
4.Under your Build Phases delete the Copy Pods Resources, Embed Pods Frameworks and Check Pods Manifest.lock phases.
5.This may seem obvious but you'll need to integrate the 3rd party
libraries some other way or remove references to them from your code.
pod deintegrate and pod clean are two designated commands to remove CocoaPod from your project/repo.
Here is the complete set of commands:
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile
Clear DerivedData :
rm -rf ~/Library/Developer/Xcode/DerivedData
Close Xcode and install cocoapods again

Related

Undefined symbols for architecture arm64: CLSBetaController block invoke in Crashlytics(CLSBetaController.o)

Hello Guys I have updated the pod files today in my projects and I saw Crashlytics got updated from 3.8.3 to 3.8.4. After installation I am trying to run the project but I am seeing this error & unable to build the project.
In Terminal
Installing Crashlytics 3.8.4 (was 3.8.3)
In Xcode Issues
Undefined symbols for architecture arm64:
"_FABNetworkMaximumRetryCount", referenced from:
___51-[CLSBetaController loadUpdateWithCompletionBlock:]_block_invoke in Crashlytics(CLSBetaController.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Open Podfile Source code
Remove the fabric & Crashlytics pods
pod 'crashlytics'
pod 'Fabric'
Install pods
pod install
Both Fabric and crashlytics pods will be removed.
Open the Podfile once again and Add both pods as shown below
pod 'crashlytics'
pod 'Fabric'
Install pods once again
pod install
`Finally update Run script
Select Project >> Select Target >> Build Phrases >> Under Run Script
"${PODS_ROOT}/Fabric/run" YOUR_API_KEY YOUR_BUILD_SECRET
Make sure you open the .xcworkspace file not the project (.xcodeproj) file when working with pods. That should solve the issue with linking.
This worked for me.
Follow all the instructions: Bring in the 2 Frameworks, Add to the plist, add the Run Phrase script, but don't add:
Fabric.with([Crashlytics.self])
Clean and Build the project. This time it should work OK. No "_FABNetworkMaximumRetryCount" error
Then add back in:
Fabric.with([Crashlytics.self])
to didFinishLaunchingWithOptions, and now build again. For some reason that worked for me.

cocoapods: library not found for

ld: library not found for -l<libname>
clang: error: linker command failed with exit code 1 (use -v to see invocation
I have got a such problem.
I've created a project in one Mac. But when I move project to another computer and try to add a new library from cocoapod the linker cannot find a new library.
I've tried a lot of features:
recreated via pod init.
pod update
cleared cache
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
Even reinstalled cocoapods.
removed old workspace file.
etc.
But none of them helped me. Please, help me find the solution.
A few hours later I found that I have to use $(inherit) flag for 'Library Search Path' . I do not know why it worked in the first computer without with flag.

Can't use SDWebImage

Xcode: Version 7.2
OS X: 10.10.5
I'm a newbie into iOS and trying to use SDWebImage in Objective-C by following the official installation guide, but I get this error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_SDWebImageManager", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I downloaded the zip file and unzip-ed it, and added the file to my project.
Also, added a dependency "ImageIO.framework" and Linker Flag "-ObjC".
Screenshot
I've already read these questions:
How to install SDWebImage
Undefined symbols for architecture arm64: “_OBJC_CLASS_$_PayTabCardReaderViewController”, referenced from: objc-class-ref in ViewController.o
Don't download and unzip. This is really the most horrible way to do things. Use CocoaPods, Carthage or at least git submodules. The "unzip way" makes code harder to maintain: you cannot know which version you imported (when you go back to this project in a year), noone knows where is the reference. People will manually change the source files, so later you won't be able to update to the newer version without losing these changes. You also have to setup your project manually, which as it seems, is troublesome for you (and many others, don't worry). Easiest way to fix it? Use CocoaPods.
To do it, open console and type:
$ sudo gem install cocoapods
Close your project in Xcode. Open the path to your .xcodeproj in console. Type:
$ pod init
Open .podfile. Paste there pod 'SDWebImage', '~> 3.7'. In console type:
$ pod install
When it completes, open .xcodeworkspace. Everything should be working fine now.
This might happen due to framework not linked up correctly into the app.
Simply try this steps:
Go to Targets -> Build Phases -> Link Binary with Libraries
Click on + symbol & add it from the project
Clean App & build again
Hope it will help to you.
pod deintegrate + pod install fixed it for me !!!

How to remove duplicate files generated through cocoa pods in iOS

I am using cocoa pods to integrate multiple third party files into my project.
I have to integrate below pod into my project
xcodeproj 'MyApp'
workspace 'MyApp'
source 'https://github.com/CocoaPods/Specs.git'
target :"MyApp", :exclusive => true do
platform :ios, '7.0'
pod 'AFNetworking', '2.0.2'
pod 'TwilioSDK', '~>1.2.2'
pod 'SocketRocket', '0.3.1-beta2'
pod 'AppRTC'
end
When I run pod install. I get duplicates as shown below..
When I build my app I am getting error
ld: warning: directory not found for option '-L/Users/anand/Documents/
Project/myApp_Backups/myApp_June/myApp_WEBRTC/Pods/build/Debug-
iphoneos'
duplicate symbol _MD5_Update in:
/Users/anand/Documents/Project/myApp_Backups/myApp_June/
myApp_WEBRTC/Pods/AppRTC/Lib/libWebRTC.a(nss_static.md5.o)
/Users/anand/Documents/Project/myApp_Backups/myApp_June/
myApp_WEBRTC/Pods/TwilioSDK/Libraries/libcrypto.a(md5_dgst.o)
duplicate symbol _SHA1_Update in:
duplicate symbol _OBJC_IVAR_$_SRIOConsumer._readToCurrentFrame in:
/Users/anand/Library/Developer/Xcode/DerivedData/myApp-
gxdbyoohznnpigavdqmaeilzlavd/Build/Products/Debug-iphoneos/libPods-
myApp-SocketRocket.a(SRWebSocket.o)
/Users/anand/Documents/Project/myApp_Backups/myApp_June/
myApp_WEBRTC/Pods/AppRTC/Lib/libWebRTC.a(socketrocket.SRWebSocket.o)
ld: 71 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I thought to do below solutions:
1) Remove SRWebSocket.h file -- but it may get errors as it is in Pods.
2) Remove pod 'SocketRocket', '0.3.1-beta2' from pod file and run pod install -- but I used both SRWebSocket.h and SRWebSocket.m in my project before installing AppRTC into my project..!
Please suggest how can I solve this issue..
Thanks in Advance..!
I have fixed the above issue as below
At my Xcode project -- Build Settings -- Other linker Flags -- I removed -all_load then some of the duplicate errors are gone.
Still I get Socket Rocket duplicate warnings after the above solution.
I fixed this by going to Pods Project -- Selected Socket Rocket pods target -- Removed the SRWebSocket.m file from Compiling. It works fine and duplicates are removed.
Thanks for all answers..
You need to remove the socketrocket object code from libWebRTC.a
run lipo -info libWebRTC.a to see what architectures are in the library (current version is i386, armv7, and arm64)
Then run
lipo libWebRTC.a -thin i386 -output libWebRTC-i386.a
Do this for each architecture by replacing i386 with the relevant value. You then need to extract the object files from each archive.
mkdir libWebRTC-i386 && cd libWebRTC-i386 && ar -x ../libWebRTC-i386.a
Do this for each of the new single architecture libraries you've just created. In each of the new folders you will find .o files that contain "socketrocket" - delete these.
Then re-archive the object files for each architecture
libtool -static *.o -o ../libWebRTC-i386.a
Once you have done this re-combine them into a fat library
lipo -create libWebRTC-armv7.a libWebRTC-arm64.a libWebRTC-i386.a -output libWebRTC.a
And voila, it should now work. Really the libWebRTC.a binary needs re-building without the socket rocket object code, and socket rocket should be added as a dependency to the podspec.
Solution
Backup your project
Close the Xcode
- install this gem on terminal:
https://github.com/kylef/cocoapods-deintegrate
run the command line below :
pod deintegrate
remove the Podfile.lock file in your project directory
run install again :
pod install
Open Xcode and Clean your project and Derived Data directory then run again
Hope this solution will fix your problem.
Best
In your build phases, check to see that you aren't compiling the same file more than once.
In your case, maybe there're two same m files in Compile Sources, just remove one and try to rebuild.
Follow the below steps to resolve your duplication symbol error.
1) Select your Xcode Project > Navigate to "Build Phases".
2) From there, search the file name for which you are getting duplication.
3) If possible, then there might be more than one ".m files" for your search keyword.
4) Remove all the files except one which you need to actually compile.
5) Same way follow the process for all the duplicate error
6) That's it! Your problem will be solved for sure.
Create an issue for AppRTC repo to remove the header and set a dependency on SRWebSocket instead.
As a temporary solution - link AppRTC to a local path with :path directive and remove this file from the local directory. Or you may link to a local podspec file with ignorance on SRWebSocket header in exclude_files config.
Now it's very easy to remove duplicate pod files or any pod which is not in use for your project.
open your pod file.
comment all pod file which you want to remove.
use commend pod install
you will your all comment pod will remove in terminal
Enjoy your day with a cup of tea or coffee while doing code.

Xcode Compiler Error: ld: library not found for -lPods

I'm trying to use the pod library to the project "BC LitterBox", after install pod according to http://cocoapods.org/ and Complier LitterBox, I'm now down to 1 compilation error, which I can't seem to get rid of.
ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Anyone know what could be causing this?
When you install a pod, CocoaPods creates a new workspace that includes your project and whatever pod(s) you installed.
You'll have to close your project and open that workspace.
Make sure you are opening the .xcworkspace file, not the .xcodeproj
You can perform this steps:
Close .xcworkspace and .xcproject (Xcode Projects);
Run pod install and pod update;
Open the new .xcworkspace;
Clean and Build your Project;
Now, you are able to run normally.
When I try compile my project which used CocoaPods I have following linking error:
ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The reason of this problem is version of CocoaPods. Project was cloned from repo, then pods was installed. But my version of cocoapods is 1.0.1. Version of cocoapods which declared in Podfile.lock is 0.39.0.
Solution is following(In terminal):
1) Uninstall CocoaPods.
sudo gem uninstall cocoapods
2) Install version of cocoapods which declared in the Podfile.lock
sudo gem install cocoapods -v 0.39.0
3) You can check version cocoapods:
gem which cocoapods
4) Clone project then install dependencies
pod install

Resources