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 Swift 5 ; Compatible with Xcode 11.2.1 #3

Open
wants to merge 2 commits into
base: master
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions LivelyGIFs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1120;
ORGANIZATIONNAME = XueYu;
TargetAttributes = {
C80883441E940D1B00939B75 = {
Expand All @@ -123,7 +123,7 @@
};
buildConfigurationList = C80883401E940D1B00939B75 /* Build configuration list for PBXProject "LivelyGIFs" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -192,21 +192,30 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -243,21 +252,30 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -292,7 +310,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xueyu.LivelyGIFs;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -305,7 +323,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xueyu.LivelyGIFs;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
3 changes: 1 addition & 2 deletions LivelyGIFs/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
5 changes: 5 additions & 0 deletions LivelyGIFs/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
6 changes: 4 additions & 2 deletions LivelyGIFs/LivePhotoVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class LivePhotoVC: UIViewController {
if error != nil{
print("Could not write video file")
} else {
self.convertToGIF(movieURL)
DispatchQueue.main.async {
self.convertToGIF(movieURL)
}
}
}
}
Expand All @@ -117,7 +119,7 @@ class LivePhotoVC: UIViewController {

// collect the needed parameters
let duration = CMTimeGetSeconds(movieAsset.duration)
let track = movieAsset.tracks(withMediaType: AVMediaTypeVideo).first!
let track = movieAsset.tracks(withMediaType: AVMediaType.video).first!
let frameRate = track.nominalFrameRate

gifURL = URL(fileURLWithPath: (NSTemporaryDirectory()).appending("file.gif"))
Expand Down
4 changes: 2 additions & 2 deletions LivelyGIFs/PhotoCollectionVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class PhotoCollectionVC: UICollectionViewController {

alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alert.addAction(UIAlertAction(title: "Settings", style: .default, handler:{ (action: UIAlertAction) in
let url = URL(string: UIApplicationOpenSettingsURLString)
UIApplication.shared.open(url!, options: ["" : ""], completionHandler: nil)
let url = URL(string: UIApplication.openSettingsURLString)
UIApplication.shared.open(url!, options: [:], completionHandler: nil)
return
}))

Expand Down
8 changes: 4 additions & 4 deletions LivelyGIFs/Regift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public struct Regift {

for frameNumber in 0 ..< frameCount {
let seconds: Float64 = Float64(startTime) + (Float64(increment) * Float64(frameNumber))
let time = CMTimeMakeWithSeconds(seconds, Constants.TimeInterval)
let time = CMTimeMakeWithSeconds(seconds, preferredTimescale: Constants.TimeInterval)

timePoints.append(time)
}
Expand Down Expand Up @@ -287,7 +287,7 @@ public struct Regift {
*/
public func createGIFForTimePoints(_ timePoints: [TimePoint], fileProperties: [String: AnyObject], frameProperties: [String: AnyObject], frameCount: Int, width: Int, height: Int) throws -> URL {
// Ensure the source media is a valid file.
guard asset.tracks(withMediaCharacteristic: AVMediaCharacteristicVisual).count > 0 else {
guard asset.tracks(withMediaCharacteristic: AVMediaCharacteristic.visual).count > 0 else {
throw RegiftError.SourceFormatInvalid
}

Expand All @@ -310,7 +310,7 @@ public struct Regift {
generator.appliesPreferredTrackTransform = true
generator.maximumSize = CGSize(width: width, height: height)

let tolerance = CMTimeMakeWithSeconds(Constants.Tolerance, Constants.TimeInterval)
let tolerance = CMTimeMakeWithSeconds(Constants.Tolerance, preferredTimescale: Constants.TimeInterval)
generator.requestedTimeToleranceBefore = tolerance
generator.requestedTimeToleranceAfter = tolerance

Expand All @@ -327,7 +327,7 @@ public struct Regift {

generator.generateCGImagesAsynchronously(forTimes: times, completionHandler: { (requestedTime, image, actualTime, result, error) in
guard let imageRef = image , error == nil else {
print("An error occurred: \(error), image is \(image)")
print("An error occurred: \(String(describing: error)), image is \(String(describing: image))")
dispatchError = true
gifGroup.leave()
return
Expand Down