-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image format support SVG #50
Comments
SDWebImage’s decoding system is plugin based and extensiable. Here we already have one https://github.com/SDWebImage/SDWebImageSVGCoder Note this SVG plugin previously need a new UIView subclass Checkout that SVGCoder’s https://github.com/SDWebImage/SDWebImageSVGCoder/tree/iOS13_SVG branch, which can be used with our |
However, seems the best vector format on iOS platform. is the PDF, which Apple have all built-in support. I strongly recommend to create Vector PDF instead. Which is portable and easy to use compared to SVG. Using https://github.com/SDWebImage/SDWebImagePDFCoder can simply add support to PDF vector without lossing details, you can try to use our demo and run the showcase code. |
I'm not adding xcode. Dont You have a library for SwiftUI. |
Emm. I guess you means:
Those two coder plugins does not support SwiftPM now. Because some of them, using the upstream dependency which does not support SwiftPM (dependency is a recursive problem). You can try to use CocoaPods firstly (try our demo, see readme), CocoaPods is easy and the most adoptable dependency manager in Cocoa. But if you want, I can provide a special compatble version which use SwiftPM (those PDF/SVG coder) |
@mkalayci35 |
@mkalayci35 |
So, it's supported. Here is the run demo with some sample SVG/PDFs. Note only
|
Can you send me the sample code? |
No code actually. Just use the coders and // AppDelegate.swift
import UIKit
import SDWebImage
import SDWebImageWebPCoder
import SDWebImagePDFCoder
import SDWebImageSVGCoder
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// Add WebP support
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
return true
}
}
// ContentView.swift
var body: some View {
AnimatedImage(url: "https://raw.githubusercontent.com/icons8/flat-color-icons/master/pdf/stack_of_photos.pdf")
} |
Specify branch. I already mentioned, use |
Or just use CocoaPods. I don't like SwiftUI actually (it's a young toy with compared to other package manager for real-world complicated software develop and dependency). target 'SDWebImageSwiftUIDemo' do
platform :ios, '13.0'
pod 'SDWebImageSwiftUI', :path => '../'
pod 'SDWebImageWebPCoder'
pod 'SDWebImagePDFCoder'
pod 'SDWebImageSVGCoder', :git => 'https://github.com/SDWebImage/SDWebImageSVGCoder.git', :branch => 'iOS13_SVG'
end |
SwiftUI is good for me. Increased my coding and design skills. I just started writing. Well, can't you make the Swift Pack compatible? I don't want to upload pods :( |
This is compatible. Use the branch dependency of SwiftPM. I can not merge that into master and release, for now. Because all current user who use that framework, it's desigend to use SVGKit (another SVG parser), and support iOS 8+. I'm a framework author, should not break my user's code. Or user will blame you. This is the responsibility. I'm considered to release a major version bump for SVGCoder (which drop SVGKit support). But this need extra consideration (such like naming ? How my current user migrate ? How can these two solution be used seamlessly). There're things to considerate and need time. For now, just use the branch dependency. You can see that Xcode GUI have a nice checkbox to use |
oo okay, https://github.com/SDWebImage/SDWebImageSVGCoder/tree/iOS13_SVG I get it now. :) :D |
I installed. Thank you very much. I got it late. Sorry :) |
@mkalayci35 WebP coder does not support SwiftPM. This is because libwebp (The upstream dependency) does not support. Simple answer. The repo is maintained by Google. It's better to ask them for help. If you want to see all our coder plugins to support SwfitPM, this need time. Previouslly, I need to wait the codec author (Google, for example, the maintainer of libwebp) to support it. However, if they can not, we have another backup solution, to just fork their repo and provide one support. Though I don't like this, but it's a reasonable solution. Or we can use our Carthage package repo: https://github.com/SDWebImage/libwebp-Xcode. To add support here. Here already a PR: SDWebImage/libwebp-Xcode#3 |
But since SwiftPM is sucked to just use
Both of them are not a really good idea for me. This is reason why I delay the support of our coder plugins for SwiftPM. Until some one have a better idea or we have to choose one. |
@mkalayci35 The SDWebImageSVGCoder v1.0.0 released. We drop the original SVGKit support into another repo. For you, the |
@mkalayci35 Another note:
The Animated ImageView will show a
|
thank you so much my app really work now Thank you so so much!! |
How do you initialise the SVG Coder for a SwiftUI project? It doesn't have an AppDelegate file. Thanks! |
For pure SwiftUI project, just use |
Or you can just mixed to use AppDelegate and SwiftUI at the same time. SwiftUI is not magic, it still need The |
@dreampiggy I'm getting this error while following the instructions both on your comment and on this thread. Unless I'm missing something on a pure SwiftUI project. Thanks for the links btw! |
@netgfx Found you're really new to iOS dev. The UIApplicationDelegate, is a protocol, so, you must implementation the code in a protocol method. Normally, put this into the https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428385-applicationdidfinishlaunching this method. Suggestion: You can start learning iOS dev by a full tutorial, not just try something from the part. Like: |
How can we change the colour of |
Can you add svg support?
The text was updated successfully, but these errors were encountered: