-
Notifications
You must be signed in to change notification settings - Fork 209
Swift4 Fix #48 #49
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
Swift4 Fix #48 #49
Conversation
1) Removed unnecessary imports 2) Removed _FMWrapper class and replaced with the default FileManager 3) Implemented subscripting using new Partial Ranges 4) Re-Implemented `|>>` using the TextFileStreamWriter 5) Replaced NSString and NSData in places where String or Data would also work 6) Added compiler flags for macOS as well as OSX, because I suspect the OSX flag will be deprecated at some point 7) Minor work towards including Linux support 8) Removed the _FMWrapper tests 9) Updated swift version and FileKit version
… && added a rename function
Awesome! I'll take a thorough look at this tonight. |
…et _ = try?... instead Refactored if statements that returned early or threw errors to use guard in order to follow proper swift coding techniques
Sorry that I keep adding commits. I've been slowly refactoring stuff as I go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally prefer using '///' for doc comments over block comments. Is there a reason for this change aside from it being your own preference?
FileKit.xcodeproj/project.pbxproj
Outdated
@@ -917,7 +921,7 @@ | |||
PRODUCT_NAME = "$(PROJECT_NAME)"; | |||
SKIP_INSTALL = YES; | |||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; | |||
SWIFT_VERSION = 3.0; | |||
SWIFT_VERSION = 4.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that changing the Swift version in Xcode from 3 to 4 prevents projects from compiling with Xcode 8. Until Xcode 9 is officially released and replaces Xcode 8, the Swift version in Xcode should be 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this commit affect Swift 4 compatibility? If not, it should probably be in its own PR.
@Ponyboy47 I've noticed that changing the Swift version in Xcode from 3 to 4 prevents projects from compiling with Xcode 8. Xcode 9 is in its third beta. When Xcode 9 hits GM or the macOS App Store, then the Swift version project setting should change to accommodate the release. Until then, it should be 3. |
A representation of a filesystem array file. | ||
|
||
The data type is NSArray. | ||
*/ | ||
public typealias NSArrayFile = File<NSArray> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a swift4 needs to change all the comments?
If not, a separated PR would have been better
- to see only swift 4 change
- to discuss elsewhere about comment formatting
- to merge it before merging swift 4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swift 4 does not require a change in comment style. I've updated RandomKit to Swift 4 and much has remained the same as before, including the comment style.
atomically: useAuxiliaryFile, | ||
encoding: String.Encoding.utf8.rawValue) | ||
} catch { | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code do not allow to debug using a breakpoint to see the error.
Swift4 is a breaking change so I think FileKitError.writeToFileFail
must contain the error as second argument
options: options) | ||
return (volumes ?? []).flatMap { Path(url: $0) } | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
fileprivate var _fmWraper = _FMWrapper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a custom FileManager is a useful macOS feature, not really used for iOS
When you have a lot to do with files, you want to separate your FileManagerDelegate
codes
public var components: [Path] { | ||
if rawValue == "" || rawValue == "." { | ||
guard rawValue != "" && rawValue != "." else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guard
is not always the solution
I see a lot if
replaced by guard
with tricky boolean conditions
it's a matter of coding style here, if
has been clear here, guard
also is clear
return false | ||
} | ||
if delim && append { | ||
handle.write(delimData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a behaviour change
if append mode, you want the delim only before?
This change must be documented carefully(method comment, changelog when releasing) or be reverted
Thanks @Ponyboy47. As you can see your PR could not be merged. I do some more work because of your PR like "Re-Implemented |>> using the TextFileStreamWriter" |
|>>
using the TextFileStreamWriter