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

RHMAP-10113 Update to Swift 3.0 #89

Merged
merged 5 commits into from
Nov 3, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ branches:

script:
- xcodebuild -workspace AeroGearPush.xcworkspace -scheme AeroGearPush -sdk iphonesimulator build
- xcodebuild -workspace AeroGearPush.xcworkspace -scheme AeroGearPushTests -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.0' test
4 changes: 2 additions & 2 deletions AeroGear-Push-Swift.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "AeroGear-Push-Swift"
s.version = "1.3.0"
s.version = "2.0.0"
s.summary = "AeroGear UnifiedPush Client Registration SDK (Swift)."
s.homepage = "https://github.com/aerogear/aerogear-ios-push"
s.license = 'Apache License, Version 2.0'
s.author = "Red Hat, Inc."
s.source = { :git => 'https://github.com/aerogear/aerogear-ios-push.git', :tag => '1.3.0-swift' }
s.source = { :git => 'https://github.com/aerogear/aerogear-ios-push.git', :tag => '2.0.0-swift' }
s.platform = :ios, 8.0
s.source_files = 'push-sdk-swift/*.{swift}'
s.module_name = "AeroGearPush"
Expand Down
56 changes: 28 additions & 28 deletions AeroGearPush.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

/* Begin PBXBuildFile section */
455BE13E4277B151286D252A /* Pods_AeroGearPushTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05D4BCD108233945916B37DF /* Pods_AeroGearPushTests.framework */; };
482A24ED1B09D4BF00CE5BDC /* AGPushAnalyticsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 482A24EB1B09D45000CE5BDC /* AGPushAnalyticsTests.swift */; };
482A24ED1B09D4BF00CE5BDC /* PushAnalyticsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 482A24EB1B09D45000CE5BDC /* PushAnalyticsTests.swift */; };
48AAA6E81C450DA90048C53A /* pushproperties.plist in Resources */ = {isa = PBXBuildFile; fileRef = 48AAA6E71C450DA90048C53A /* pushproperties.plist */; };
48EDFAE61B00E8D300F8D11F /* AGPushAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48EDFAE51B00E8D300F8D11F /* AGPushAnalytics.swift */; };
6F46417219654E4A00D2B1C9 /* AGDeviceRegistration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F46417119654E4A00D2B1C9 /* AGDeviceRegistration.swift */; };
6F464174196564A500D2B1C9 /* AGClientDeviceInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F464173196564A500D2B1C9 /* AGClientDeviceInformation.swift */; };
6F4641771965660300D2B1C9 /* AGClientDeviceInformationImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F4641761965660300D2B1C9 /* AGClientDeviceInformationImpl.swift */; };
48EDFAE61B00E8D300F8D11F /* PushAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48EDFAE51B00E8D300F8D11F /* PushAnalytics.swift */; };
6F46417219654E4A00D2B1C9 /* DeviceRegistration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F46417119654E4A00D2B1C9 /* DeviceRegistration.swift */; };
6F464174196564A500D2B1C9 /* ClientDeviceInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F464173196564A500D2B1C9 /* ClientDeviceInformation.swift */; };
6F4641771965660300D2B1C9 /* ClientDeviceInformationImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F4641761965660300D2B1C9 /* ClientDeviceInformationImpl.swift */; };
6F46D37B19A3A726001799DB /* AeroGearPush.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F71353119646266009B26D8 /* AeroGearPush.framework */; };
6F4970DE1A1688DF00A1B50F /* AeroGearPush.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 6F71353119646266009B26D8 /* AeroGearPush.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
6F71353719646266009B26D8 /* push-sdk-swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F71353619646266009B26D8 /* push-sdk-swift.h */; settings = {ATTRIBUTES = (Public, ); }; };
6F71354419646266009B26D8 /* AGDeviceRegistrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F71354319646266009B26D8 /* AGDeviceRegistrationTests.swift */; };
6F71354419646266009B26D8 /* DeviceRegistrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F71354319646266009B26D8 /* DeviceRegistrationTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -61,19 +61,19 @@
/* Begin PBXFileReference section */
05D4BCD108233945916B37DF /* Pods_AeroGearPushTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AeroGearPushTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2C2A5D518A7E93769A13252A /* Pods-AeroGearPushTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AeroGearPushTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AeroGearPushTests/Pods-AeroGearPushTests.debug.xcconfig"; sourceTree = "<group>"; };
482A24EB1B09D45000CE5BDC /* AGPushAnalyticsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AGPushAnalyticsTests.swift; sourceTree = "<group>"; };
482A24EB1B09D45000CE5BDC /* PushAnalyticsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushAnalyticsTests.swift; sourceTree = "<group>"; };
48AAA6E71C450DA90048C53A /* pushproperties.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = pushproperties.plist; sourceTree = "<group>"; };
48EDFAE51B00E8D300F8D11F /* AGPushAnalytics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AGPushAnalytics.swift; sourceTree = "<group>"; };
48EDFAE51B00E8D300F8D11F /* PushAnalytics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushAnalytics.swift; sourceTree = "<group>"; };
6EA6D52ABF5A679A23B4F606 /* Pods-AeroGearPushTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AeroGearPushTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AeroGearPushTests/Pods-AeroGearPushTests.release.xcconfig"; sourceTree = "<group>"; };
6F46417119654E4A00D2B1C9 /* AGDeviceRegistration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AGDeviceRegistration.swift; sourceTree = "<group>"; };
6F464173196564A500D2B1C9 /* AGClientDeviceInformation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AGClientDeviceInformation.swift; sourceTree = "<group>"; };
6F4641761965660300D2B1C9 /* AGClientDeviceInformationImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AGClientDeviceInformationImpl.swift; sourceTree = "<group>"; };
6F46417119654E4A00D2B1C9 /* DeviceRegistration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceRegistration.swift; sourceTree = "<group>"; };
6F464173196564A500D2B1C9 /* ClientDeviceInformation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClientDeviceInformation.swift; sourceTree = "<group>"; };
6F4641761965660300D2B1C9 /* ClientDeviceInformationImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClientDeviceInformationImpl.swift; sourceTree = "<group>"; };
6F71353119646266009B26D8 /* AeroGearPush.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AeroGearPush.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6F71353519646266009B26D8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6F71353619646266009B26D8 /* push-sdk-swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "push-sdk-swift.h"; sourceTree = "<group>"; };
6F71353C19646266009B26D8 /* AeroGearPushTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AeroGearPushTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6F71354219646266009B26D8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6F71354319646266009B26D8 /* AGDeviceRegistrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AGDeviceRegistrationTests.swift; sourceTree = "<group>"; };
6F71354319646266009B26D8 /* DeviceRegistrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceRegistrationTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -99,7 +99,7 @@
6F464175196565EE00D2B1C9 /* Internal */ = {
isa = PBXGroup;
children = (
6F4641761965660300D2B1C9 /* AGClientDeviceInformationImpl.swift */,
6F4641761965660300D2B1C9 /* ClientDeviceInformationImpl.swift */,
);
name = Internal;
sourceTree = "<group>";
Expand Down Expand Up @@ -129,9 +129,9 @@
children = (
6F71353619646266009B26D8 /* push-sdk-swift.h */,
6F464175196565EE00D2B1C9 /* Internal */,
6F46417119654E4A00D2B1C9 /* AGDeviceRegistration.swift */,
6F464173196564A500D2B1C9 /* AGClientDeviceInformation.swift */,
48EDFAE51B00E8D300F8D11F /* AGPushAnalytics.swift */,
6F46417119654E4A00D2B1C9 /* DeviceRegistration.swift */,
6F464173196564A500D2B1C9 /* ClientDeviceInformation.swift */,
48EDFAE51B00E8D300F8D11F /* PushAnalytics.swift */,
6F71353419646266009B26D8 /* Supporting Files */,
);
path = "push-sdk-swift";
Expand All @@ -148,8 +148,8 @@
6F71354019646266009B26D8 /* push-sdk-swiftTests */ = {
isa = PBXGroup;
children = (
6F71354319646266009B26D8 /* AGDeviceRegistrationTests.swift */,
482A24EB1B09D45000CE5BDC /* AGPushAnalyticsTests.swift */,
6F71354319646266009B26D8 /* DeviceRegistrationTests.swift */,
482A24EB1B09D45000CE5BDC /* PushAnalyticsTests.swift */,
6F71354119646266009B26D8 /* Supporting Files */,
);
path = "push-sdk-swiftTests";
Expand Down Expand Up @@ -348,19 +348,19 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
48EDFAE61B00E8D300F8D11F /* AGPushAnalytics.swift in Sources */,
6F4641771965660300D2B1C9 /* AGClientDeviceInformationImpl.swift in Sources */,
6F46417219654E4A00D2B1C9 /* AGDeviceRegistration.swift in Sources */,
6F464174196564A500D2B1C9 /* AGClientDeviceInformation.swift in Sources */,
48EDFAE61B00E8D300F8D11F /* PushAnalytics.swift in Sources */,
6F4641771965660300D2B1C9 /* ClientDeviceInformationImpl.swift in Sources */,
6F46417219654E4A00D2B1C9 /* DeviceRegistration.swift in Sources */,
6F464174196564A500D2B1C9 /* ClientDeviceInformation.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
6F71353819646266009B26D8 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
482A24ED1B09D4BF00CE5BDC /* AGPushAnalyticsTests.swift in Sources */,
6F71354419646266009B26D8 /* AGDeviceRegistrationTests.swift in Sources */,
482A24ED1B09D4BF00CE5BDC /* PushAnalyticsTests.swift in Sources */,
6F71354419646266009B26D8 /* DeviceRegistrationTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -494,7 +494,7 @@
PRODUCT_NAME = AeroGearPush;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -513,7 +513,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.aerogear.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = AeroGearPush;
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -532,7 +532,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.aerogear.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = AeroGearPushTests;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -547,7 +547,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.aerogear.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = AeroGearPushTests;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6F71353B19646266009B26D8"
BuildableName = "AeroGearPushTests.xctest"
BlueprintName = "AeroGearPushTests"
ReferencedContainer = "container:AeroGearPush.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</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">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
6 changes: 3 additions & 3 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ platform :ios, '8.0'
use_frameworks!

target 'AeroGearPushTests' do
pod 'OHHTTPStubs', '3.1.10'
pod 'OHHTTPStubs', '5.2.0'
end

# Workaround to fix swift version to 2.3 for Pods.
# Workaround to fix swift version to 3.0 for Pods.
# it could be removed once CocoaPods 1.1.0 is released.
# https://github.com/CocoaPods/CocoaPods/issues/5521
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3'
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

**iOS Push Notification Registration SDK for the AeroGear UnifiedPush Server**

A small and handy library written in [Swift](https://developer.apple.com/swift/) that helps to register iOS applications with the [AeroGear UnifiedPush Server](https://github.com/aerogear/aerogear-unified-push-server).
A small and handy library written in [Swift 3.0](https://developer.apple.com/swift/) that helps to register iOS applications with the [AeroGear UnifiedPush Server](https://github.com/aerogear/aerogear-unified-push-server).

| | Project Info |
| --------------- | ------------- |
Expand All @@ -22,11 +22,11 @@ A small and handy library written in [Swift](https://developer.apple.com/swift/)

2. Get the dependencies

The project uses [OHHTTPStubs](https://github.com/AliSoftware/OHHTTPStubs) framework for stubbing its http network requests and utilizes [CocoaPods](http://cocoapods.org) for handling its dependencies. As a pre-requisite, install [CocoaPods](https://cocoapods.org/) and then install the pod. On the root directory of the project run:
The project uses [OHHTTPStubs](https://github.com/AliSoftware/OHHTTPStubs) framework for stubbing its http network requests and utilizes [CocoaPods](http://cocoapods.org) for handling its dependencies. As a pre-requisite, install [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) and then install the pod. On the root directory of the project run:
```bash
pod install
```
3. open AeroGearPushSwift.xcworkspace
3. open AeroGearPush.xcworkspace

## Adding the library to your project
To add the library in your project, you can either use [CocoaPods](http://cocoapods.org) or manual install either by dragging the code or building a ```framework``` to install in your project. See the respective sections below for instructions:
Expand All @@ -52,10 +52,10 @@ to install your dependencies
```swift
func application(application: UIApplication!, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData!) {
// setup registration
let registration = AGDeviceRegistration(serverURL: NSURL(string: "<# URL of the running AeroGear UnifiedPush Server #>")!)
let registration = DeviceRegistration(serverURL: NSURL(string: "<# URL of the running AeroGear UnifiedPush Server #>")!)

// attemp to register
registration.registerWithClientInfo({ (clientInfo: AGClientDeviceInformation!) in
registration.registerWithClientInfo({ (clientInfo: ClientDeviceInformation!) in
// setup configuration
clientInfo.deviceToken = deviceToken
clientInfo.variantID = "<# Variant Id #>"
Expand Down Expand Up @@ -86,10 +86,10 @@ In the ```AppDelegate.swift``` file:
```swift
func application(application: UIApplication!, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData!) {
// setup registration
let registration = AGDeviceRegistration()
let registration = DeviceRegistration()

// attemp to register
registration.registerWithClientInfo({ (clientInfo: AGClientDeviceInformation!) in
registration.registerWithClientInfo({ (clientInfo: ClientDeviceInformation!) in
// setup configuration
clientInfo.deviceToken = deviceToken
let currentDevice = UIDevice()
Expand Down Expand Up @@ -130,15 +130,15 @@ If you are interested in monitoring how a push message relates to the usage of y
* Send metrics when app is launched due to push notification
```swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
AGPushAnalytics.sendMetricsWhenAppLaunched(launchOptions)
PushAnalytics.sendMetricsWhenAppLaunched(launchOptions)
return true
}
```
* Send metrics when the app is brought from background to foreground due to a push notification
```swift
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject: AnyObject], fetchCompletionHandler: (UIBackgroundFetchResult) -> Void) {
// Send metrics when app is launched due to push notification
AGPushAnalytics.sendMetricsWhenAppAwoken(application.applicationState, userInfo: userInfo)
PushAnalytics.sendMetricsWhenAppAwoken(application.applicationState, userInfo: userInfo)

// Do stuff ...
fetchCompletionHandler(UIBackgroundFetchResult.NoData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import Foundation
Represents the set of allowed device metadata.
*/
@objc
public protocol AGClientDeviceInformation {
public protocol ClientDeviceInformation {

/**
The Device Token which identifies the device within APNs.
*/
var deviceToken: NSData? { get set }
var deviceToken: Data? { get set }

/**
The ID of the mobile Variant, for which this client will be registered.
Expand Down Expand Up @@ -64,4 +64,4 @@ public protocol AGClientDeviceInformation {
*/
var deviceType: String? { get set }

}
}