Skip to content
Merged
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
2 changes: 1 addition & 1 deletion OptimizelySwiftSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Pod::Spec.new do |s|
s.author = { "Optimizely" => "[email protected]" }
s.ios.deployment_target = "10.0"
s.tvos.deployment_target = "10.0"
s.osx.deployment_target = "10.14"
s.source = {
:git => "https://github.com/optimizely/swift-sdk.git",
:tag => "v"+s.version.to_s
Expand All @@ -18,4 +19,3 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => "OPTIMIZELY_SDK_VERSION=@\\\"#{s.version}\\\"" }
end

246 changes: 246 additions & 0 deletions OptimizelySwiftSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BD64853A2491474500F30986"
BuildableName = "Optimizely.framework"
BlueprintName = "OptimizelySwiftSDK-macOS"
ReferencedContainer = "container:OptimizelySwiftSDK.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BD64853A2491474500F30986"
BuildableName = "Optimizely.framework"
BlueprintName = "OptimizelySwiftSDK-macOS"
ReferencedContainer = "container:OptimizelySwiftSDK.xcodeproj">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BD64853A2491474500F30986"
BuildableName = "Optimizely.framework"
BlueprintName = "OptimizelySwiftSDK-macOS"
ReferencedContainer = "container:OptimizelySwiftSDK.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ let package = Package(
name: "Optimizely",
platforms: [
.iOS(.v10),
.tvOS(.v10)
.tvOS(.v10),
.macOS(.v10_14)
],
products: [
.library(name: "Optimizely",
Expand Down
22 changes: 18 additions & 4 deletions Sources/Protocols/BackgroundingCallbacks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,37 @@
***************************************************************************/

import Foundation
#if os(macOS)
import Cocoa
#else // iOS, tvOS
import UIKit
#endif

@objc protocol BackgroundingCallbacks {
func applicationDidEnterBackground()
func applicationDidBecomeActive()
}

private extension NSNotification.Name {
#if os(macOS)
static let didEnterBackground = NSApplication.didResignActiveNotification
static let didBecomeActive = NSApplication.didBecomeActiveNotification
#else // iOS, tvOS
static let didEnterBackground = UIApplication.didEnterBackgroundNotification
static let didBecomeActive = UIApplication.didBecomeActiveNotification
#endif
}

extension BackgroundingCallbacks {
func subscribe() {
// swift4.2+
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive), name: UIApplication.didBecomeActiveNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground), name: .didEnterBackground, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive), name: .didBecomeActive, object: nil)
}

func unsubscribe() {
// swift4.2+
NotificationCenter.default.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIApplication.didBecomeActiveNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: .didEnterBackground, object: nil)
NotificationCenter.default.removeObserver(self, name: .didBecomeActive, object: nil)
}
}
2 changes: 1 addition & 1 deletion Sources/Supporting Files/Optimizely.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License. *
***************************************************************************/

#import <UIKit/UIKit.h>
@import Foundation;

//! Project version number for Optimizely.
FOUNDATION_EXPORT double OptimizelyVersionNumber;
Expand Down