diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b06c467 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# OS X +.DS_Store + diff --git a/CHANGELOG.md b/CHANGELOG.md index ffa8005..d04108a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ This file documents the changes between different versions of the `fliclib.framework` for the original Flic. +## fliclib-ios 1.4.0 + +### Significant Changes + +* The framework is now distributed using the new XCFramework packaging format. This means that instead of a single `fliclib.framework` file, you will need to use a `fliclib.xcframework` bundle. This bundle is essentially a folder containing framework builds for all supported architectures. The main benefit of this is that the framework will from now on run in the iOS Simulator, by default, with no configuration needed. + + This change switch was necessary due to the fact that Xcode 11.4 now throws a compiler error if any embedded framework is not build for Simulator. This would only generate a warning in previous versions. Thus the previously provided simulator files would no longer work without the use of cumbersome build scripts. + + Xcode 11 is required in order to use XCFramework bundles. + ## fliclib-ios 1.3.3 ### Changes diff --git a/README.md b/README.md index 285157d..4915ea5 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,30 @@ This is the official iOS framework for the original **Flic 1**. If you are looking to integrate the new **Flic 2**, please see [https://github.com/50ButtonsEach/flic2lib-ios](https://github.com/50ButtonsEach/flic2lib-ios) +**Note:** As of `April 7th, 2020`, this framework is distributed as an XCFramework bundle instead of a regular framework bundle. + ## Getting Started This framework works in collaboration with the Flic app so please make sure that you have it installed before you begin. For instructions on how to implement this see [https://partners.flic.io/partners/developers/ios-tutorial](https://partners.flic.io/partners/developers/ios-tutorial), or take a look at one of our example projects here on github for [Swift](https://github.com/50ButtonsEach/ios-boilerplate-swift) or [Objective-C](https://github.com/50ButtonsEach/ios-boilerplate-objc). -## Simulator Support +*** + +**Note:** As of `April 7th, 2020`, the first 4 steps under the *Set up Xcode* section in the linked tutorial are no longer valid. Instead, replace them with the following 2 steps: -The framework itself does not contain slices for x86 and i386 (iOS Simulator). The reason for this is that if we were to add those slices to the framework then -they would have to be removed before App Store submission, which is not a very straightforward thing to do. So, for those who want to run the framework in the simulator -we instead provide a wrapper that adds a fake fliclib implementation when building for x86 and i386. +1. Place the downloaded `fliclib.xcframework` folder somewhere on you computer, preferably in your project's folder structure. -To use this wrapper follow these steps: +2. Drag-and-drop the whole `fliclib.xcframework` folder from your finder window to the `Frameworks, Libraries, and Embedded Content` section under +the `General` tab of your application's target setting. + + Ensure that `fliclib.xcframework` is listed as *Embed & Sign*: + + Frameworks, Libraries and Embedded Content + + Doing this should automatically add the xcframework to `Link Binary With Libraries` under the Build Phases tab. + +## Simulator Support -1. Include the files inside the `simulator-wrapper` folder to your project. -2. On all the places in your code where you need to import fliclib you should import the wrapper instead. In other words, replace `#import ` with `#import "fliclibWrapper.h"`. Of course, the file path will depend on how you have configured your project. For example, if you have the *fliclib-ios* repository as a git submodule in your project root then it might look like this `#import "../fliclib-ios/simulator-wrapper/fliclibWrapper.h"`. -3. Make sure that both `SCLFlicManagerSimulator.m` and `SCLFlicButtonSimulator.m` are added to *Compile Sources* in your project *Build Phases*. +The XCFramework bundle will run in the simulator by default, no configuration needed. ## Licence diff --git a/fliclib.framework/fliclib b/fliclib.framework/fliclib deleted file mode 100755 index a66e9b0..0000000 Binary files a/fliclib.framework/fliclib and /dev/null differ diff --git a/fliclib.xcframework/Info.plist b/fliclib.xcframework/Info.plist new file mode 100644 index 0000000..9aa05c3 --- /dev/null +++ b/fliclib.xcframework/Info.plist @@ -0,0 +1,41 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + ios-armv7_arm64 + LibraryPath + fliclib.framework + SupportedArchitectures + + armv7 + arm64 + + SupportedPlatform + ios + + + LibraryIdentifier + ios-x86_64_i386-simulator + LibraryPath + fliclib.framework + SupportedArchitectures + + x86_64 + i386 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/fliclib.framework/Headers/SCLFlicButton.h b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Headers/SCLFlicButton.h similarity index 90% rename from fliclib.framework/Headers/SCLFlicButton.h rename to fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Headers/SCLFlicButton.h index ece927e..2692479 100644 --- a/fliclib.framework/Headers/SCLFlicButton.h +++ b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Headers/SCLFlicButton.h @@ -16,7 +16,8 @@ * @discussion Represents the diffrent connection states that a flic can be in at any given time. * */ -typedef NS_ENUM(NSInteger, SCLFlicButtonConnectionState) { +typedef NS_ENUM(NSInteger, SCLFlicButtonConnectionState) +{ /** * The flic is currently connected. This means that the iOS device has an active link with the flic and that data can be sent in both * directions provided that it has also been verified, notified by the flicButtonIsReady: callback. @@ -44,7 +45,8 @@ typedef NS_ENUM(NSInteger, SCLFlicButtonConnectionState) { * Please be mindful of battery usage. * */ -typedef NS_ENUM(NSInteger, SCLFlicButtonLEDIndicateCount) { +typedef NS_ENUM(NSInteger, SCLFlicButtonLEDIndicateCount) +{ /** * The LED will fade 1 time. */ @@ -74,7 +76,8 @@ typedef NS_ENUM(NSInteger, SCLFlicButtonLEDIndicateCount) { * The buttonUp and buttonDown events will be active no matter which of these alternatives you choose. * */ -typedef NS_ENUM(NSInteger, SCLFlicButtonTriggerBehavior) { +typedef NS_ENUM(NSInteger, SCLFlicButtonTriggerBehavior) +{ /** * Used to distinguish between only click and hold. *

@@ -127,7 +130,8 @@ typedef NS_ENUM(NSInteger, SCLFlicButtonTriggerBehavior) { * @discussion These enums represents the different error codes that can be sent on both the SCLFlicButton and SCLFlicManager classes. * */ -typedef NS_ENUM(NSInteger, SCLFlicError) { +typedef NS_ENUM(NSInteger, SCLFlicError) +{ /** * An error has occurred. */ @@ -240,7 +244,8 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * using the specified delegate methods. * */ -@interface SCLFlicButton : NSObject { +@interface SCLFlicButton : NSObject +{ } @@ -258,7 +263,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion The virtual ID of the flic. * */ -@property (readonly, nonatomic, strong, nonnull) NSUUID *buttonIdentifier; +@property(readonly, nonatomic, strong, nonnull) NSUUID *buttonIdentifier; /*! * @property buttonPublicKey @@ -266,7 +271,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion The public key of the flic. This in the key that is used to identify the flic on our backend. * */ -@property (readonly, nonatomic, strong, nonnull) NSString *buttonPublicKey; +@property(readonly, nonatomic, strong, nonnull) NSString *buttonPublicKey; /*! * @property name @@ -274,7 +279,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion The Bluetooth device name of the flic button. * */ -@property (atomic, readonly, strong, nonnull) NSString *name; +@property(atomic, readonly, strong, nonnull) NSString *name; /*! * @property color @@ -283,7 +288,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * was already grabbed with an earlier version of fliclib, then the color will default to white. * */ -@property (atomic, readonly, strong, nonnull) UIColor *color; +@property(atomic, readonly, strong, nonnull) UIColor *color; /*! * @property userAssignedName @@ -291,7 +296,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion This is the user assigned name of the Flic button that is assigned and displayed in the Flic App. * */ -@property (atomic, readonly, strong, nonnull) NSString *userAssignedName; +@property(atomic, readonly, strong, nonnull) NSString *userAssignedName; /*! * @property state @@ -299,7 +304,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion The current state of the flic. * */ -@property (atomic, readonly) SCLFlicButtonConnectionState connectionState; +@property(atomic, readonly) SCLFlicButtonConnectionState connectionState; /*! * @property lowLatency @@ -319,7 +324,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * Take a look at SCLFlicButtonTriggerBehavior to see the options available. * */ -@property (nonatomic, readwrite) SCLFlicButtonTriggerBehavior triggerBehavior; +@property(nonatomic, readwrite) SCLFlicButtonTriggerBehavior triggerBehavior; /*! * @property pressCount @@ -333,7 +338,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * that anyone will ever reach those numbers. The presscounter will be reset if a factory reset is done on the physical flic button. * */ -@property (nonatomic, readonly) int pressCount; +@property(nonatomic, readonly) int pressCount; /*! * @property isReady @@ -341,7 +346,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion This property lets you know wether the Flic is ready or not. * */ -@property (readonly) BOOL isReady; +@property(readonly) BOOL isReady; /*! * @method connect: @@ -351,7 +356,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * pending connection. It can be canceled by calling the disconnect method. * */ -- (void) connect; +- (void)connect; /*! * @method disconnect: @@ -359,7 +364,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion Disconnect a currently connected flic or cancel a pending connection. * */ -- (void) disconnect; +- (void)disconnect; /*! * @method indicateLED: @@ -369,7 +374,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * * @param count Decides how many times the LED will indicate (fade) */ -- (void) indicateLED: (SCLFlicButtonLEDIndicateCount) count; +- (void)indicateLED:(SCLFlicButtonLEDIndicateCount)count; /*! * @method readRSSI @@ -379,7 +384,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * in decibels and has an effective range from -100 to 0. * */ -- (void) readRSSI; +- (void)readRSSI; @end @@ -408,7 +413,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion The flic registered a button down event. * */ -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonDown:(BOOL) queued age: (NSInteger) age; +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonDown:(BOOL)queued age:(NSInteger)age; /*! * @method flicButton:didReceiveButtonUp:age: @@ -422,7 +427,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion The flic registered a button up event. * */ -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonUp:(BOOL) queued age: (NSInteger) age; +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonUp:(BOOL)queued age:(NSInteger)age; /*! * @method flicButton:didReceiveButtonClick:age: @@ -437,7 +442,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * The behavior of this event depends on what SCLFlicButtonTriggerBehavior the triggerBehavior property is set to. * */ -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonClick:(BOOL) queued age: (NSInteger) age; +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonClick:(BOOL)queued age:(NSInteger)age; /*! * @method flicButton:didReceiveButtonDoubleClick:age: @@ -452,7 +457,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * The behavior of this event depends on what SCLFlicButtonTriggerBehavior the triggerBehavior property is set to. * */ -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonDoubleClick:(BOOL) queued age: (NSInteger) age; +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonDoubleClick:(BOOL)queued age:(NSInteger)age; /*! * @method flicButton:didReceiveButtonHold:age: @@ -467,7 +472,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * The behavior of this event depends on what SCLFlicButtonTriggerBehavior the triggerBehavior property is set to. * */ -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonHold:(BOOL) queued age: (NSInteger) age; +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonHold:(BOOL)queued age:(NSInteger)age; /*! * @method flicButtonDidConnect: @@ -480,7 +485,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * after the flicButtonIsReady: callback has arrived. * */ -- (void) flicButtonDidConnect:(SCLFlicButton * _Nonnull) button; +- (void)flicButtonDidConnect:(SCLFlicButton * _Nonnull)button; /*! * @method flicButtonIsReady: @@ -492,7 +497,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * immediately after the flicButtonDidConnect: event. * */ -- (void) flicButtonIsReady:(SCLFlicButton * _Nonnull) button; +- (void)flicButtonIsReady:(SCLFlicButton * _Nonnull)button; /*! * @method flicButton:didDisconnectWithError: @@ -504,7 +509,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * This can sometimes be called during a connection event that failed before the user was notified of the connection. * */ -- (void) flicButton:(SCLFlicButton * _Nonnull) button didDisconnectWithError:(NSError * _Nullable) error; +- (void)flicButton:(SCLFlicButton * _Nonnull)button didDisconnectWithError:(NSError * _Nullable)error; /*! * @method flicButton:didFailToConnectWithError: @@ -519,7 +524,7 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * need to call the connect: yourself to activate the pending connection once again. * */ -- (void) flicButton:(SCLFlicButton * _Nonnull) button didFailToConnectWithError:(NSError * _Nullable) error; +- (void)flicButton:(SCLFlicButton * _Nonnull)button didFailToConnectWithError:(NSError * _Nullable)error; /*! * @method flicButton:didUpdateRSSI:error: @@ -532,6 +537,6 @@ typedef NS_ENUM(NSInteger, SCLFlicError) { * @discussion This callback verifies (unless an error occurred) that the RSSI value was updated. * */ -- (void) flicButton:(SCLFlicButton * _Nonnull) button didUpdateRSSI:(NSNumber * _Nonnull) RSSI error:(NSError * _Nullable) error; +- (void)flicButton:(SCLFlicButton * _Nonnull)button didUpdateRSSI:(NSNumber * _Nonnull)RSSI error:(NSError * _Nullable)error; @end diff --git a/fliclib.framework/Headers/SCLFlicManager.h b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Headers/SCLFlicManager.h similarity index 89% rename from fliclib.framework/Headers/SCLFlicManager.h rename to fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Headers/SCLFlicManager.h index 1856b4b..a9a8fb7 100644 --- a/fliclib.framework/Headers/SCLFlicManager.h +++ b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Headers/SCLFlicManager.h @@ -18,7 +18,8 @@ * any kind of communication with a flic. * */ -typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { +typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) +{ /** * This state is the desired state that is needed when communicating with a flic. */ @@ -60,7 +61,8 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * and collect the associated flic objects using the knownButtons: method. * */ -@interface SCLFlicManager : NSObject { +@interface SCLFlicManager : NSObject +{ } @@ -93,7 +95,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * bluetooth related tasks until the manager properly changes to SCLFlicManagerBluetoothStateOn. * */ -@property (nonatomic, readonly) SCLFlicManagerBluetoothState bluetoothState; +@property(nonatomic, readonly) SCLFlicManagerBluetoothState bluetoothState; /*! * @property enabled @@ -102,7 +104,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * enable and disable. When This property is set to NO, then no Bluetooth LE communication * will be allowed. This means that no communication with a flic can be made. */ -@property (readonly, getter=isEnabled) BOOL enabled; +@property(readonly, getter=isEnabled) BOOL enabled; /*! * @method sharedManager @@ -110,7 +112,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * @discussion Use this to access the manager singleton. This will only work if a call to configureWithDelegate:appID:appSecret:backgroundExecution: * has been made once this app session, otherwise nil will be returned. */ -+ (instancetype _Nullable) sharedManager; ++ (instancetype _Nullable)sharedManager; /*! * @method configureWithDelegate:defaultButtonDelegate:appID:appSecret:backgroundExecution: @@ -137,7 +139,11 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * */ -+ (instancetype _Nullable) configureWithDelegate:(id _Nullable) delegate defaultButtonDelegate: (id _Nullable) buttonDelegate appID: (NSString * _Nonnull) appID appSecret: (NSString * _Nonnull) appSecret backgroundExecution: (BOOL) bExecution; ++ (instancetype _Nullable)configureWithDelegate:(id _Nullable)delegate + defaultButtonDelegate:(id _Nullable)buttonDelegate + appID:(NSString * _Nonnull)appID + appSecret:(NSString * _Nonnull)appSecret + backgroundExecution:(BOOL)bExecution; /*! * @method knownButtons: @@ -148,7 +154,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * of the SCLFlicButton instance. * */ -- (NSDictionary * _Nonnull) knownButtons; +- (NSDictionary * _Nonnull)knownButtons; /*! * @method forgetButton: @@ -160,7 +166,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * @param button The button that you wish to destroy. * */ -- (void) forgetButton:(SCLFlicButton * _Nonnull) button; +- (void)forgetButton:(SCLFlicButton * _Nonnull)button; /*! * @method disable @@ -169,7 +175,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * You will not be able to do any communication with a flic until you call enable. * */ -- (void) disable; +- (void)disable; /*! * @method enable @@ -179,7 +185,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * in which case the connect will automatically be sent. * */ -- (void) enable; +- (void)enable; /*! * @method grabFlicFromFlicAppWithCallbackUrlScheme: @@ -191,7 +197,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * full URL. * */ -- (void) grabFlicFromFlicAppWithCallbackUrlScheme: (NSString * _Nonnull) scheme; +- (void)grabFlicFromFlicAppWithCallbackUrlScheme:(NSString * _Nonnull)scheme; /*! * @method handleOpenURL: @@ -203,7 +209,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * @return If this url can be handled by the flic manager or not. * */ -- (BOOL) handleOpenURL: (NSURL * _Nonnull) url; +- (BOOL)handleOpenURL:(NSURL * _Nonnull)url; /*! @@ -213,11 +219,10 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * proper state. This is needed since we can not rely on Apple to take care of that to 100%. * */ -- (void) onLocationChange; +- (void)onLocationChange; @end - /*! * @protocol SCLFlicManagerDelegate * @@ -239,7 +244,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * @discussion This delegate method is called every time the a new Flic button is grabbed from the Flic App. * */ -- (void) flicManager:(SCLFlicManager * _Nonnull) manager didGrabFlicButton:(SCLFlicButton * _Nullable) button withError: (NSError * _Nullable) error; +- (void)flicManager:(SCLFlicManager * _Nonnull)manager didGrabFlicButton:(SCLFlicButton * _Nullable)button withError:(NSError * _Nullable)error; @optional @@ -257,7 +262,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * pending again. * */ -- (void) flicManager:(SCLFlicManager * _Nonnull) manager didChangeBluetoothState: (SCLFlicManagerBluetoothState) state; +- (void)flicManager:(SCLFlicManager * _Nonnull)manager didChangeBluetoothState:(SCLFlicManagerBluetoothState)state; /*! * @method flicManagerDidRestoreState: @@ -270,7 +275,7 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * order to properly restore the rest of your application. Do not forget to re-set the delegate on all buttons. * */ -- (void) flicManagerDidRestoreState:(SCLFlicManager * _Nonnull) manager; +- (void)flicManagerDidRestoreState:(SCLFlicManager * _Nonnull)manager; /*! * @method flicManager:didForgetButton:error: @@ -283,7 +288,6 @@ typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { * to also remove your references in case you still have any. * */ -- (void) flicManager:(SCLFlicManager * _Nonnull) manager didForgetButton:(NSUUID * _Nonnull) buttonIdentifier error:(NSError * _Nullable)error; - +- (void)flicManager:(SCLFlicManager * _Nonnull)manager didForgetButton:(NSUUID * _Nonnull)buttonIdentifier error:(NSError * _Nullable)error; @end diff --git a/fliclib.framework/Headers/fliclib.h b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Headers/fliclib.h similarity index 100% rename from fliclib.framework/Headers/fliclib.h rename to fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Headers/fliclib.h diff --git a/fliclib.framework/Info.plist b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Info.plist similarity index 73% rename from fliclib.framework/Info.plist rename to fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Info.plist index cbe5d64..526ac06 100644 Binary files a/fliclib.framework/Info.plist and b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Info.plist differ diff --git a/fliclib.framework/Modules/module.modulemap b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Modules/module.modulemap similarity index 100% rename from fliclib.framework/Modules/module.modulemap rename to fliclib.xcframework/ios-armv7_arm64/fliclib.framework/Modules/module.modulemap diff --git a/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/fliclib b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/fliclib new file mode 100755 index 0000000..2779c05 Binary files /dev/null and b/fliclib.xcframework/ios-armv7_arm64/fliclib.framework/fliclib differ diff --git a/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/SCLFlicButton.h b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/SCLFlicButton.h new file mode 100644 index 0000000..2692479 --- /dev/null +++ b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/SCLFlicButton.h @@ -0,0 +1,542 @@ +// +// @file SCLFlicButton.h +// @framework fliclib +// +// Created by Anton Meier on 2014-06-18. +// Copyright (c) 2020 Shortcut Labs. All rights reserved. +// + +#import +#import +@class UIColor; + +/*! + * @enum SCLFlicButtonConnectionState + * + * @discussion Represents the diffrent connection states that a flic can be in at any given time. + * + */ +typedef NS_ENUM(NSInteger, SCLFlicButtonConnectionState) +{ + /** + * The flic is currently connected. This means that the iOS device has an active link with the flic and that data can be sent in both + * directions provided that it has also been verified, notified by the flicButtonIsReady: callback. + */ + SCLFlicButtonConnectionStateConnected = 0, + /** + * The flic is currently connecting. This means that the iOS device is either in the process of establishing a link with flic or + * that it is waiting for flic to come within proximity so that such process can be initiated. + */ + SCLFlicButtonConnectionStateConnecting, + /** + * The flic is currently disconnected. + */ + SCLFlicButtonConnectionStateDisconnected, + /** + * The flic is currently disconnecting. + */ + SCLFlicButtonConnectionStateDisconnecting, +}; + +/*! + * @enum SCLFlicButtonLEDIndicateCount + * + * @discussion Represents the indication count, meaning how many times the LED will fade when using the indicateLED: method. + * Please be mindful of battery usage. + * + */ +typedef NS_ENUM(NSInteger, SCLFlicButtonLEDIndicateCount) +{ + /** + * The LED will fade 1 time. + */ + SCLFlicButtonLEDIndicateCount1 = 1, + /** + * The LED will fade 2 times. + */ + SCLFlicButtonLEDIndicateCount2, + /** + * The LED will fade 3 times. + */ + SCLFlicButtonLEDIndicateCount3, + /** + * The LED will fade 4 times. + */ + SCLFlicButtonLEDIndicateCount4, + /** + * The LED will fade 5 times. + */ + SCLFlicButtonLEDIndicateCount5, +}; + +/*! + * @enum SCLFlicButtonTriggerBehavior + * + * @discussion Represents the different trigger event behaviors that can be configured on the flic. + * The buttonUp and buttonDown events will be active no matter which of these alternatives you choose. + * + */ +typedef NS_ENUM(NSInteger, SCLFlicButtonTriggerBehavior) +{ + /** + * Used to distinguish between only click and hold. + *

+ * Click will be fired when the button is released if it was pressed for maximum 1 second. + * Otherwise, hold will be fired 1 second after the button was pressed. Click will then not be fired upon release. + * Since this option will only distinguish between click and hold it does not have to take double click into consideration. + * This means that the click event can be sent immediately on button release rather than to wait for a possible double click. + *

+ * Note: this will be the default behavior. + */ + SCLFlicButtonTriggerBehaviorClickAndHold = 0, + /** + * Used to distinguish between only single click and double click. + *

+ * Double click will be registered if the time between two button down events was at most 0.5 seconds. + * The double click event will then be fired upon button release. + * If the time was more than 0.5 seconds, a single click event will be fired; + * either directly upon button release if the button was down for more than 0.5 seconds, or after 0.5 seconds + * if the button was down for less than 0.5 seconds. + *

+ * To summarize this, a small delay will be added to the click event (if it was released within 0.5 s) in order to see if a + * double click will happen next. This ensures that a click event will not be sent prior to the double click. + */ + SCLFlicButtonTriggerBehaviorClickAndDoubleClick, + /** + * Used to distinguish between single click, double click and hold. + *

+ * If the time between the first button down and button up event was more than 1 second, a hold event will be fired. + *

+ * Else, double click will be fired if the time between two button down events was at most 0.5 seconds. + * The double click event will then be fired upon button release. + * If the time was more than 0.5 seconds, a single click event will be fired; + * either directly upon button release if the button was down for more than 0.5 seconds, + * or after 0.5 seconds if the button was down for less than 0.5 seconds. + *

+ * Note: Three fast consecutive clicks means one double click and then one single click. + * Four fast consecutive clicks means two double clicks. + */ + SCLFlicButtonTriggerBehaviorClickAndDoubleClickAndHold, + /** + * This mode will only send click and the event will be sent directly on buttonDown. This will be the same as listening for + * buttonDown. This click mode can be used if you wish to have the lowes possible latency on the click event. + */ + SCLFlicButtonTriggerBehaviorClick, +}; + +/*! + * @enum SCLFlicError + * + * @discussion These enums represents the different error codes that can be sent on both the SCLFlicButton and SCLFlicManager classes. + * + */ +typedef NS_ENUM(NSInteger, SCLFlicError) +{ + /** + * An error has occurred. + */ + SCLFlicErrorUnknown = 0, + /** + * The framework was unable to forget the button. + */ + SCLFlicErrorCouldNotForgetButton = 1, + /** + * If a connection to a button failed for unknown reasons. This could for example be if it is brought out of range during a connection sequense. + */ + SCLFlicErrorConnectionFailed = 2, + /** + * The RSSI value could not be read. + */ + SCLFlicErrorCouldNotUpdateRSSI = 3, + /** + * The data sent by the Flic/PbF button does not confirn with the protocol specificatin. + */ + SCLFlicErrorUnknownDataReceived = 5, + /** + * A crypthographic error has occurred. + */ + SCLFlicErrorCryptographicFailure = 11, + /** + * The request did not contain enough data to be completed. + */ + SCLFlicErrorMissingData = 13, + /** + * The signature over the data is not valid. The data might be corrupt. + */ + SCLFlicErrorInvalidSignature = 14, + /** + * You are trying to grab a Flic button that you have already grabbed before. + */ + SCLFlicErrorButtonAlreadyGrabbed = 15, + /** + * The button's verification message was not valid. + */ + SCLFlicErrorIllegalVerificationResponse = 31, + /** + * The iOS device was unable to performe the bluetooth specific service discovery. + */ + SCLFlicErrorCouldNotDiscoverServices = 33, + /** + * The button was unable to create a stable connection even after a number of re-tries. + */ + SCLFlicErrorConnectionRetryLimitReached = 34, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorUnknown = 100, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorInvalidParameters = 101, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorInvalidHandle = 102, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorNotConnected = 103, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorOutOfSpace = 104, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorOperationCancelled = 105, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorConnectionLost = 106, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorPeripheralDisconnected = 107, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorUUIDNotAllowed = 108, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorAlreadyAdvertising = 109, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorConnectionFailed = 110, + /** + * Bluetooth specific error + */ + SCLFlicErrorBluetoothErrorConnectionLimitReached = 111, + /** + * Connection was refused by Flic + */ + SCLFlicErrorFlicRefusedConnection = 200, +}; + +@protocol SCLFlicButtonDelegate; + +/*! + * @class SCLFlicButton + * + * @discussion An instance of this class represents a physical flic. + * All commands will be directly passed to the physical flic and any events occurring on the flic will be passed along + * using the specified delegate methods. + * + */ +@interface SCLFlicButton : NSObject +{ + +} + +/*! + * @property delegate + * + * @discussion The delegate object that will receive events related to this particular flic. + * + */ +@property(weak, nonatomic, nullable) id delegate; + +/*! + * @property buttonIdentifier + * + * @discussion The virtual ID of the flic. + * + */ +@property(readonly, nonatomic, strong, nonnull) NSUUID *buttonIdentifier; + +/*! + * @property buttonPublicKey + * + * @discussion The public key of the flic. This in the key that is used to identify the flic on our backend. + * + */ +@property(readonly, nonatomic, strong, nonnull) NSString *buttonPublicKey; + +/*! + * @property name + * + * @discussion The Bluetooth device name of the flic button. + * + */ +@property(atomic, readonly, strong, nonnull) NSString *name; + +/*! + * @property color + * + * @discussion The actual color of the grabbed Flic button. If for some reason the real color is not available, such as if the button + * was already grabbed with an earlier version of fliclib, then the color will default to white. + * + */ +@property(atomic, readonly, strong, nonnull) UIColor *color; + +/*! + * @property userAssignedName + * + * @discussion This is the user assigned name of the Flic button that is assigned and displayed in the Flic App. + * + */ +@property(atomic, readonly, strong, nonnull) NSString *userAssignedName; + +/*! + * @property state + * + * @discussion The current state of the flic. + * + */ +@property(atomic, readonly) SCLFlicButtonConnectionState connectionState; + +/*! + * @property lowLatency + * + * @discussion The latency setting for this button. If you set this to YES then you will get lower latency on the click events when your + * app is in the foreground. As soon as the app leaves the foreground it will be set back to the regular latency setting. + * Please only use this if you have a very good reason for it, such as if you are designing a foreground game that requires it. + * Battery consumption will increase with this activated. + * + */ +@property(nonatomic, readwrite) BOOL lowLatency; + +/*! + * @property triggerBehavior + * + * @discussion This property specifies how the flic press events should be handled. You are allowed to change this property any time you want. + * Take a look at SCLFlicButtonTriggerBehavior to see the options available. + * + */ +@property(nonatomic, readwrite) SCLFlicButtonTriggerBehavior triggerBehavior; + +/*! + * @property pressCount + * + * @discussion This property specifies how many times the flic has been toggled at any given time. This will register all down events + * as well as the up events, which means that if you want to know how many times it has been clicked then you have to divide + * this number by two. Also, this property will always contain the last known registered value, meaning that if the flic + * has been pressed while not being within proximity then the property will of course not be up to date. It will be updated + * as soon as the flic connects the next time. Important notice: Even though this value is represented by an int the internal + * counter only consists of 3 bytes meaning that the counter will rollover at 0xffffff (16777215). However, it is highly unlikely + * that anyone will ever reach those numbers. The presscounter will be reset if a factory reset is done on the physical flic button. + * + */ +@property(nonatomic, readonly) int pressCount; + +/*! + * @property isReady + * + * @discussion This property lets you know wether the Flic is ready or not. + * + */ +@property(readonly) BOOL isReady; + +/*! + * @method connect: + * + * @discussion Attempts to connect the flic. If the flic is not available, due to either being out of range or not advertising, + * then the flic will be connected once it becomes available since this call will not time out, also called a + * pending connection. It can be canceled by calling the disconnect method. + * + */ +- (void)connect; + +/*! + * @method disconnect: + * + * @discussion Disconnect a currently connected flic or cancel a pending connection. + * + */ +- (void)disconnect; + +/*! + * @method indicateLED: + * + * @discussion Use this method when you want to indicate something to the user by fading the LED. Be mindful with battery usage. + * This will only work if the Flic is connected. To prevent unnecessary battery wase the maximum fade count is five. + * + * @param count Decides how many times the LED will indicate (fade) + */ +- (void)indicateLED:(SCLFlicButtonLEDIndicateCount)count; + +/*! + * @method readRSSI + * + * @discussion A call to this method will read the RSSI (received signal strength indication) of the flic while it is currently connected. + * A callback will be sent to the SCLFlicButton delegate once the value has been updated. This value is represented + * in decibels and has an effective range from -100 to 0. + * + */ +- (void)readRSSI; + +@end + +/*! + * @protocol SCLFlicButtonDelegate + * + * @discussion The delegate of a SCLFlicButton object must adopt the SCLFlicButtonDelegate protocol. There are not + * any required delegate methods, but all are recommended for proper use of the Flic. + * + */ +@protocol SCLFlicButtonDelegate + +@required + +@optional + +/*! + * @method flicButton:didReceiveButtonDown:age: + * + * @param button The SCLFlicButton object that the event came from. + * @param queued This lets you know if the event is a queued event that happened before the flic connected or if it is a real time + * event. + * @param age The age of the trigger event in seconds. This is particularily important when receiving events that might have been + * queued up on flic while it was out of range. The units is in seconds and will be rounded to the nearest second. + * + * @discussion The flic registered a button down event. + * + */ +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonDown:(BOOL)queued age:(NSInteger)age; + +/*! + * @method flicButton:didReceiveButtonUp:age: + * + * @param button The SCLFlicButton object that the event came from. + * @param queued This lets you know if the event is a queued event that happened before the flic connected or if it is a real time + * event. + * @param age The age of the trigger event in seconds. This is particularily important when receiving events that might have been + * queued up on flic while it was out of range. The units is in seconds and will be rounded to the nearest second. + * + * @discussion The flic registered a button up event. + * + */ +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonUp:(BOOL)queued age:(NSInteger)age; + +/*! + * @method flicButton:didReceiveButtonClick:age: + * + * @param button The SCLFlicButton object that the event came from. + * @param queued This lets you know if the event is a queued event that happened before the flic connected or if it is a real time + * event. + * @param age The age of the trigger event in seconds. This is particularily important when receiving events that might have been + * queued up on flic while it was out of range. The units is in seconds and will be rounded to the nearest second. + * + * @discussion The flic registered a button click event. + * The behavior of this event depends on what SCLFlicButtonTriggerBehavior the triggerBehavior property is set to. + * + */ +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonClick:(BOOL)queued age:(NSInteger)age; + +/*! + * @method flicButton:didReceiveButtonDoubleClick:age: + * + * @param button The SCLFlicButton object that the event came from. + * @param queued This lets you know if the event is a queued event that happened before the flic connected or if it is a real time + * event. + * @param age The age of the trigger event in seconds. This is particularily important when receiving events that might have been + * queued up on flic while it was out of range. The units is in seconds and will be rounded to the nearest second. + * + * @discussion The flic registered a button double click event. + * The behavior of this event depends on what SCLFlicButtonTriggerBehavior the triggerBehavior property is set to. + * + */ +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonDoubleClick:(BOOL)queued age:(NSInteger)age; + +/*! + * @method flicButton:didReceiveButtonHold:age: + * + * @param button The SCLFlicButton object that the event came from. + * @param queued This lets you know if the event is a queued event that happened before the flic connected or if it is a real time + * event. + * @param age The age of the trigger event in seconds. This is particularily important when receiving events that might have been + * queued up on flic while it was out of range. The units is in seconds and will be rounded to the nearest second. + * + * @discussion The flic registered a button hold event. + * The behavior of this event depends on what SCLFlicButtonTriggerBehavior the triggerBehavior property is set to. + * + */ +- (void)flicButton:(SCLFlicButton * _Nonnull)button didReceiveButtonHold:(BOOL)queued age:(NSInteger)age; + +/*! + * @method flicButtonDidConnect: + * + * @param button The SCLFlicButton object that the event came from. + * + * @discussion This delegate method is called every time the flic physically connected to the iOS device, regardless of the reason for it. + * Keep in mind that you also have to wait for the flicButtonIsReady: before the flic is ready for use. + * The connectionState is not guaranteed to switch to SCLFlicButtonConnectionStateConnected until + * after the flicButtonIsReady: callback has arrived. + * + */ +- (void)flicButtonDidConnect:(SCLFlicButton * _Nonnull)button; + +/*! + * @method flicButtonIsReady: + * + * @param button The SCLFlicButton object that the event came from. + * + * @discussion This delegate method is called every time the flic has sucessfully connected and the autheticity has been verified. + * You will not receive any press events from the flic before this callback has been sent. Typically this event will be sent + * immediately after the flicButtonDidConnect: event. + * + */ +- (void)flicButtonIsReady:(SCLFlicButton * _Nonnull)button; + +/*! + * @method flicButton:didDisconnectWithError: + * + * @param button The SCLFlicButton object that the event came from. + * @param error The error that caused the disconnect. If the disconnect was intentional, then the parameter will be nil. + * + * @discussion This delegate method is called every time the flic has disconnected, regardless of the reason for it. + * This can sometimes be called during a connection event that failed before the user was notified of the connection. + * + */ +- (void)flicButton:(SCLFlicButton * _Nonnull)button didDisconnectWithError:(NSError * _Nullable)error; + +/*! + * @method flicButton:didFailToConnectWithError: + * + * @param button The SCLFlicButton object that the event came from. + * @param error The error that caused the flic to fail to connect. + * + * @discussion The requested connection failed. Please note that depending on at what point in the connection process the connection + * failed you might also receive a regular flicButtonDidDisconnect: as well. If the connection fails and this callback is + * made then the flic will always cancel the pending connection, regardless of what state the flic happens to be in. + * This means that if you get a flicButton:didFailToConnectWithError: then you + * need to call the connect: yourself to activate the pending connection once again. + * + */ +- (void)flicButton:(SCLFlicButton * _Nonnull)button didFailToConnectWithError:(NSError * _Nullable)error; + +/*! + * @method flicButton:didUpdateRSSI:error: + * + * @param button The SCLFlicButton object that the event came from. + * @param RSSI The RSSI value represented in decibels. + * @param error In case there was a problem with updating the RSSI value then this parameter will describe the error. + * This will in all other cases be nil. + * + * @discussion This callback verifies (unless an error occurred) that the RSSI value was updated. + * + */ +- (void)flicButton:(SCLFlicButton * _Nonnull)button didUpdateRSSI:(NSNumber * _Nonnull)RSSI error:(NSError * _Nullable)error; + +@end diff --git a/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/SCLFlicManager.h b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/SCLFlicManager.h new file mode 100644 index 0000000..a9a8fb7 --- /dev/null +++ b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/SCLFlicManager.h @@ -0,0 +1,293 @@ +// +// @file SCLFlicManager.h +// @framework fliclib +// +// Created by Anton Meier on 2014-06-18. +// Copyright (c) 2020 Shortcut Labs. All rights reserved. +// + +#import +#import +#import "SCLFlicButton.h" + +/*! + * @enum SCLFlicManagerBluetoothState + * + * @discussion These enums represents the different possible states that the manager can be in at any given time. + * The manager needs to be in the SCLFlicManagerBluetoothStatePoweredOn state in order for it to perform + * any kind of communication with a flic. + * + */ +typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) +{ + /** + * This state is the desired state that is needed when communicating with a flic. + */ + SCLFlicManagerBluetoothStatePoweredOn = 0, + /** + * This state means that the manager is currently powered off and will not be able to perform any bluetooth related tasks. + * This will for example be the case when bluetooth is turned off on the iOS device. + */ + SCLFlicManagerBluetoothStatePoweredOff, + /** + * The manager is resetting and will most likely switch to the powered on state shortly. + */ + SCLFlicManagerBluetoothStateResetting, + /** + * The manager was not able to turn on because the iOS device that it is currently running on does not support Bluetooth Low Energy. + */ + SCLFlicManagerBluetoothStateUnsupported, + /** + * The manager was not able to turn on because the app is not authorized to to use Bluetooth Low Energy. + */ + SCLFlicManagerBluetoothStateUnauthorized, + /** + * The manager is in an unknown state, it will most likely change shortly. + */ + SCLFlicManagerBluetoothStateUnknown, +}; + +@protocol SCLFlicManagerDelegate; + +/*! + * @class SCLFlicManager + * + * @discussion An instance of this class is required in order to perform any bluetooth LE communication with + * the flic. The object will keep track of all the flics that are associated to the specific iOS device. + * It is important to mention that the SCLFlicManager does not support the regular state preservation + * and restoration protocol for view controllers, meaning that it does not support NSCoding. + * Instead, all of the state preservation will be taken cared of for you by the manager. + * Simply reinstantiate it using the initWithDelegate:appID:appSecret:andRestoreState: method + * and collect the associated flic objects using the knownButtons: method. + * + */ +@interface SCLFlicManager : NSObject +{ + +} + +/*! + * @property delegate + * + * @discussion The delegate object that will receive all the flic related events. See the definition of the + * SCLFlicManagerDelegate to see what callbacks are available. + * + */ +@property(weak, nonatomic, nullable) id delegate; + +/*! + * @property defaultButtonDelegate + * + * @discussion The default delegate that will be assigned to all buttons both when they are grabbed, but also during state + * restoration. This is not required since the button delegates can be set manually. If you decide to set them + * manually then you have to also remember to set them on on every application restoration when the manager + * sends the flicManagerDidRestoreState callback. + * + */ +@property(weak, nonatomic, nullable) id defaultButtonDelegate; + +/*! + * @property bluetoothState + * + * @discussion The current bluetoothState of the flic manager. A bluetoothDidChangeState event will be generated + * on the SCLFlicManagerDelegate whenever this state has changed. When the flic manager is initialized + * the state will be SCLFlicManagerBluetoothStateUnknown by default. You will not be able to do any + * bluetooth related tasks until the manager properly changes to SCLFlicManagerBluetoothStateOn. + * + */ +@property(nonatomic, readonly) SCLFlicManagerBluetoothState bluetoothState; + +/*! + * @property enabled + * + * @discussion This is a flag that lets you know if the manager is enabled for Bluetooth LE communication. This can be toggled on/off using the + * enable and disable. When This property is set to NO, then no Bluetooth LE communication + * will be allowed. This means that no communication with a flic can be made. + */ +@property(readonly, getter=isEnabled) BOOL enabled; + +/*! + * @method sharedManager + * + * @discussion Use this to access the manager singleton. This will only work if a call to configureWithDelegate:appID:appSecret:backgroundExecution: + * has been made once this app session, otherwise nil will be returned. + */ ++ (instancetype _Nullable)sharedManager; + +/*! + * @method configureWithDelegate:defaultButtonDelegate:appID:appSecret:backgroundExecution: + * + * @discussion The initialization call to use when you want to create a manager. This will initiate a SCLFlicManager and do the proper + * preparation needed in order to start the bluetooth communication with flic buttons. The BOOL restore included + * in the initialization call decides whether a brand new manager will be created or if it should be created and restored to + * the last known state of the most previous manager created by the same app. If you choose to create a new manager then any old + * manager (if existing) will be irreversibly cleared. Using more than one manager in the same application is not supported. + *

+ * When choosing the restore option all settings on the manager will be restored. This will also recreate all SCLFlicButtons + * that had previously been used with this manager unless they had been manually removed using the forgetButton: + * method. All the flic objects that had a pending connection before will be set to the same state after restoration. When the + * restoration process is complete the manager will call the flicManagerDidRestoreState: method of its delegate + * object. At that point it is recommended that you call knownButtons: in order to collect all the flic objects and + * re-set their delegate. + * + * @param delegate The delegate that all callbacks will be sent to. + * @param buttonDelegate This delegate will automatically be set to new buttons and old buttons on app restoration. + * @param appID This is the App-ID string that the developer is required to have in order to use the fliclib framework. + * @param appSecret This is the App-Secret string that the developer is required to have in order to use the fliclib framework. + * @param bExecution Flag that specifies if want to configure the Flic manager to support background execution. If YES, then you also + * have to check the "Uses Bluetooth LE accessories" option under your projects Background Modes settings. + * + */ + ++ (instancetype _Nullable)configureWithDelegate:(id _Nullable)delegate + defaultButtonDelegate:(id _Nullable)buttonDelegate + appID:(NSString * _Nonnull)appID + appSecret:(NSString * _Nonnull)appSecret + backgroundExecution:(BOOL)bExecution; + +/*! + * @method knownButtons: + * + * @discussion All buttons that have ever been added to the manager and not manually been forgotten/removed. + * + * @return Dictionary containing the SCLFlicButton objects. The keys are of NSUUID type that represent the buttonIdentifier + * of the SCLFlicButton instance. + * + */ +- (NSDictionary * _Nonnull)knownButtons; + +/*! + * @method forgetButton: + * + * @discussion This will attempt to completely remove the flic button from the manager and clear the SCLFlicButton instance. If the flic + * is connected when this method is called then it will also be disconnected first. Remember to clear all your references + * to this particular button instance so that it properly gets cleared from memory. + * + * @param button The button that you wish to destroy. + * + */ +- (void)forgetButton:(SCLFlicButton * _Nonnull)button; + +/*! + * @method disable + * + * @discussion This will disable all bluetooth communication and disconnect all currently connected buttons and pending connections. + * You will not be able to do any communication with a flic until you call enable. + * + */ +- (void)disable; + +/*! + * @method enable + * + * @discussion This will enable the bluetooth communication after it has previously been disabled. It will not however reconnect any buttons, + * that will have to be handled manually. This is unless you have the flic(s) configured to be in KeepAlive mode, + * in which case the connect will automatically be sent. + * + */ +- (void)enable; + +/*! + * @method grabFlicFromFlicAppWithCallbackUrlScheme: + * + * @discussion This will launch the Flic app and allow the user to select the Flic button to assign to this App. + * + * @param scheme This is the callback URL that you have registered in your Plist file and want the Flic app to return + * the grabbed Flic to. Remember that this is only the scheme name that you have registered, and NOT a + * full URL. + * + */ +- (void)grabFlicFromFlicAppWithCallbackUrlScheme:(NSString * _Nonnull)scheme; + +/*! + * @method handleOpenURL: + * + * @discussion Call this method with the URL returned from the Flic app. A callback will be sent if a button can be created. + * + * @param url This is the full url that was returned from the Flic app. + * + * @return If this url can be handled by the flic manager or not. + * + */ +- (BOOL)handleOpenURL:(NSURL * _Nonnull)url; + + +/*! + * @method onLocationChange + * + * @discussion Call this method on significant location changes. This will go through all pending connections and make sure that they are in the + * proper state. This is needed since we can not rely on Apple to take care of that to 100%. + * + */ +- (void)onLocationChange; + +@end + +/*! + * @protocol SCLFlicManagerDelegate + * + * @discussion The delegate of a SCLFlicManager instance must adopt the SCLFlicManagerDelegate protocol. There are no + * required delegate methods, but flicManagerDidChangeBluetoothState is highly recommended. + * + */ +@protocol SCLFlicManagerDelegate + +@required + +/*! + * @method flicManager:didGrabFlicButton:withError: + * + * @param manager The manager providing this information. + * @param button The SCLFlicButton object that was grabbed from the Flic app + * @param error In case something went wrong while grabbing the Flic this parameter will explain the error. + * + * @discussion This delegate method is called every time the a new Flic button is grabbed from the Flic App. + * + */ +- (void)flicManager:(SCLFlicManager * _Nonnull)manager didGrabFlicButton:(SCLFlicButton * _Nullable)button withError:(NSError * _Nullable)error; + +@optional + +/*! + * @method flicManager:didChangeBluetoothState: + * + * @param manager The flic manager providing this information. + * @param state The state that the manager changed to that caused the callback. Notice that there is no guarantee that it has not changed since! + * + * @discussion If the bluetooth state on the iOS device or the flicManager changes for any reason, then this delegate method will be called + * letting you that something happened. A parameter state will be included, but it is a good practice to always read + * the most current value of the bluetoothState property on the manager to get info about the current state, since + * there is a chance that the state could have changed again while the callback was sent. If the state changes to + * SCLFlicManagerBluetoothStatePoweredOn then all the previous connections and pending connections will be set back to + * pending again. + * + */ +- (void)flicManager:(SCLFlicManager * _Nonnull)manager didChangeBluetoothState:(SCLFlicManagerBluetoothState)state; + +/*! + * @method flicManagerDidRestoreState: + * + * @param manager The flic manager providing this information. + * + * @discussion This delegate method will be called after the manager has been properly restored after being terminated by + * the system. All the flic buttons that that you had prior to being terminated have been restored as well and + * this is a good time to collect all the SCLFlicButton objects by using the knownButtons: method in + * order to properly restore the rest of your application. Do not forget to re-set the delegate on all buttons. + * + */ +- (void)flicManagerDidRestoreState:(SCLFlicManager * _Nonnull)manager; + +/*! + * @method flicManager:didForgetButton:error: + * + * @param manager The flic manager providing this information. + * @param buttonIdentifier The buttonIdentifier of the SCLFlicButton object that was cleared + * @param error In case there was an error + * + * @discussion This callback will be made when a flic has been properly forgotten/removed, unless there was an error. Remember + * to also remove your references in case you still have any. + * + */ +- (void)flicManager:(SCLFlicManager * _Nonnull)manager didForgetButton:(NSUUID * _Nonnull)buttonIdentifier error:(NSError * _Nullable)error; + +@end diff --git a/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/fliclib.h b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/fliclib.h new file mode 100644 index 0000000..c3292f4 --- /dev/null +++ b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Headers/fliclib.h @@ -0,0 +1,20 @@ +// +// fliclib.h +// fliclib +// +// Created by Anton Meier on 2016-04-20. +// Copyright (c) 2020 Shortcut Labs. All rights reserved. +// + +#import + +#import +#import + +//! Project version number for fliclib. +FOUNDATION_EXPORT double fliclibVersionNumber; + +//! Project version string for fliclib. +FOUNDATION_EXPORT const unsigned char fliclibVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import diff --git a/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Info.plist b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Info.plist new file mode 100644 index 0000000..fb06338 Binary files /dev/null and b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Info.plist differ diff --git a/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Modules/module.modulemap b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Modules/module.modulemap new file mode 100644 index 0000000..f81d126 --- /dev/null +++ b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module fliclib { + umbrella header "fliclib.h" + + export * + module * { export * } +} diff --git a/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/fliclib b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/fliclib new file mode 100755 index 0000000..9e70e33 Binary files /dev/null and b/fliclib.xcframework/ios-x86_64_i386-simulator/fliclib.framework/fliclib differ diff --git a/simulator-wrapper/.DS_Store b/simulator-wrapper/.DS_Store deleted file mode 100644 index 6eeb4ca..0000000 Binary files a/simulator-wrapper/.DS_Store and /dev/null differ diff --git a/simulator-wrapper/SCLFlicButtonSimulator.h b/simulator-wrapper/SCLFlicButtonSimulator.h deleted file mode 100644 index a2d1125..0000000 --- a/simulator-wrapper/SCLFlicButtonSimulator.h +++ /dev/null @@ -1,102 +0,0 @@ -// -// @file SCLFlicButtonSimulator.h -// @framework fliclib -// -// Created by Anton Meier on 2016-06-17. -// Copyright (c) 2016 Shortcut Labs. All rights reserved. -// - -#import -@class UIColor; - -typedef NS_ENUM(NSInteger, SCLFlicButtonConnectionState) { - SCLFlicButtonConnectionStateConnected = 0, - SCLFlicButtonConnectionStateConnecting, - SCLFlicButtonConnectionStateDisconnected, - SCLFlicButtonConnectionStateDisconnecting, -}; - -typedef NS_ENUM(NSInteger, SCLFlicButtonLEDIndicateCount) { - SCLFlicButtonLEDIndicateCount1 = 1, - SCLFlicButtonLEDIndicateCount2, - SCLFlicButtonLEDIndicateCount3, - SCLFlicButtonLEDIndicateCount4, - SCLFlicButtonLEDIndicateCount5, -}; - -typedef NS_ENUM(NSInteger, SCLFlicButtonTriggerBehavior) { - SCLFlicButtonTriggerBehaviorClickAndHold = 0, - SCLFlicButtonTriggerBehaviorClickAndDoubleClick, - SCLFlicButtonTriggerBehaviorClickAndDoubleClickAndHold, -}; - -typedef NS_ENUM(NSInteger, SCLFlicError) { - SCLFlicErrorUnknown = 0, - SCLFlicErrorCouldNotCompleteTask = 1, - SCLFlicErrorConnectionFailed = 2, - SCLFlicErrorCouldNotUpdateRSSI = 3, - SCLFlicErrorButtonIsPrivate = 10, - SCLFlicErrorCryptographicFailure = 11, - SCLFlicErrorMissingData = 13, - SCLFlicErrorInvalidSignature = 14, - SCLFlicErrorButtonAlreadyGrabbed = 15, - SCLFlicErrorBluetoothErrorUnknown = 100, - SCLFlicErrorBluetoothErrorInvalidParameters = 101, - SCLFlicErrorBluetoothErrorInvalidHandle = 102, - SCLFlicErrorBluetoothErrorNotConnected = 103, - SCLFlicErrorBluetoothErrorOutOfSpace = 104, - SCLFlicErrorBluetoothErrorOperationCancelled = 105, - SCLFlicErrorBluetoothErrorConnectionLost = 106, - SCLFlicErrorBluetoothErrorPeripheralDisconnected = 107, - SCLFlicErrorBluetoothErrorUUIDNotAllowed = 108, - SCLFlicErrorBluetoothErrorAlreadyAdvertising = 109, - SCLFlicErrorBluetoothErrorConnectionFailed = 110, - SCLFlicErrorBluetoothErrorConnectionLimitReached = 111, - SCLFlicErrorFlicRefusedConnection = 200, -}; - -@protocol SCLFlicButtonDelegate; - -@interface SCLFlicButton : NSObject { - -} - -@property(weak, nonatomic, nullable) id delegate; -@property (readonly, nonatomic, strong, nonnull) NSUUID *buttonIdentifier; -@property (readonly, nonatomic, strong, nonnull) NSString *buttonPublicKey; -@property (atomic, readonly, strong, nonnull) NSString *name; -@property (atomic, readonly, strong, nonnull) UIColor *color; -@property (atomic, readonly, strong, nonnull) NSString *userAssignedName; -@property (atomic, readonly) SCLFlicButtonConnectionState connectionState; -@property (nonatomic, readwrite) BOOL lowLatency; -@property (nonatomic, readwrite) SCLFlicButtonTriggerBehavior triggerBehavior; -@property (nonatomic, readonly) int pressCount; -@property (readonly) BOOL isReady; - - -- (void) connect; -- (void) disconnect; -- (void) indicateLED: (SCLFlicButtonLEDIndicateCount) count; -- (void) readRSSI; - -@end - -@protocol SCLFlicButtonDelegate - -@required - -@optional - -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonDown:(BOOL) queued age: (NSInteger) age; -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonUp:(BOOL) queued age: (NSInteger) age; -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonClick:(BOOL) queued age: (NSInteger) age; -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonDoubleClick:(BOOL) queued age: (NSInteger) age; -- (void) flicButton:(SCLFlicButton * _Nonnull) button didReceiveButtonHold:(BOOL) queued age: (NSInteger) age; -- (void) flicButtonDidConnect:(SCLFlicButton * _Nonnull) button; -- (void) flicButtonIsReady:(SCLFlicButton * _Nonnull) button; -- (void) flicButton:(SCLFlicButton * _Nonnull) button didDisconnectWithError:(NSError * _Nullable) error; -- (void) flicButton:(SCLFlicButton * _Nonnull) button didFailToConnectWithError:(NSError * _Nullable) error; -- (void) flicButton:(SCLFlicButton * _Nonnull) button didUpdateRSSI:(NSNumber * _Nonnull) RSSI error:(NSError * _Nullable) error; - -@end - diff --git a/simulator-wrapper/SCLFlicButtonSimulator.m b/simulator-wrapper/SCLFlicButtonSimulator.m deleted file mode 100644 index 63fb597..0000000 --- a/simulator-wrapper/SCLFlicButtonSimulator.m +++ /dev/null @@ -1,76 +0,0 @@ -// -// @file SCLFlicButtonSimulator.m -// @framework fliclib -// -// Created by Anton Meier on 2016-06-17. -// Copyright (c) 2016 Shortcut Labs. All rights reserved. -// - -#import "SCLFlicButtonSimulator.h" -#if TARGET_OS_SIMULATOR - -#import - -@implementation SCLFlicButton - -- (instancetype) init { - self = [super init]; - if ( self != nil ) { - NSLog(@"SCLFlicButtonSimulator init"); - _isReady = YES; - _lowLatency = NO; - _buttonIdentifier = [NSUUID UUID]; - _name=[NSString stringWithFormat:@"FLIC: %@", _buttonIdentifier.UUIDString ]; - _connectionState=SCLFlicButtonConnectionStateConnected; - _triggerBehavior = SCLFlicButtonTriggerBehaviorClickAndHold; - _pressCount = 0; - _buttonPublicKey = _buttonIdentifier.UUIDString; - _userAssignedName = @"My Flic"; - _color = [UIColor whiteColor]; - - // Uncomment to recieve a button down 2 seconds after grab. - /* - __weak SCLFlicButton *flicButton = self; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - if ([flicButton.delegate respondsToSelector:@selector(flicButton:didReceiveButtonDown:age:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [flicButton.delegate flicButton:self didReceiveButtonDown:NO age:0]; }); - } - }); - */ - return self; - } - return nil; -} - -- (void) connect { - _connectionState = SCLFlicButtonConnectionStateConnected; - if ([self.delegate respondsToSelector:@selector(flicButtonDidConnect:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [self.delegate flicButtonDidConnect:self]; }); - } - _isReady = YES; - if ([self.delegate respondsToSelector:@selector(flicButtonIsReady:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [self.delegate flicButtonIsReady:self]; }); - } -} - -- (void) disconnect { - _connectionState = SCLFlicButtonConnectionStateConnected; - _isReady = NO; - if ([self.delegate respondsToSelector:@selector(flicButton:didDisconnectWithError:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [self.delegate flicButton:self didDisconnectWithError:nil]; }); - } -} - -- (void) indicateLED: (SCLFlicButtonLEDIndicateCount) count { - -} - -- (void) readRSSI { - if ([self.delegate respondsToSelector:@selector(flicButton:didUpdateRSSI:error:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [self.delegate flicButton:self didUpdateRSSI:[NSNumber numberWithInt: -1] error:nil]; }); - } -} - -@end - -#endif diff --git a/simulator-wrapper/SCLFlicManagerSimulator.h b/simulator-wrapper/SCLFlicManagerSimulator.h deleted file mode 100644 index 5d08070..0000000 --- a/simulator-wrapper/SCLFlicManagerSimulator.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// @file SCLFlicManagerSimulator.h -// @framework fliclib -// -// Created by Anton Meier on 2016-05-17. -// Copyright (c) 2016 Shortcut Labs. All rights reserved. -// - -#import -#import "SCLFlicButtonSimulator.h" - -typedef NS_ENUM(NSInteger, SCLFlicManagerBluetoothState) { - SCLFlicManagerBluetoothStatePoweredOn = 0, - SCLFlicManagerBluetoothStatePoweredOff, - SCLFlicManagerBluetoothStateResetting, - SCLFlicManagerBluetoothStateUnsupported, - SCLFlicManagerBluetoothStateUnauthorized, - SCLFlicManagerBluetoothStateUnknown, -}; - -@protocol SCLFlicManagerDelegate; - -@interface SCLFlicManager : NSObject { - -} - -@property(weak, nonatomic, nullable) id delegate; -@property(weak, nonatomic, nullable) id defaultButtonDelegate; -@property (nonatomic, readonly) SCLFlicManagerBluetoothState bluetoothState; -@property (readonly, getter=isEnabled) BOOL enabled; - -+ (instancetype _Nullable) sharedManager; -+ (instancetype _Nullable) configureWithDelegate:(id _Nullable) delegate defaultButtonDelegate: (id _Nullable) buttonDelegate appID: (NSString * _Nonnull) appID appSecret: (NSString * _Nonnull) appSecret backgroundExecution: (BOOL) bExecution; -- (NSDictionary * _Nonnull) knownButtons; -- (void) forgetButton:(SCLFlicButton * _Nonnull) button; -- (void) disable; -- (void) enable; -- (void) grabFlicFromFlicAppWithCallbackUrlScheme: (NSString * _Nonnull) scheme; -- (BOOL) handleOpenURL: (NSURL * _Nonnull) url; -- (void) onLocationChange; - -@end - - -@protocol SCLFlicManagerDelegate - -@required - -- (void) flicManager:(SCLFlicManager * _Nonnull) manager didGrabFlicButton:(SCLFlicButton * _Nullable) button withError: (NSError * _Nullable) error; - -@optional - -- (void) flicManager:(SCLFlicManager * _Nonnull) manager didChangeBluetoothState: (SCLFlicManagerBluetoothState) state; -- (void) flicManagerDidRestoreState:(SCLFlicManager * _Nonnull) manager; -- (void) flicManager:(SCLFlicManager * _Nonnull) manager didForgetButton:(NSUUID * _Nonnull) buttonIdentifier error:(NSError * _Nullable)error; - -@end diff --git a/simulator-wrapper/SCLFlicManagerSimulator.m b/simulator-wrapper/SCLFlicManagerSimulator.m deleted file mode 100644 index 822c167..0000000 --- a/simulator-wrapper/SCLFlicManagerSimulator.m +++ /dev/null @@ -1,101 +0,0 @@ -// -// @file SCLFlicManagerSimulator.m -// @framework fliclib -// -// Created by Anton Meier on 2016-05-17. -// Copyright (c) 2016 Shortcut Labs. All rights reserved. -// - -#import "SCLFlicManagerSimulator.h" -#if TARGET_OS_SIMULATOR - -@interface SCLFlicManager () - -@property (nonatomic, strong) NSMutableDictionary *buttonDictionary; - -@end - -@interface SCLFlicButton () - -- (instancetype) init; - -@end - -@implementation SCLFlicManager - -static SCLFlicManager *_sharedManager = nil; - -+ (SCLFlicManager *) sharedManager; { - return _sharedManager; -} - -+ (instancetype _Nullable) configureWithDelegate:(id _Nullable) delegate defaultButtonDelegate: (id _Nullable) buttonDelegate appID: (NSString * _Nonnull) appID appSecret: (NSString * _Nonnull) appSecret backgroundExecution: (BOOL) bExecution; { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - _sharedManager = [[SCLFlicManager alloc] initWithDelegate:delegate buttonDelegate:buttonDelegate]; - if ([SCLFlicManager sharedManager].delegate && [[SCLFlicManager sharedManager].delegate respondsToSelector:@selector(flicManagerDidRestoreState:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [[SCLFlicManager sharedManager].delegate flicManagerDidRestoreState:[SCLFlicManager sharedManager]]; }); - } - if ([SCLFlicManager sharedManager].delegate && [[SCLFlicManager sharedManager].delegate respondsToSelector:@selector(flicManager:didChangeBluetoothState:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [[SCLFlicManager sharedManager].delegate flicManager:[SCLFlicManager sharedManager] didChangeBluetoothState:[SCLFlicManager sharedManager].bluetoothState]; }); - } - }); - - return _sharedManager; -} - -- (instancetype) initWithDelegate: (id _Nullable) delegate buttonDelegate: (id _Nullable) buttonDelegate { - self = [super init]; - if ( self != nil ) { - NSLog(@"SCLFlicManagerSimulator init"); - _enabled = YES; - _delegate = delegate; - _buttonDictionary = [NSMutableDictionary dictionary]; - _defaultButtonDelegate = buttonDelegate; - _bluetoothState = SCLFlicManagerBluetoothStatePoweredOn; - return self; - } - return nil; -} - -- (void) forgetButton:(SCLFlicButton *) button { - if ([self.buttonDictionary objectForKey:button.buttonIdentifier]) { - [self.buttonDictionary removeObjectForKey:button.buttonIdentifier]; - if (self.delegate && [self.delegate respondsToSelector:@selector(flicManager:didForgetButton:error:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [self.delegate flicManager:self didForgetButton:button.buttonIdentifier error:nil]; }); - } - } -} - -- (void) disable { - _enabled = NO; -} - -- (void) enable { - _enabled = YES; -} - -- (NSDictionary*) knownButtons { - return [self.buttonDictionary copy]; -} - -- (void) onLocationChange { - -} - -- (BOOL) handleOpenURL: (NSURL * _Nonnull) url; { - return YES; -} - -- (void) grabFlicFromFlicAppWithCallbackUrlScheme: (NSString *) scheme { - SCLFlicButton *button = [[SCLFlicButton alloc] init]; - button.delegate = self.defaultButtonDelegate; - [self.buttonDictionary setObject:button forKey:button.buttonIdentifier]; - if (self.delegate && [self.delegate respondsToSelector:@selector(flicManager:didGrabFlicButton:withError:)]) { - dispatch_async(dispatch_get_main_queue(), ^{ [self.delegate flicManager:self didGrabFlicButton:button withError:nil]; }); - } -} - -@end - -#endif diff --git a/simulator-wrapper/fliclibWrapper.h b/simulator-wrapper/fliclibWrapper.h deleted file mode 100644 index 2324f48..0000000 --- a/simulator-wrapper/fliclibWrapper.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// fliclibWrapper.h -// fliclib -// -// Created by Anton Meier on 2016-04-20. -// Copyright (c) 2016 Shortcut Labs. All rights reserved. -// - -#if TARGET_OS_SIMULATOR - -#import "SCLFlicManagerSimulator.h" - -#else - -#import - -#endif