Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
osx_image: xcode7.3
language: objective-c

env:
global:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
- OSX_SIM="macosx"
- IOS_SIM="iphonesimulator"

matrix:
include:
- os: osx
osx_image: xcode7.3
env: DESTINATION="arch=x86_64" SDK="${OSX_SIM}" SCHEME="Cache-Mac"
- os: osx
osx_image: xcode7.3
env: DESTINATION="OS=9.2,name=iPhone 6S" SDK="${IOS_SIM}9.3" SCHEME="Cache-iOS"
- os: osx
osx_image: xcode8
env: DESTINATION="arch=x86_64" SDK="${OSX_SIM}" SCHEME="Cache-Mac"
- os: osx
osx_image: xcode8
env: DESTINATION="OS=10.0,name=iPhone 6S" SDK="${IOS_SIM}10.0" SCHEME="Cache-iOS"

before_install:
- brew update
- if brew outdated | grep -qx carthage; then brew upgrade carthage; fi
- travis_wait 35 carthage bootstrap --platform Mac,iOS

script:
- xcodebuild clean build -project Cache.xcodeproj -scheme "Cache-Mac" -sdk macosx
- xcodebuild test -project Cache.xcodeproj -scheme "Cache-Mac" -sdk macosx
- xcodebuild clean build -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator
- xcodebuild test -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator
- xcodebuild clean build -project Cache.xcodeproj -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION"
- xcodebuild test -project Cache.xcodeproj -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION"
10 changes: 10 additions & 0 deletions Cache.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@
TargetAttributes = {
D5291D171C2837DB00B702C9 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
D5291D5F1C283B5300B702C9 = {
CreatedOnToolsVersion = 7.2;
Expand All @@ -616,6 +617,7 @@
};
D5DC59DF1C20593E003BD79B = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -866,6 +868,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Debug;
};
Expand All @@ -880,6 +883,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
};
name = Release;
};
Expand All @@ -905,6 +909,7 @@
PRODUCT_NAME = Cache;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
};
name = Debug;
};
Expand All @@ -930,6 +935,7 @@
PRODUCT_NAME = Cache;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
};
name = Release;
};
Expand All @@ -948,6 +954,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-MacTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
};
name = Debug;
};
Expand All @@ -966,6 +973,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.Cache-MacTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
};
name = Release;
};
Expand Down Expand Up @@ -1077,6 +1085,7 @@
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Cache;
PRODUCT_NAME = Cache;
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
};
name = Debug;
};
Expand All @@ -1099,6 +1108,7 @@
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Cache;
PRODUCT_NAME = Cache;
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "krzyzanowskim/CryptoSwift"
github "sumolari/CryptoSwift" "swift-2.3"
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "krzyzanowskim/CryptoSwift" "3a0c3153717070a42971c30cd73d67f6f832f4bc"
github "Quick/Nimble" "v4.0.1"
github "Quick/Quick" "v0.9.2"
github "sumolari/CryptoSwift" "fcc2d6b38e4fcd601b08d71eb2eb24d16fce34d0"
github "Quick/Nimble" "v4.1.0"
github "Quick/Quick" "v0.9.3"
18 changes: 17 additions & 1 deletion Source/Mac/Extensions/NSImage+Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ extension NSImage: Cachable {
public func encode() -> NSData? {
guard let data = TIFFRepresentation else { return nil }

#if swift(>=2.3)
let imageFileType: NSBitmapImageFileType = hasAlpha
? .PNG
: .JPEG
#else
let imageFileType: NSBitmapImageFileType = hasAlpha
? .NSPNGFileType
: .NSJPEGFileType

#endif

return NSBitmapImageRep(data: data)?.representationUsingType(imageFileType, properties: [:])
}
}
Expand All @@ -50,7 +56,17 @@ extension NSImage {
var imageRect: CGRect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
let imageRef = CGImageForProposedRect(&imageRect, context: nil, hints: nil)
let result: Bool

#if swift(>=2.3)
let alpha: CGImageAlphaInfo
if let image = imageRef {
alpha = CGImageGetAlphaInfo(image)
} else {
alpha = .None
}
#else
let alpha = CGImageGetAlphaInfo(imageRef)
#endif

switch alpha {
case .None, .NoneSkipFirst, .NoneSkipLast:
Expand Down
9 changes: 9 additions & 0 deletions Source/iOS/Extensions/UIImage+Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ extension UIImage {
*/
var hasAlpha: Bool {
let result: Bool
#if swift(>=2.3)
let alpha: CGImageAlphaInfo
if let image = CGImage {
alpha = CGImageGetAlphaInfo(image)
} else {
alpha = .None
}
#else
let alpha = CGImageGetAlphaInfo(CGImage)
#endif

switch alpha {
case .None, .NoneSkipFirst, .NoneSkipLast:
Expand Down
6 changes: 6 additions & 0 deletions Tests/Mac/Helpers/NSImage+CacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ extension NSImage {
var data: NSData {
let representation = TIFFRepresentation!

#if swift(>=2.3)
let imageFileType: NSBitmapImageFileType = hasAlpha
? .PNG
: .JPEG
#else
let imageFileType: NSBitmapImageFileType = hasAlpha
? .NSPNGFileType
: .NSJPEGFileType
#endif

return (NSBitmapImageRep(data: representation)?.representationUsingType(
imageFileType, properties: [:]))!
Expand Down
6 changes: 6 additions & 0 deletions Tests/Mac/Specs/Extensions/NSImage+CacheSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ class NSImageCacheSpec: QuickSpec {
let image = SpecHelper.image()
let representation = image.TIFFRepresentation!

#if swift(>=2.3)
let imageFileType: NSBitmapImageFileType = image.hasAlpha
? .PNG
: .JPEG
#else
let imageFileType: NSBitmapImageFileType = image.hasAlpha
? .NSPNGFileType
: .NSJPEGFileType
#endif

let data = NSBitmapImageRep(data: representation)!.representationUsingType(
imageFileType, properties: [:])
Expand Down
9 changes: 9 additions & 0 deletions Tests/iOS/Helpers/SpecHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ struct SpecHelper {
UIGraphicsBeginImageContextWithOptions(size, opaque, 0)
let context = UIGraphicsGetCurrentContext()

#if swift(>=2.3)
CGContextSetFillColorWithColor(context!, color.CGColor)
CGContextFillRect(context!, CGRectMake(0, 0, size.width, size.height))
#else
CGContextSetFillColorWithColor(context, color.CGColor)
CGContextFillRect(context, CGRectMake(0, 0, size.width, size.height))
#endif

let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

#if swift(>=2.3)
return image!
#else
return image
#endif
}
}
4 changes: 4 additions & 0 deletions Tests/iOS/Helpers/UIImage+CacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ extension UIImage {
let drawnImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

#if swift(>=2.3)
return CGDataProviderCopyData(CGImageGetDataProvider(drawnImage!.CGImage!)!)!
#else
return CGDataProviderCopyData(CGImageGetDataProvider(drawnImage.CGImage))!
#endif
}
}
2 changes: 1 addition & 1 deletion Tests/iOS/Specs/DataStructures/ExpirySpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExpirySpec: QuickSpec {
let date = NSDate().dateByAddingTimeInterval(1000)
expiry = .Seconds(1000)

expect(expiry.date.timeIntervalSince1970) ≈ (date.timeIntervalSince1970, 0.01)
expect(expiry.date.timeIntervalSince1970).to(beCloseTo(date.timeIntervalSince1970, within: 0.01))
}

it("returns specified date") {
Expand Down