Skip to content

Commit

Permalink
Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesit committed Sep 18, 2017
1 parent 6322cd1 commit 7f58dd6
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 32 deletions.
49 changes: 41 additions & 8 deletions SwiftBubble.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,14 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0710;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Felix Grabowski";
TargetAttributes = {
4236EA641B19EB81000DA31F = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 0810;
DevelopmentTeam = RH89HEC84R;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
4236EAA31B19ECAD000DA31F = {
CreatedOnToolsVersion = 6.3.2;
Expand Down Expand Up @@ -433,18 +435,27 @@
4236EA6E1B19EB81000DA31F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
ALWAYS_SEARCH_USER_PATHS = NO;
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_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
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_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;
COPY_PHASE_STRIP = NO;
Expand All @@ -466,28 +477,38 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
};
name = Debug;
};
4236EA6F1B19EB81000DA31F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
ALWAYS_SEARCH_USER_PATHS = NO;
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_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
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_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;
COPY_PHASE_STRIP = NO;
Expand All @@ -502,41 +523,53 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
};
name = Release;
};
4236EA711B19EB81000DA31F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
DEVELOPMENT_TEAM = RH89HEC84R;
INFOPLIST_FILE = SwiftBubble/Info.plist;
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = "com.felixgrabowski.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
WRAPPER_EXTENSION = saver;
};
name = Debug;
};
4236EA721B19EB81000DA31F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
DEVELOPMENT_TEAM = RH89HEC84R;
INFOPLIST_FILE = SwiftBubble/Info.plist;
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = "com.felixgrabowski.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
WRAPPER_EXTENSION = saver;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -69,6 +70,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -69,6 +70,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion SwiftBubble/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
37 changes: 18 additions & 19 deletions SwiftBubble/SwiftBubbleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import ScreenSaver
import AVFoundation
import AVKit


class SoapBubbleView: ScreenSaverView {
class SwiftBubbleView: ScreenSaverView {

var videoView:NSView!
let frameRate = 29.97
Expand All @@ -39,7 +38,7 @@ class SoapBubbleView: ScreenSaverView {
let playerItem = AVPlayerItem(asset: asset)
player = AVPlayer(playerItem: playerItem)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.videoGravity = AVLayerVideoGravityResizeAspect
playerLayer.videoGravity = AVLayerVideoGravity.resizeAspect

let videoView = NSView(frame: NSMakeRect(0, 0, NSWidth(frame)/2, NSHeight(frame)/2))
videoView.wantsLayer = true
Expand All @@ -63,7 +62,7 @@ class SoapBubbleView: ScreenSaverView {
override func startAnimation() {
player.play()
NotificationCenter.default.addObserver(self,
selector: #selector(SoapBubbleView.restartVideo),
selector: #selector(SwiftBubbleView.restartVideo),
name: NSNotification.Name.AVPlayerItemDidPlayToEndTime,
object: player.currentItem)
super.startAnimation()
Expand All @@ -81,15 +80,15 @@ class SoapBubbleView: ScreenSaverView {
override func animateOneFrame() {
}

override func hasConfigureSheet() -> Bool {
override var hasConfigureSheet: Bool {
return false
}

override func configureSheet() -> NSWindow? {
override var configureSheet: NSWindow? {
return nil
}

func restartVideo() {
@objc func restartVideo() {
let seconds:Int64 = 0
let preferredTimeScale:Int32 = 1
let seekTime:CMTime = CMTimeMake(seconds, preferredTimeScale)
Expand All @@ -103,31 +102,31 @@ class SoapBubbleView: ScreenSaverView {
v2.translatesAutoresizingMaskIntoConstraints = false
let multiplier:CGFloat = 0.75 // video scaling
let equalWidth = NSLayoutConstraint(item: v1,
attribute:NSLayoutAttribute.width,
relatedBy:NSLayoutRelation.equal,
attribute:NSLayoutConstraint.Attribute.width,
relatedBy:NSLayoutConstraint.Relation.equal,
toItem:self,
attribute:NSLayoutAttribute.width,
attribute:NSLayoutConstraint.Attribute.width,
multiplier:multiplier,
constant:0);
let equalHeight = NSLayoutConstraint(item: v1,
attribute:NSLayoutAttribute.height,
relatedBy:NSLayoutRelation.equal,
attribute:NSLayoutConstraint.Attribute.height,
relatedBy:NSLayoutConstraint.Relation.equal,
toItem:self,
attribute:NSLayoutAttribute.height,
attribute:NSLayoutConstraint.Attribute.height,
multiplier:multiplier,
constant:0);
let centerX = NSLayoutConstraint(item: v1,
attribute:NSLayoutAttribute.centerX,
relatedBy:NSLayoutRelation.equal,
attribute:NSLayoutConstraint.Attribute.centerX,
relatedBy:NSLayoutConstraint.Relation.equal,
toItem:self,
attribute:NSLayoutAttribute.centerX,
attribute:NSLayoutConstraint.Attribute.centerX,
multiplier:1.0,
constant:0);
let centerY = NSLayoutConstraint(item: v1,
attribute:NSLayoutAttribute.centerY,
relatedBy:NSLayoutRelation.equal,
attribute:NSLayoutConstraint.Attribute.centerY,
relatedBy:NSLayoutConstraint.Relation.equal,
toItem:self,
attribute:NSLayoutAttribute.centerY,
attribute:NSLayoutConstraint.Attribute.centerY,
multiplier:1.0,
constant:0);

Expand Down

0 comments on commit 7f58dd6

Please sign in to comment.