Xcode clang error when adding SDWebImage framework

只愿长相守 提交于 2019-12-25 07:01:02

问题


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)


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/32292187/xcode-clang-error-when-adding-sdwebimage-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!