Skip to content

Commit 003899a

Browse files
authored
Merge pull request #4 from danchokobo/fix-migration-swift-5
migrate & fix errors
2 parents 99d86cf + 7fcef8e commit 003899a

9 files changed

Lines changed: 71 additions & 27 deletions

File tree

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Danagul Otel
2+
- IOS developer at VEON company, young and curious
3+
- [![twitter-alt][twitter-img]](https://twitter.com/danchokaa)
4+
[![github-alt][github-img]](https://github.com/danchokobo)
5+
[![linkedin-alt][linkedin-img]](https://www.linkedin.com/in/danagul-otel-9b841a122/)

JDAVKit/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}

JDAVKit/JDVideoKit/JDBufferToVideo.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class JDBufferToVideo:NSObject
195195
if videoWriter.startWriting()
196196
{
197197
//start session 讓 pixel buffer != nil
198-
videoWriter.startSession(atSourceTime: kCMTimeZero)
198+
videoWriter.startSession(atSourceTime: CMTime.zero)
199199
if (pixelBufferAdaptor.pixelBufferPool == nil)
200200
{
201201
fatalError("pixelBufferPool is nil")
@@ -208,14 +208,14 @@ class JDBufferToVideo:NSObject
208208
let welf = self
209209
let currentProgress = Progress(totalUnitCount: Int64(welf.buffer.count))
210210
var frameCount: Int64 = 0
211-
let frameDuration = CMTimeMake(1, welf.fps)
211+
let frameDuration = CMTimeMake(value: 1, timescale: welf.fps)
212212
var remainingPhotoURLs = welf.buffer
213213

214214
while !remainingPhotoURLs.isEmpty
215215
{
216216
let nextPhotoURL:CVPixelBuffer? = remainingPhotoURLs.remove(at: 0)
217217
let newPixelBufferoutputs:CVPixelBuffer = nextPhotoURL!
218-
let lastFrameTime = CMTimeMake(frameCount, welf.fps)
218+
let lastFrameTime = CMTimeMake(value: frameCount, timescale: welf.fps)
219219
let presentationTime = frameCount == 0 ? lastFrameTime : CMTimeAdd(lastFrameTime, frameDuration)
220220
while !videoWriterInput.isReadyForMoreMediaData
221221
{

JDAVKit/JDVideoKit/JDPresentingViewController.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public class JDPresentingViewController:UIViewController
105105
//產生縮圖列
106106
let assetImgGenerate : AVAssetImageGenerator = AVAssetImageGenerator(asset: videoasset)
107107
assetImgGenerate.appliesPreferredTrackTransform = true
108-
assetImgGenerate.requestedTimeToleranceAfter = kCMTimeZero
109-
assetImgGenerate.requestedTimeToleranceBefore = kCMTimeZero
108+
assetImgGenerate.requestedTimeToleranceAfter = CMTime.zero
109+
assetImgGenerate.requestedTimeToleranceBefore = CMTime.zero
110110
assetImgGenerate.appliesPreferredTrackTransform = true
111111
let thumbTime: CMTime = videoasset.duration
112112
let thumbtimeSeconds:Double = Double(CMTimeGetSeconds(thumbTime))
@@ -236,7 +236,7 @@ public class JDPresentingViewController:UIViewController
236236
{
237237
self.ChoosingMode = .Normal
238238
self.videoPlayer.replaceCurrentItem(with: assetitem)
239-
videoPlayer.seek(to: kCMTimeZero) { (bool) in
239+
videoPlayer.seek(to: CMTime.zero) { (bool) in
240240
self.videoPlayer.rate = 1.0
241241
}
242242
return
@@ -252,7 +252,7 @@ public class JDPresentingViewController:UIViewController
252252
@IBAction func SaveAction(_ sender: Any) {
253253
if(indicatorView == nil)
254254
{
255-
indicatorView = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
255+
indicatorView = UIActivityIndicatorView(style: .whiteLarge)
256256
indicatorView?.frame = self.view.frame
257257
indicatorView?.startAnimating()
258258
self.view.addSubview(indicatorView!)
@@ -279,7 +279,7 @@ public class JDPresentingViewController:UIViewController
279279
{
280280
self.videoPlayer.replaceCurrentItem(with: assetitem)
281281
}
282-
videoPlayer.seek(to: kCMTimeZero) { (bool) in
282+
videoPlayer.seek(to: CMTime.zero) { (bool) in
283283
if(!bool) { print("seek Fail");return }
284284
self.videoPlayer.rate = 2.0
285285
}
@@ -290,7 +290,7 @@ public class JDPresentingViewController:UIViewController
290290
if let item = BoomVideoItem,videoPlayer.currentItem! != item
291291
{
292292
self.videoPlayer.replaceCurrentItem(with: item)
293-
videoPlayer.seek(to: kCMTimeZero) { (bool) in
293+
videoPlayer.seek(to: CMTime.zero) { (bool) in
294294
if(!bool) { print("seek Fail"); return }
295295
self.videoPlayer.rate = 1.0
296296
}
@@ -335,11 +335,11 @@ public class JDPresentingViewController:UIViewController
335335
}
336336

337337
if keyPath == #keyPath(AVPlayerItem.status) {
338-
let status: AVPlayerItemStatus
338+
let status: AVPlayerItem.Status
339339

340340
// Get the status change from the change dictionary
341341
if let statusNumber = change?[.newKey] as? NSNumber {
342-
status = AVPlayerItemStatus(rawValue: statusNumber.intValue)!
342+
status = AVPlayerItem.Status(rawValue: statusNumber.intValue)!
343343
} else {
344344
status = .unknown
345345
}
@@ -354,6 +354,8 @@ public class JDPresentingViewController:UIViewController
354354
break
355355
case .unknown:
356356
break
357+
@unknown default:
358+
break
357359
}
358360
}
359361
}

JDAVKit/JDVideoKit/JDProcessingViewController.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,14 @@ extension JDProcessingViewController: AVCaptureFileOutputRecordingDelegate
291291
extension JDProcessingViewController:UIImagePickerControllerDelegate,UINavigationControllerDelegate
292292
{
293293

294-
295-
296-
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
297-
{
298-
picker.dismiss(animated: true) {
299-
let type = info["UIImagePickerControllerMediaType"]
300-
let url = info["UIImagePickerControllerMediaURL"]
301-
let rurl = info["UIImagePickerControllerReferenceURL"]
302-
let video = VideoOrigin(mediaType: type, mediaUrl: url, referenceURL: rurl)
303-
self.videoHasBeenSelect(video: video)
304-
}
294+
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
295+
picker.dismiss(animated: true) {
296+
let type = info["UIImagePickerControllerMediaType"]
297+
let url = info["UIImagePickerControllerMediaURL"]
298+
let rurl = info["UIImagePickerControllerReferenceURL"]
299+
let video = VideoOrigin(mediaType: type, mediaUrl: url, referenceURL: rurl)
300+
self.videoHasBeenSelect(video: video)
301+
}
305302
}
306303

307304
public func imagePickerControllerDidCancel(_ picker: UIImagePickerController)

JDVideoKit.xcodeproj/project.pbxproj

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
isa = PBXProject;
133133
attributes = {
134134
LastSwiftUpdateCheck = 0830;
135-
LastUpgradeCheck = 0830;
135+
LastUpgradeCheck = 1100;
136136
ORGANIZATIONNAME = james12345;
137137
TargetAttributes = {
138138
4F8844D61F24C07600B28B7A = {
@@ -144,7 +144,7 @@
144144
};
145145
buildConfigurationList = 4F8844D21F24C07600B28B7A /* Build configuration list for PBXProject "JDVideoKit" */;
146146
compatibilityVersion = "Xcode 3.2";
147-
developmentRegion = English;
147+
developmentRegion = en;
148148
hasScannedForEncodings = 0;
149149
knownRegions = (
150150
en,
@@ -217,21 +217,30 @@
217217
isa = XCBuildConfiguration;
218218
buildSettings = {
219219
ALWAYS_SEARCH_USER_PATHS = NO;
220+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
220221
CLANG_ANALYZER_NONNULL = YES;
221222
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
222223
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
223224
CLANG_CXX_LIBRARY = "libc++";
224225
CLANG_ENABLE_MODULES = YES;
225226
CLANG_ENABLE_OBJC_ARC = YES;
227+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
226228
CLANG_WARN_BOOL_CONVERSION = YES;
229+
CLANG_WARN_COMMA = YES;
227230
CLANG_WARN_CONSTANT_CONVERSION = YES;
231+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
228232
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
229233
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
230234
CLANG_WARN_EMPTY_BODY = YES;
231235
CLANG_WARN_ENUM_CONVERSION = YES;
232236
CLANG_WARN_INFINITE_RECURSION = YES;
233237
CLANG_WARN_INT_CONVERSION = YES;
238+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
239+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
240+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
234241
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
242+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
243+
CLANG_WARN_STRICT_PROTOTYPES = YES;
235244
CLANG_WARN_SUSPICIOUS_MOVE = YES;
236245
CLANG_WARN_UNREACHABLE_CODE = YES;
237246
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -267,21 +276,30 @@
267276
isa = XCBuildConfiguration;
268277
buildSettings = {
269278
ALWAYS_SEARCH_USER_PATHS = NO;
279+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
270280
CLANG_ANALYZER_NONNULL = YES;
271281
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
272282
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
273283
CLANG_CXX_LIBRARY = "libc++";
274284
CLANG_ENABLE_MODULES = YES;
275285
CLANG_ENABLE_OBJC_ARC = YES;
286+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
276287
CLANG_WARN_BOOL_CONVERSION = YES;
288+
CLANG_WARN_COMMA = YES;
277289
CLANG_WARN_CONSTANT_CONVERSION = YES;
290+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
278291
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
279292
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
280293
CLANG_WARN_EMPTY_BODY = YES;
281294
CLANG_WARN_ENUM_CONVERSION = YES;
282295
CLANG_WARN_INFINITE_RECURSION = YES;
283296
CLANG_WARN_INT_CONVERSION = YES;
297+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
298+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
299+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
284300
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
301+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
302+
CLANG_WARN_STRICT_PROTOTYPES = YES;
285303
CLANG_WARN_SUSPICIOUS_MOVE = YES;
286304
CLANG_WARN_UNREACHABLE_CODE = YES;
287305
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -316,7 +334,7 @@
316334
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
317335
PRODUCT_BUNDLE_IDENTIFIER = com.jameskuo12345.JDVideoKit;
318336
PRODUCT_NAME = "$(TARGET_NAME)";
319-
SWIFT_VERSION = 4.0;
337+
SWIFT_VERSION = 5.0;
320338
};
321339
name = Debug;
322340
};
@@ -330,7 +348,7 @@
330348
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
331349
PRODUCT_BUNDLE_IDENTIFIER = com.jameskuo12345.JDVideoKit;
332350
PRODUCT_NAME = "$(TARGET_NAME)";
333-
SWIFT_VERSION = 4.0;
351+
SWIFT_VERSION = 5.0;
334352
};
335353
name = Release;
336354
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>JDVideoKit.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>

0 commit comments

Comments
 (0)