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

Swift 5 and Swift Package Manager #698

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
14 changes: 10 additions & 4 deletions C4.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
138B93242391D042009219C5 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
138B93252391D052009219C5 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
1F40C6FA1C82ADF0004AE1E7 /* Camera.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Camera.swift; sourceTree = "<group>"; };
1F754DCA1C48EE600036D39F /* ImageLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageLayer.swift; sourceTree = "<group>"; };
1F75FDE81C5B1FE700EB62C2 /* C4Loop.aif */ = {isa = PBXFileReference; lastKnownFileType = file; path = C4Loop.aif; sourceTree = "<group>"; };
Expand Down Expand Up @@ -358,6 +360,8 @@
614F823919DB5ED3001DF1D4 = {
isa = PBXGroup;
children = (
138B93242391D042009219C5 /* README.md */,
138B93252391D052009219C5 /* Package.swift */,
A9D4F66E1B534F9F00F937AB /* C4 */,
A9596D271A054A960023323D /* Tests */,
A96F505B1B5385A5002B3A46 /* C4App */,
Expand Down Expand Up @@ -649,7 +653,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0900;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1120;
ORGANIZATIONNAME = C4;
TargetAttributes = {
610A6A4D1F928E1B003B841A = {
Expand Down Expand Up @@ -678,7 +682,7 @@
};
buildConfigurationList = 614F823D19DB5ED3001DF1D4 /* Build configuration list for PBXProject "C4" */;
compatibilityVersion = "Xcode 8.0";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -1106,6 +1110,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -1155,7 +1160,7 @@
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -1166,6 +1171,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -1206,7 +1212,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
24 changes: 10 additions & 14 deletions C4.xcodeproj/xcshareddata/xcschemes/C4-iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1120"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "614F824219DB5ED3001DF1D4"
BuildableName = "C4.framework"
BlueprintName = "C4-iOS"
ReferencedContainer = "container:C4.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "614F824219DB5ED3001DF1D4"
BuildableName = "C4.framework"
BlueprintName = "C4-iOS"
ReferencedContainer = "container:C4.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -70,8 +68,6 @@
ReferencedContainer = "container:C4.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
24 changes: 10 additions & 14 deletions C4.xcodeproj/xcshareddata/xcschemes/C4-tvOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1120"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "610A6A4D1F928E1B003B841A"
BuildableName = "C4.framework"
BlueprintName = "C4-tvOS"
ReferencedContainer = "container:C4.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "610A6A4D1F928E1B003B841A"
BuildableName = "C4.framework"
BlueprintName = "C4-tvOS"
ReferencedContainer = "container:C4.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -70,8 +68,6 @@
ReferencedContainer = "container:C4.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
4 changes: 2 additions & 2 deletions C4/Core/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ public class Color {
public extension UIColor {
/// Initializes a UIColor object from a Color object.
/// - parameter color: The C4 color object.
public convenience init?(_ color: Color) {
convenience init?(_ color: Color) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use spaces for indentation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Moved 'em back to spaces.

self.init(cgColor: color.cgColor)
}
}

public extension CIColor {
/// Initializes a CIColor object from a Color object.
/// - parameter color: The C4 color object.
public convenience init(_ color: Color) {
convenience init(_ color: Color) {
self.init(cgColor: color.cgColor)
}
}
2 changes: 1 addition & 1 deletion C4/Core/Point.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public func lerp(_ a: Point, _ b: Point, at: Double) -> Point {

public extension CGPoint {
///Initializes a CGPoint from a Point
public init(_ point: Point) {
init(_ point: Point) {
self.init(x: CGFloat(point.x), y: CGFloat(point.y))
}
}
2 changes: 1 addition & 1 deletion C4/Core/Rect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public func inset(_ r: Rect, dx: Double, dy: Double) -> Rect {
// MARK: - Casting to CGRect
public extension CGRect {
/// Initializes a CGRect from a Rect
public init(_ rect: Rect) {
init(_ rect: Rect) {
self.init(origin: CGPoint(rect.origin), size: CGSize(rect.size))
}
}
2 changes: 1 addition & 1 deletion C4/Core/Size.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public func <= (lhs: Size, rhs: Size) -> Bool {
// MARK: - Casting to CGSize
public extension CGSize {
/// Initializes a new CGSize from a Size
public init(_ size: Size) {
init(_ size: Size) {
self.init(width: CGFloat(size.width), height: CGFloat(size.height))
}
}
2 changes: 1 addition & 1 deletion C4/UI/AudioPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class AudioPlayer: NSObject, AVAudioPlayerDelegate {
/// ````
public init?(_ name: String) {
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
try AVAudioSession.sharedInstance().setCategory(.playback)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these indentation changes need to be reverted.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Moved 'em back to spaces.

try AVAudioSession.sharedInstance().setActive(true)
} catch {
print("Couldn't set up AVAudioSession")
Expand Down
4 changes: 2 additions & 2 deletions C4/UI/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class Camera: View {
previewLayer.backgroundColor = clear.cgColor
previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill

orientationObserver = on(event: NSNotification.Name.UIDeviceOrientationDidChange) { [unowned self] in
orientationObserver = on(event: UIDevice.orientationDidChangeNotification) { [unowned self] in
self.updateOrientation()
}
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public class Camera: View {
return image
}

var orientation: UIImageOrientation
var orientation: UIImage.Orientation
let shouldFlip = position == .front

switch videoOrientation {
Expand Down
2 changes: 1 addition & 1 deletion C4/UI/Image+ColorAt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public extension Image {
/// let color = img.color(at: Point())
/// ````
/// - parameter at: a Point.
public func color(at point: Point) -> Color {
func color(at point: Point) -> Color {

guard bounds.contains(point) else {
print("Point is outside the image bounds")
Expand Down
4 changes: 2 additions & 2 deletions C4/UI/Movie.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public class Movie: View {
/// - parameter filename: The name of the movie file included in your project.
public convenience init?(_ filename: String) {
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
try AVAudioSession.sharedInstance().setCategory(.playback)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print("Couldn't set up AVAudioSession")
Expand Down Expand Up @@ -225,7 +225,7 @@ public class Movie: View {
print("The current movie's player is not properly initialized")
return
}
p.seek(to: CMTimeMake(0, 1))
p.seek(to: CMTimeMake(value: 0, timescale: 1))
p.pause()
}

Expand Down
50 changes: 25 additions & 25 deletions C4/UI/Shape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ open class Shape: View {
return nil
}

let fillRule = shapeLayer.fillRule == kCAFillRuleNonZero ? CGPathFillRule.evenOdd : CGPathFillRule.winding
let fillRule = shapeLayer.fillRule == CAShapeLayerFillRule.nonZero ? CGPathFillRule.evenOdd : CGPathFillRule.winding

if path.contains(point, using: fillRule, transform: CGAffineTransform.identity) {
return self
Expand Down Expand Up @@ -215,22 +215,22 @@ open class Shape: View {
/// The fill rule used when filling the path. Defaults to `nonZero`.
public var fillRule: FillRule {
get {
switch shapeLayer.fillRule {
case kCAFillRuleNonZero:
return .nonZero
case kCAFillRuleEvenOdd:
return .evenOdd
default:
return .nonZero
}
switch shapeLayer.fillRule {
case .nonZero:
return .nonZero
case .evenOdd:
return .evenOdd
default:
return .nonZero
}
}
set(fillRule) {
switch fillRule {
case .nonZero:
shapeLayer.fillRule = kCAFillRuleNonZero
case .evenOdd:
shapeLayer.fillRule = kCAFillRuleEvenOdd
}
switch fillRule {
case .nonZero:
shapeLayer.fillRule = .nonZero
case .evenOdd:
shapeLayer.fillRule = .evenOdd
}
}
}

Expand Down Expand Up @@ -275,9 +275,9 @@ open class Shape: View {
public var lineCap: LineCap {
get {
switch shapeLayer.lineCap {
case kCALineCapRound:
case .round:
return .round
case kCALineCapSquare:
case .square:
return .square
default:
return .butt
Expand All @@ -286,11 +286,11 @@ open class Shape: View {
set(lineCap) {
switch lineCap {
case .butt:
shapeLayer.lineCap = kCALineCapButt
shapeLayer.lineCap = .butt
case .round:
shapeLayer.lineCap = kCALineCapRound
shapeLayer.lineCap = .round
case .square:
shapeLayer.lineCap = kCALineCapSquare
shapeLayer.lineCap = .square
}
}
}
Expand All @@ -299,9 +299,9 @@ open class Shape: View {
public var lineJoin: LineJoin {
get {
switch shapeLayer.lineJoin {
case kCALineJoinRound:
case .round:
return .round
case kCALineJoinBevel:
case .bevel:
return .bevel
default:
return .miter
Expand All @@ -310,11 +310,11 @@ open class Shape: View {
set(lineJoin) {
switch lineJoin {
case .miter:
shapeLayer.lineJoin = kCALineJoinMiter
shapeLayer.lineJoin = .miter
case .round:
shapeLayer.lineJoin = kCALineJoinRound
shapeLayer.lineJoin = .round
case .bevel:
shapeLayer.lineJoin = kCALineJoinBevel
shapeLayer.lineJoin = .bevel
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion C4/UI/ShapeLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ extension CABasicAnimation {
self.autoreverses = animation.autoreverses
self.repeatCount = Float(animation.repeatCount)
}
self.fillMode = kCAFillModeBoth
self.fillMode = .both
self.isRemovedOnCompletion = false
}
}
Expand Down
Loading