Skip to content
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

Upgrade to Xcode 12, Swift 5 and add support for SPM #80

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
5.0
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode10.1
osx_image: xcode12.0.1
before_install:
- gem install xcpretty
script:
Expand Down
37 changes: 37 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

let package = Package(
name: "Toucan",
platforms: [
.iOS(.v9), .tvOS(.v9)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Toucan",
targets: ["Toucan"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Toucan",
dependencies: [],
path: "Sources",
exclude: ["Toucan-Info.plist", "tvOS/Toucan.tvOS-Info.plist"]),
.testTarget(
name: "ToucanTests",
dependencies: ["Toucan"],
path: "Tests",
exclude: ["Info.plist"],
resources: [
.process("Assets")
])
]
)
File renamed without changes.
File renamed without changes.
18 changes: 13 additions & 5 deletions Source/Toucan.swift → Sources/Toucan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,26 @@ import CoreGraphics
let resizedAndMaskedImage = Toucan(withImage: myImage).resize(CGSize(width: 100, height: 150)).maskWithEllipse().image
*/
public class Toucan : NSObject {

#if swift(>=4.2)

internal typealias ImageOrientation = UIImage.Orientation
#else
internal typealias ImageOrientation = UIImageOrientation
#endif

public var image : UIImage?

public init(image withImage: UIImage) {
self.image = withImage
}

/**
Image with the orientation fixed up based on EXF data.

- parameter image: Source image

- returns: Image with corrected orientation
*/
public static func imageWithCorrectedOrientation(_ image: UIImage) -> UIImage {
let imgRef = Util.CGImageWithCorrectOrientation(image)
return UIImage(cgImage: imgRef)
}

// MARK: - Resize

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions Tests/ToucanTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ import XCTest
class ToucanTestCase : XCTestCase {

internal var portraitImage : UIImage {
let imageData = try? Data(contentsOf: Bundle(for: ToucanTestCase.self).url(forResource: "Portrait", withExtension: "jpg")!)
let imageData = try? Data(contentsOf: Bundle.module.url(forResource: "Portrait", withExtension: "jpg")!)
let image = UIImage(data: imageData!)
XCTAssertEqual(image!.size, CGSize(width: 1593, height: 2161), "Verify portrait image size")
return image!
}

internal var landscapeImage : UIImage {
let imageData = try? Data(contentsOf: Bundle(for: ToucanTestCase.self).url(forResource: "Landscape", withExtension: "jpg")!)
let imageData = try? Data(contentsOf: Bundle.module.url(forResource: "Landscape", withExtension: "jpg")!)
let image = UIImage(data: imageData!)
XCTAssertEqual(image!.size, CGSize(width: 3872, height: 2592), "Verify landscape image size")
return image!
}

internal var maskImage : UIImage {
let imageData = try? Data(contentsOf: Bundle(for: ToucanTestCase.self).url(forResource: "OctagonMask", withExtension: "png")!)
let imageData = try? Data(contentsOf: Bundle.module.url(forResource: "OctagonMask", withExtension: "png")!)
let image = UIImage(data: imageData!)
XCTAssertEqual(image!.size, CGSize(width: 500, height: 500), "Verify mask image size")
return image!
Expand Down
4 changes: 2 additions & 2 deletions Toucan.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Pod::Spec.new do |s|
s.authors = { 'Gavin Bunney' => 'gavin@bunney.net.au' }
s.source = { :git => 'https://github.com/gavinbunney/Toucan.git', :tag => s.version }

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '9.0'

s.source_files = 'Source/*.swift'
s.swift_version = '4.0'
s.swift_version = '5.0'

s.requires_arc = true
end