I am trying to compile an app that use SDWebImage, when I add the framework to xCode I keep getting the following error.
I have attempted to add the framework by clone the git repo
ld: framework not found SDWebImage
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Linking in Xcode requires a bit of work. We can tell what to do or suggest a better way. As I consider "dropping framework" solution a very bad habit, I'd strongly suggest a better way:
Use dependency manager!
This will help you to see whenever your dependencies get new updates. You'll also know which version are you using. This is a good practice.
You can eg use Cocoapods. Go to your Terminal, type:
$ sudo gem install cocoapods
Then go to your project folder (place, where you have xcodeproj) and type:
$ pod init
This creates a file named Podfile. Open it and paste:
platform :ios, '8.0' // or whatever you need
use_frameworks!
pod 'SDWebImage', '~> 3.7'
So when you have it ready, open Terminal and type:
$ pod install
From now you should work on xcworkspace instead od xcodeproj. Your dependency should work correctly.
BTW: There are many other solutions. You can simply use git submodules. You can also use Carthage. However most popular and as for me atm most convenient way is Cocoapods, so I wrote steps for this way.
You've added SDWebImage as a linked framework.
What you should be doing is adding it as an Embedded framework, and make sure that your build phase copies the framework into your app bundle.
Related
I've been using Eclipse for a while now for java development and it is seamless. I considered using eclipse for C development also. I installed C/C++ IDE CDT 9.9 addon from the marketplace. I now can create a Makefile project and develop code. But, I'm not able to debug code. After some research, I understood that the native debugger CDT is integrated with, GDB is no longer shipped with macOS. So, at this point, I understood that I have two solutions:
Install GDB and everything works normally.
Install LLDB addon for Eclipse available at the marketplace and everything works normally.
I went on installing LLDB addon for Eclipse and when tried to debug, it showed me:
I checked it in the terminal and I found out that lldb is available and lldb-mi is not available. I googled it and found lldb-mi. To install lldb-mi as shown on the Github page, I needed to install CMake. When I try to generate build files for lldb-mi using CMake, it showed me:
After seeing this message, I thought I may need to install LLVM. I googled and found two ways:
Install from Homebrew
Compile and build from source code and install from it
I chose to go and compile the source code and install it. I downloaded llvm-9.0.0.src and generated build as instructed here. It took almost 2 hours and gave this error:
Now, as I understand it, I just generated build files(Makefiles) and compiled the LLVM source code. It's 19GB in size now. Should I go ahead and install it? or have I misinterpreted anything and did anything wrong?
As #Tsyvarev pointed out, using sudo, llvm got installed successfully. Now, lldb-mi needs to be installed. When I go back and cmake ., it's showing me this error:
Karthiks-MacBook-Pro:lldb-mi-master karthik$ sudo cmake .
-- Found LLVM 9.0.0
-- Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm
-- Building with -fPIC
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
lib_lldb
linked by target "lldb-mi" in directory /Users/karthik/Downloads/lldb-mi-master/src
-- Configuring incomplete, errors occurred!
See also "/Users/karthik/Downloads/lldb-mi-master/CMakeFiles/CMakeOutput.log".
As #squareskittles pointed, I understood that lldb-mi requires lib_lldb for cmake to generate build files. I did:
$git clone https://github.com/lldb-tools/lldb-mi
$cd lldb-mi
$mkdir build
$cmake -DCMAKE_PREFIX_PATH=path/to/llvm/root/tree -S . -B build/
CMake should generate all the build files into lldb-mi/build/. It is successful.
$cd build
$make
make should compile the code. It produced:
Karthiks-MacBook-Pro:lldb-mi karthik$ cd build
Karthiks-MacBook-Pro:build karthik$ make
[ 1%] Building CXX object src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o
In file included from /Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.cpp:10:
/Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.h:40:69: error: a space is required between consecutive right
angle brackets (use '> >')
: public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>> {
^~
> >
1 error generated.
make[2]: *** [src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/lldb-mi.dir/all] Error 2
make: *** [all] Error 2
Karthiks-MacBook-Pro:build karthik$
I put space between those > >, but there are still a lot of errors in the code.
I presume there are errors in the lldb-mi repository itself.
Can anyone tell me what I should be doing now?
Thanks in advance!
The lldb-mi not longer present from Xcode 11.x, but lldb and LLDB.Framework already included in the Xcode.
Use the lldb-mi that comes bundled with previous versions of XCode( 10.x) , the location is ‘Xcode.app/Contents/Developer/usr/bin/lldb-mi’, copy it to the same location of current version XCode.
And, in Eclipse, change the lldb command location.
Fine!
I am implementing firebase setup via pods.
My Pods file looks like following one.
# Uncomment the next line to define a global platform for your project
platform :ios, '8.0'
# $(PROJECT_DIR)/build/Debug-iphoneos/GoogleToolboxForMac lib search path
target 'ProductName' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for mCura
pod 'Firebase/Core'
pod 'Firebase/Messaging'
end
Everything is fine with iPad simulator. its running but when I run my application in iDevice. It shows library not found.
ld: library not found for -lGoogleToolboxForMac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have already wasted 2 days for removing this error & tried everything I could find on net. And GoogleToolboxForMac library automatically installs when firebase pod get installed.
I change my pod file to following code and re-install pod. It installed all necessary files for GoogleToolboxForMac.
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'ProductName' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'GoogleToolboxForMac', '~> 2.1'
end
After Installing pod
1) Change Scheme to Generic iOS Device and Build.
2) After build success you can see libGoogleToolboxForMac.a file in black colour instead of red.
3) Now select Device and run build on iDevice. Follow screenshot.
Or you can have build library libGoogleToolboxForMac.a
I was also getting this exception:
It fixed after opening the /platform/ios folder in Xcode instead of /platform/ios/MyApp.xcodeproj file.
I got the same error and it was fixed just by opening the project from the .xcworkspace file instead of the .xcodeproj.
Sigh.
For my Cordova project I just removed plugins, platforms and node_modules, readded IOS, and double clicked instead of using alt-down to open the xsworkspace and suddenly it magically worked.
Posting this here so I remember that it might be unnecessary to look for a real solution.
This StackOverflow question: Framework not found GoogleToolboxForMac had the answer that fixed this for me, but it was not the most highly upvoted answer. I had to go to the build settings for the GoogleToolboxForMac target and change the "Build Active Architecture Only" setting from Yes to No. Then clean and rebuild.
I entered the mysterious phenomenon that I can build my app for simulator but I can't build for real device. The error is as below (which doesn't appear when build for simulator):
ld: library not found for -lPods-TechMoviePlus
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(I'm using Cocoapods and attach one of my app's targets, so that the name of library is a little different.)
Project > Target > General > Linked Frameworks and Libraries is as below:
Thank you for your kindness!
Assigning the target in Podfile has resolved the problem.
target :TechMoviePlus do
pod "AFNetworking", "~> 2.0"
pod "LBGIFImage"
end
Open your pbxproj file with an editor and check for references to Pods-Application. If you renamed your application after pod install, you may have some references to the old pods.
Remove all the references to Pods-Application, launch xcode, full clean, and build.
It worked for me.
I'm trying to make a Cocoapod that depends on another but I'm having issues at compile time. Say in this case MyApp is using CocoapodA and CocoapodB, B relies on A.
MyApp Podfile:
platform :ios, '5.0'
pod 'CocoapodA'
pod 'CocoapodB', :path => '../../CocoapodB'
CocoapodB Podspec:
s.dependency 'CocoapodA'
but when I try to compile I get 'CocoapodA/CocoapodA.h' file not found where the import in CocoapodB is trying to include it.
I've tried reading the Podspec documentation but I didn't really get what I'm missing. I also tried s.library = 'CocoapodA'.
Make sure that you correctly specify header files for CocoapodA, for example:
s.public_header_files = 'CocoapodA/**/*.h'
My problem ended up being that the OTHER_LDFLAGS were being overridden. After selecting the Other Linker Flags key (build settings) and pressing backspace it now builds.
Weirdly I can only build on actual device; both simulator and archive are failing. They're probably caused by something else.
I want to use protobuf(https://code.google.com/p/protobuf/) in my project
Did you successfully compile protobuf with xCode 5, Please help to share your experience?
Thanks.
You can add support for Google Protocol Buffers to an Xcode 5 project using Cocoapods by adding the following line to your Podfile.
pod 'GoogleProtobuf', '~> 2.5.0'
This will place the C++ version of the protobuf code into a Pod for your project. It will also add the protoc compiler in the folder Pods/GoogleProtobuf/bin/protoc within your project.
You can create a custom build rule in your project that automatically converts the .proto files into .ph.{h,cc} files. Here is how I did that:
Setup a build rule to "Process Source files with names matching: *.proto Using Custom Script". The script should include the following:
cd ${INPUT_FILE_DIR}
${SRCROOT}/Pods/GoogleProtobuf/bin/protoc --proto_path=${INPUT_FILE_DIR} ${INPUT_FILE_PATH} --cpp_out=${INPUT_FILE_DIR}/cpp
Set the output files to include the following:
$(INPUT_FILE_DIR)/cpp/$(INPUT_FILE_BASE).pb.h
$(INPUT_FILE_DIR)/cpp/$(INPUT_FILE_BASE).pb.cc
Any .proto files you include in your project will now automatically be converted to C++ and then compiled as part of your build.
If you don't mind building Google Protobuf yourself then a good alternative to using Cocoapods is to run the bash script here.
https://gist.github.com/BennettSmith/7150245
This script will produce a proper build of Google Protobuf that supports the i386, armv7, armv7s, arm64 and x86_64 architectures. It will produce a static library that is universal. It will also produce the protoc compiler for use on OS X.