SwiftLinkPreview alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view SwiftLinkPreview alternatives based on common mentions on social networks and blogs.
-
SwifterSwift
A handy collection of more than 500 native Swift extensions to boost your productivity. -
SwiftGen
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
R.swift
Strong typed, autocompleted resources like images, fonts and segues in Swift projects -
SwiftGen-Storyboard
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
swift-protobuf
Plugin and runtime library for using protobuf with Swift -
Dollar
A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript -
ExSwift
a set of Swift extensions for standard types and classes. -
EZSwiftExtensions
:smirk: How Swift standard types and classes were supposed to work. -
DifferenceKit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection. -
LifetimeTracker
Find retain cycles / memory leaks sooner. -
Result
Swift type modelling the success/failure of arbitrary operations. -
DeepDiff
🦀Amazingly incredible extraordinary lightning fast diffing in Swift -
Device
Light weight tool for detecting the current device and screen size written in swift. -
WhatsNew
Showcase new features after an app update similar to Pages, Numbers and Keynote. -
Codextended
Extensions giving Swift's Codable API type inference super powers 🦸♂️🦹♀️ -
AwesomeCache
Delightful on-disk cache (written in Swift) -
Popsicle
Delightful, extensible Swift value interpolation framework. -
Playbook
📘A library for isolated developing UI components and automatically taking snapshots of them. -
SwiftyJSONAccelerator
macOS app to generate Swift 5 code for models from JSON (with Codeable) -
PDFGenerator
A simple generator of PDF written in Swift. -
ReadabilityKit
Preview extractor for news, articles and full-texts in Swift -
Compass
:earth_africa: Compass helps you setup a central navigation system for your application -
ObjectiveKit
Swift-friendly API for a set of powerful Objective C runtime functions. -
Solar
A Swift micro library for generating Sunrise and Sunset times. -
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift -
Rugby
🏈 Cache CocoaPods for faster rebuild and indexing Xcode project. -
Pythonic.swift
Pythonic tool-belt for Swift – a Swift implementation of selected parts of Python standard library. -
BetterSafariView
A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI. -
SwiftyUtils
All the reusable code that we need in each project -
SwiftPlantUML
A command-line tool and Swift Package for generating class diagrams powered by PlantUML
InfluxDB - Power Real-Time Data Analytics at Scale
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SwiftLinkPreview or a related project?
README
[Swift Link Preview](Images/badge.png)
Link Previewer for iOS, macOS, watchOS and tvOS
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Index
- Visual Examples
- Requirements and Details
- Installation
- Usage
- Flow
- Important
- Tips
- Information and Contact
- Related Projects
- License
Visual Examples
UTF-8 | Extended UTF-8 | Gallery |
---|---|---|
[UTF-8](Images/default.gif "UTF-8") | [Extended UTF-8](Images/langs.gif "Extended UTF-8") | [Gallery](Images/gallery.gif "Gallery") |
Video Websites | Images | |
[Video Websites](Images/videos.gif "Video Websites") | [Images](Images/images.gif "Images") |
Requirements and Details
- iOS 8.0+ / macOS 10.11+ / tvOS 9.0+ / watchOS 2.0+
- Xcode 8.0+
- Built with Swift 3
Installation
CocoaPods
To use SwiftLinkPreview as a pod package just add the following in your Podfile file.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'Your Target Name' do
use_frameworks!
// ...
pod 'SwiftLinkPreview', '~> 3.4.0'
// ...
end
Carthage
To use SwiftLinkPreview as a Carthage module package just add the following in your Cartfile file.
// ...
github "LeonardoCardoso/SwiftLinkPreview" ~> 3.4.0
// ...
Swift Package Manager
To use SwiftLinkPreview as a Swift Package Manager package just add the following in your Package.swift file.
import PackageDescription
let package = Package(
name: "Your Target Name",
dependencies: [
// ...
.Package(url: "https://github.com/LeonardoCardoso/SwiftLinkPreview.git", "3.4.0")
// ...
]
)
Manually
You just need to drop all contents in Sources
folder, but .plist files, into Xcode project (make sure to enable "Copy items if needed" and "Create groups").
Usage
Instatiating
import SwiftLinkPreview
// ...
let slp = SwiftLinkPreview(session: URLSession.shared,
workQueue: SwiftLinkPreview.defaultWorkQueue,
responseQueue: DispatchQueue.main,
cache: DisabledCache.instance)
Requesting preview
let preview = slp.preview("Text containing URL",
onSuccess: { result in print("\(result)") },
onError: { error in print("\(error)")})
// preview.cancel() to cancel it.
result is a struct Response
:
Response {
let url: URL // URL
let finalUrl: URL // unshortened URL
let canonicalUrl: String // canonical URL
let title: String // title
let description: String // page description or relevant text
let images: [String] // array of URLs of the images
let image: String // main image
let icon: String // favicon
let video: String // video
let price: String // price
}
Cancelling a request
let cancelablePreview = slp.preview(...,
onSuccess: ...,
onError: ...)
cancelablePreview.cancel()
Enabling and accessing cache
SLP has a built-in memory cache, so create your object as the following:
let slp = SwiftLinkPreview(cache: InMemoryCache())
To get the cached response:
if let cached = self.slp.cache.slp_getCachedResponse(url: String) {
// Do whatever with the cached response
} else {
// Perform preview otherwise
slp.preview(...)
}
If you want to create your own cache, just implement this protocol and use it on the object initializer.
public protocol Cache {
func slp_getCachedResponse(url: String) -> SwiftLinkPreview.Response?
func slp_setCachedResponse(url: String, response: SwiftLinkPreview.Response?)
}
FLOW
Important
You need to set Allow Arbitrary Loads
to YES
on your project's Info.plist file.
If you don't want to use the option above and you are using SwiftLinkPreview
for services of your knowledge, you can whitelist them on Info.plist file as well. You can read more about it here, here and here.
Tips
Not all websites will have their info brought, you can treat the info that your implementation gets as you like. But here are two tips about posting a preview:
- If some info is missing, you can offer the user to enter it. Take for example the description.
- If more than one image is fetched, you can offer the user the feature of picking one image.
Tests
Feel free to fork this repo and add URLs on [SwiftLinkPreviewTests/URLs.swift](SwiftLinkPreviewTests/URLs.swift) to test URLs and help improving this lib. The more URLs the better the reliability.
Information and Contact
Developed by @LeonardoCardoso.
Contact me either by Twitter @leocardz or emailing me to [email protected].
Related Projects
License
The MIT License (MIT)
Copyright (c) 2016 Leonardo Cardoso
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Follow me for the latest updates
*Note that all licence references and agreements mentioned in the SwiftLinkPreview README section above
are relevant to that project's source code only.