Commit 0cd8a872 authored by 刘俊宏's avatar 刘俊宏

pod 'SVProgressHUD' pod 'BabyBluetooth'

parent bec7f063
...@@ -24,4 +24,6 @@ pod 'RealmSwift' ...@@ -24,4 +24,6 @@ pod 'RealmSwift'
pod 'SnapKit' pod 'SnapKit'
pod 'LGButton' pod 'LGButton'
pod 'WYAutoLayout' pod 'WYAutoLayout'
pod 'BabyBluetooth'
pod 'SVProgressHUD'
end end
\ No newline at end of file
PODS: PODS:
- Alamofire (4.9.1) - Alamofire (4.9.1)
- BabyBluetooth (0.7.0)
- CryptoSwift (1.3.0) - CryptoSwift (1.3.0)
- Dollar (9.0.0) - Dollar (9.0.0)
- ESTabBarController-swift (2.8.0) - ESTabBarController-swift (2.8.0)
...@@ -17,6 +18,7 @@ PODS: ...@@ -17,6 +18,7 @@ PODS:
- Realm (= 4.4.0) - Realm (= 4.4.0)
- SkeletonView (1.8.7) - SkeletonView (1.8.7)
- SnapKit (4.2.0) - SnapKit (4.2.0)
- SVProgressHUD (2.2.5)
- SwiftDate (6.1.0) - SwiftDate (6.1.0)
- SwifterSwift (5.1.0): - SwifterSwift (5.1.0):
- SwifterSwift/AppKit (= 5.1.0) - SwifterSwift/AppKit (= 5.1.0)
...@@ -45,6 +47,7 @@ PODS: ...@@ -45,6 +47,7 @@ PODS:
DEPENDENCIES: DEPENDENCIES:
- Alamofire - Alamofire
- BabyBluetooth
- CryptoSwift - CryptoSwift
- Dollar - Dollar
- ESTabBarController-swift - ESTabBarController-swift
...@@ -58,6 +61,7 @@ DEPENDENCIES: ...@@ -58,6 +61,7 @@ DEPENDENCIES:
- RealmSwift - RealmSwift
- SkeletonView - SkeletonView
- SnapKit - SnapKit
- SVProgressHUD
- SwiftDate - SwiftDate
- SwifterSwift - SwifterSwift
- SwiftyJSON - SwiftyJSON
...@@ -67,6 +71,7 @@ DEPENDENCIES: ...@@ -67,6 +71,7 @@ DEPENDENCIES:
SPEC REPOS: SPEC REPOS:
trunk: trunk:
- Alamofire - Alamofire
- BabyBluetooth
- CryptoSwift - CryptoSwift
- Dollar - Dollar
- ESTabBarController-swift - ESTabBarController-swift
...@@ -81,6 +86,7 @@ SPEC REPOS: ...@@ -81,6 +86,7 @@ SPEC REPOS:
- RealmSwift - RealmSwift
- SkeletonView - SkeletonView
- SnapKit - SnapKit
- SVProgressHUD
- SwiftDate - SwiftDate
- SwifterSwift - SwifterSwift
- SwiftyJSON - SwiftyJSON
...@@ -89,6 +95,7 @@ SPEC REPOS: ...@@ -89,6 +95,7 @@ SPEC REPOS:
SPEC CHECKSUMS: SPEC CHECKSUMS:
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18 Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
BabyBluetooth: d50758aecf24d4a0ab9271d69f0f116d6bee51c9
CryptoSwift: 1283821600233bdbeb96d7b389c3288c3bf77211 CryptoSwift: 1283821600233bdbeb96d7b389c3288c3bf77211
Dollar: 2fc9bdeeb2d3ae1f251461803240d5c93829ee0c Dollar: 2fc9bdeeb2d3ae1f251461803240d5c93829ee0c
ESTabBarController-swift: 05593a6ad64700b03c0eb60ff625916370aa4136 ESTabBarController-swift: 05593a6ad64700b03c0eb60ff625916370aa4136
...@@ -103,12 +110,13 @@ SPEC CHECKSUMS: ...@@ -103,12 +110,13 @@ SPEC CHECKSUMS:
RealmSwift: 33656a42bd300959a081fc13347376bc478071af RealmSwift: 33656a42bd300959a081fc13347376bc478071af
SkeletonView: ba5370f41280b2f0a76918bb143c1294232bb4f4 SkeletonView: ba5370f41280b2f0a76918bb143c1294232bb4f4
SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftDate: fa2bb3962056bb44047b4b85a30044e5eae30b03 SwiftDate: fa2bb3962056bb44047b4b85a30044e5eae30b03
SwifterSwift: a9e8e144832638c2850b43da5feaf9598c6ad65b SwifterSwift: a9e8e144832638c2850b43da5feaf9598c6ad65b
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7 SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7
ViewAnimator: 5af1c6f3b310f012bf081259c43717aa54fbae73 ViewAnimator: 5af1c6f3b310f012bf081259c43717aa54fbae73
WYAutoLayout: 3cb136ddc2efa9faaecf15876e6a9b2a6fd7c6cb WYAutoLayout: 3cb136ddc2efa9faaecf15876e6a9b2a6fd7c6cb
PODFILE CHECKSUM: f7cea575720bdb85bdc196fb0c179b4966897e6e PODFILE CHECKSUM: 5362542ba7b343b78bf3e0ee7359bad79d3db6ae
COCOAPODS: 1.9.1 COCOAPODS: 1.9.1
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
version:0.7.0
*/
// Created by 刘彦玮 on 15/3/31.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BabyCentralManager.h"
#import "BabyPeripheralManager.h"
#import "BabyToy.h"
#import "BabySpeaker.h"
#import "BabyRhythm.h"
#import "BabyDefine.h"
@interface BabyBluetooth : NSObject
#pragma mark - babybluetooth的委托
//默认频道的委托
/**
设备状态改变的block | when CentralManager state changed
*/
- (void)setBlockOnCentralManagerDidUpdateState:(void (^)(CBCentralManager *central))block;
/**
找到Peripherals的block | when find peripheral
*/
- (void)setBlockOnDiscoverToPeripherals:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI))block;
/**
连接Peripherals成功的block
| when connected peripheral
*/
- (void)setBlockOnConnected:(void (^)(CBCentralManager *central,CBPeripheral *peripheral))block;
/**
连接Peripherals失败的block
| when fail to connect peripheral
*/
- (void)setBlockOnFailToConnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
/**
断开Peripherals的连接的block
| when disconnected peripheral
*/
- (void)setBlockOnDisconnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
/**
设置查找服务的block
| when discover services of peripheral
*/
- (void)setBlockOnDiscoverServices:(void (^)(CBPeripheral *peripheral,NSError *error))block;
/**
设置查找到Characteristics的block
| when discovered Characteristics
*/
- (void)setBlockOnDiscoverCharacteristics:(void (^)(CBPeripheral *peripheral,CBService *service,NSError *error))block;
/**
设置获取到最新Characteristics值的block
| when read new characteristics value or notiy a characteristics value
*/
- (void)setBlockOnReadValueForCharacteristic:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block;
/**
设置查找到Descriptors名称的block
| when discover descriptors for characteristic
*/
- (void)setBlockOnDiscoverDescriptorsForCharacteristic:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block;
/**
设置读取到Descriptors值的block
| when read descriptors for characteristic
*/
- (void)setBlockOnReadValueForDescriptors:(void (^)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error))block;
/**
写Characteristic成功后的block
| when did write value for characteristic successed
*/
- (void)setBlockOnDidWriteValueForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
/**
写descriptor成功后的block
| when did write value for descriptor successed
*/
- (void)setBlockOnDidWriteValueForDescriptor:(void (^)(CBDescriptor *descriptor,NSError *error))block;
/**
characteristic订阅状态改变的block
| when characteristic notification state changed
*/
- (void)setBlockOnDidUpdateNotificationStateForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
/**
读取RSSI的委托
| when did read RSSI
*/
- (void)setBlockOnDidReadRSSI:(void (^)(NSNumber *RSSI,NSError *error))block;
/**
discoverIncludedServices的回调,暂时在babybluetooth中无作用
| no used in babybluetooth
*/
- (void)setBlockOnDidDiscoverIncludedServicesForService:(void (^)(CBService *service,NSError *error))block;
/**
外设更新名字后的block
| when peripheral update name
*/
- (void)setBlockOnDidUpdateName:(void (^)(CBPeripheral *peripheral))block;
/**
外设更新服务后的block
| when peripheral update services
*/
- (void)setBlockOnDidModifyServices:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block;
// channel的委托
/**
设备状态改变的block
| when CentralManager state changed
*/
- (void)setBlockOnCentralManagerDidUpdateStateAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central))block;
/**
找到Peripherals的block
| when find peripheral
*/
- (void)setBlockOnDiscoverToPeripheralsAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI))block;
/**
连接Peripherals成功的block
| when connected peripheral
*/
- (void)setBlockOnConnectedAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral))block;
/**
连接Peripherals失败的block
| when fail to connect peripheral
*/
- (void)setBlockOnFailToConnectAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
/**
断开Peripherals的连接的block
| when disconnected peripheral
*/
- (void)setBlockOnDisconnectAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
/**
设置查找服务的block
| when discover services of peripheral
*/
- (void)setBlockOnDiscoverServicesAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,NSError *error))block;
/**
设置查找到Characteristics的block
| when discovered Characteristics
*/
- (void)setBlockOnDiscoverCharacteristicsAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,CBService *service,NSError *error))block;
/**
设置获取到最新Characteristics值的block
| when read new characteristics value or notiy a characteristics value
*/
- (void)setBlockOnReadValueForCharacteristicAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block;
/**
设置查找到Characteristics描述的block
| when discover descriptors for characteristic
*/
- (void)setBlockOnDiscoverDescriptorsForCharacteristicAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error))block;
/**
设置读取到Characteristics描述的值的block
| when read descriptors for characteristic
*/
- (void)setBlockOnReadValueForDescriptorsAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error))block;
/**
写Characteristic成功后的block
| when did write value for characteristic successed
*/
- (void)setBlockOnDidWriteValueForCharacteristicAtChannel:(NSString *)channel
block:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
/**
写descriptor成功后的block
| when did write value for descriptor successed
*/
- (void)setBlockOnDidWriteValueForDescriptorAtChannel:(NSString *)channel
block:(void (^)(CBDescriptor *descriptor,NSError *error))block;
/**
characteristic订阅状态改变的block
| when characteristic notification state changed
*/
- (void)setBlockOnDidUpdateNotificationStateForCharacteristicAtChannel:(NSString *)channel
block:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
/**
读取RSSI的委托
| when did read RSSI
*/
- (void)setBlockOnDidReadRSSIAtChannel:(NSString *)channel
block:(void (^)(NSNumber *RSSI,NSError *error))block;
/**
discoverIncludedServices的回调,暂时在babybluetooth中无作用
| no used in babybluetooth
*/
- (void)setBlockOnDidDiscoverIncludedServicesForServiceAtChannel:(NSString *)channel
block:(void (^)(CBService *service,NSError *error))block;
/**
外设更新名字后的block
| when peripheral update name
*/
- (void)setBlockOnDidUpdateNameAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral))block;
/**
外设更新服务后的block
| when peripheral update services
*/
- (void)setBlockOnDidModifyServicesAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block;
#pragma mark - babybluetooth filter
/**
设置查找Peripherals的规则
| filter of discover peripherals
*/
- (void)setFilterOnDiscoverPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
/**
设置连接Peripherals的规则
| setting filter of connect to peripherals peripherals
*/
- (void)setFilterOnConnectToPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
/**
设置查找Peripherals的规则
| filter of discover peripherals
*/
- (void)setFilterOnDiscoverPeripheralsAtChannel:(NSString *)channel
filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
/**
设置连接Peripherals的规则
| setting filter of connect to peripherals peripherals
*/
- (void)setFilterOnConnectToPeripheralsAtChannel:(NSString *)channel
filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
#pragma mark - babybluetooth Special
/**
babyBluettooth cancelScan方法调用后的回调
| when after call cancelScan
*/
- (void)setBlockOnCancelScanBlock:(void(^)(CBCentralManager *centralManager))block;
/**
babyBluettooth cancelAllPeripheralsConnectionBlock 方法执行后并且全部设备断开后的回调
| when did all peripheral disConnect
*/
- (void)setBlockOnCancelAllPeripheralsConnectionBlock:(void(^)(CBCentralManager *centralManager))block;
/**
babyBluettooth cancelScan方法调用后的回调
| when after call cancelScan
*/
- (void)setBlockOnCancelScanBlockAtChannel:(NSString *)channel
block:(void(^)(CBCentralManager *centralManager))block;
/**
babyBluettooth cancelAllPeripheralsConnectionBlock 方法执行后并且全部设备断开后的回调
| when did all peripheral disConnect
*/
- (void)setBlockOnCancelAllPeripheralsConnectionBlockAtChannel:(NSString *)channel
block:(void(^)(CBCentralManager *centralManager))block;
/**
设置蓝牙运行时的参数
| set ble runtime parameters
*/
- (void)setBabyOptionsWithScanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
discoverWithServices:(NSArray *)discoverWithServices
discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;
/**
设置蓝牙运行时的参数
| set ble runtime parameters
*/
- (void)setBabyOptionsAtChannel:(NSString *)channel
scanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
discoverWithServices:(NSArray *)discoverWithServices
discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;
#pragma mark - 链式函数
/**
查找Peripherals
*/
- (BabyBluetooth *(^)()) scanForPeripherals;
/**
连接Peripherals
*/
- (BabyBluetooth *(^)()) connectToPeripherals;
/**
发现Services
*/
- (BabyBluetooth *(^)()) discoverServices;
/**
获取Characteristics
*/
- (BabyBluetooth *(^)()) discoverCharacteristics;
/**
更新Characteristics的值
*/
- (BabyBluetooth *(^)()) readValueForCharacteristic;
/**
获取Characteristics的名称
*/
- (BabyBluetooth *(^)()) discoverDescriptorsForCharacteristic;
/**
获取Descriptors的值
*/
- (BabyBluetooth *(^)()) readValueForDescriptors;
/**
开始执行
*/
- (BabyBluetooth *(^)()) begin;
/**
sec秒后停止
*/
- (BabyBluetooth *(^)(int sec)) stop;
/**
持有对象
*/
- (BabyBluetooth *(^)(id obj)) having;
/**
切换委托的频道
*/
- (BabyBluetooth *(^)(NSString *channel)) channel;
/**
谓词,返回self
*/
- (BabyBluetooth *) and;
/**
谓词,返回self
*/
- (BabyBluetooth *) then;
/**
谓词,返回self
*/
- (BabyBluetooth *) with;
/**
* enjoy 祝你使用愉快,
*
* 说明:enjoy是蓝牙全套串行方法的简写(发现服务,发现特征,读取特征,读取特征描述),前面可以必须有scanForPeripherals或having方法,channel可以选择添加。
enjoy() 等同于 connectToPeripherals().discoverServices().discoverCharacteristics().readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin();
它可以让你少敲很多代码
## 例子:
- 扫描后来个全套(发现服务,发现特征,读取特征,读取特征描述)
` baby.scanForPeripherals().connectToPeripherals().discoverServices().discoverCharacteristics()
.readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin();
`
- 直接使用已有的外设连接后全套(发现服务,发现特征,读取特征,读取特征描述)
` baby.having(self.peripheral).connectToPeripherals().discoverServices().discoverCharacteristics()
.readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin();
`
enjoy后面也可以加stop()方法
*/
- (BabyBluetooth *(^)()) enjoy;
#pragma mark - 工具方法
/**
* 单例构造方法
* @return BabyBluetooth共享实例
*/
+ (instancetype)shareBabyBluetooth;
/**
断开连接
*/
- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral;
/**
断开所有连接
*/
- (void)cancelAllPeripheralsConnection;
/**
停止扫描
*/
- (void)cancelScan;
/**
更新Characteristics的值
*/
- (BabyBluetooth *(^)(CBPeripheral *peripheral,CBCharacteristic *characteristic)) characteristicDetails;
/**
设置characteristic的notify
*/
- (void)notify:(CBPeripheral *)peripheral
characteristic:(CBCharacteristic *)characteristic
block:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block;
/**
取消characteristic的notify
*/
- (void)cancelNotify:(CBPeripheral *)peripheral
characteristic:(CBCharacteristic *)characteristic;
/**
获取当前连接的peripherals
*/
- (NSArray *)findConnectedPeripherals;
/**
获取当前连接的peripheral
*/
- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName;
/**
获取当前corebluetooth的centralManager对象
*/
- (CBCentralManager *)centralManager;
/**
添加断开自动重连的外设
*/
- (void)AutoReconnect:(CBPeripheral *)peripheral;
/**
删除断开自动重连的外设
*/
- (void)AutoReconnectCancel:(CBPeripheral *)peripheral;
/**
根据外设UUID对应的string获取已配对的外设
通过方法获取外设后可以直接连接外设,跳过扫描过程
*/
- (CBPeripheral *)retrievePeripheralWithUUIDString:(NSString *)UUIDString;
#pragma mark - peripheral model
//进入外设模式
- (BabyPeripheralManager *(^)()) bePeripheral;
- (BabyPeripheralManager *(^)(NSString *localName)) bePeripheralWithName;
@property (nonatomic, readonly) CBPeripheralManager *peripheralManager;
//peripheral model block
/**
PeripheralManager did update state block
*/
- (void)peripheralModelBlockOnPeripheralManagerDidUpdateState:(void(^)(CBPeripheralManager *peripheral))block;
/**
PeripheralManager did add service block
*/
- (void)peripheralModelBlockOnDidAddService:(void(^)(CBPeripheralManager *peripheral,CBService *service,NSError *error))block;
/**
PeripheralManager did start advertising block
*/
- (void)peripheralModelBlockOnDidStartAdvertising:(void(^)(CBPeripheralManager *peripheral,NSError *error))block;
/**
peripheralManager did receive read request block
*/
- (void)peripheralModelBlockOnDidReceiveReadRequest:(void(^)(CBPeripheralManager *peripheral,CBATTRequest *request))block;
/**
peripheralManager did receive write request block
*/
- (void)peripheralModelBlockOnDidReceiveWriteRequests:(void(^)(CBPeripheralManager *peripheral,NSArray *requests))block;
/**
peripheralManager did subscribe to characteristic block
*/
- (void)peripheralModelBlockOnDidSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block;
/**
peripheralManager did subscribe to characteristic block
*/
- (void)peripheralModelBlockOnDidUnSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block;
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
*/
// Created by 刘彦玮 on 15/3/31.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
#import "BabyBluetooth.h"
@implementation BabyBluetooth{
BabyCentralManager *babyCentralManager;
BabyPeripheralManager *babyPeripheralManager;
BabySpeaker *babySpeaker;
int CENTRAL_MANAGER_INIT_WAIT_TIMES;
NSTimer *timerForStop;
}
//单例模式
+ (instancetype)shareBabyBluetooth {
static BabyBluetooth *share = nil;
static dispatch_once_t oneToken;
dispatch_once(&oneToken, ^{
share = [[BabyBluetooth alloc]init];
});
return share;
}
- (instancetype)init {
self = [super init];
if (self) {
//初始化对象
babyCentralManager = [[BabyCentralManager alloc]init];
babySpeaker = [[BabySpeaker alloc]init];
babyCentralManager->babySpeaker = babySpeaker;
babyPeripheralManager = [[BabyPeripheralManager alloc]init];
babyPeripheralManager->babySpeaker = babySpeaker;
}
return self;
}
#pragma mark - babybluetooth的委托
/*
默认频道的委托
*/
//设备状态改变的委托
- (void)setBlockOnCentralManagerDidUpdateState:(void (^)(CBCentralManager *central))block {
[[babySpeaker callback]setBlockOnCentralManagerDidUpdateState:block];
}
//找到Peripherals的委托
- (void)setBlockOnDiscoverToPeripherals:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI))block{
[[babySpeaker callback]setBlockOnDiscoverPeripherals:block];
}
//连接Peripherals成功的委托
- (void)setBlockOnConnected:(void (^)(CBCentralManager *central,CBPeripheral *peripheral))block {
[[babySpeaker callback]setBlockOnConnectedPeripheral:block];
}
//连接Peripherals失败的委托
- (void)setBlockOnFailToConnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block {
[[babySpeaker callback]setBlockOnFailToConnect:block];
}
//断开Peripherals的连接
- (void)setBlockOnDisconnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block {
[[babySpeaker callback]setBlockOnDisconnect:block];
}
//设置查找服务回叫
- (void)setBlockOnDiscoverServices:(void (^)(CBPeripheral *peripheral,NSError *error))block {
[[babySpeaker callback]setBlockOnDiscoverServices:block];
}
//设置查找到Characteristics的block
- (void)setBlockOnDiscoverCharacteristics:(void (^)(CBPeripheral *peripheral,CBService *service,NSError *error))block {
[[babySpeaker callback]setBlockOnDiscoverCharacteristics:block];
}
//设置获取到最新Characteristics值的block
- (void)setBlockOnReadValueForCharacteristic:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block {
[[babySpeaker callback]setBlockOnReadValueForCharacteristic:block];
}
//设置查找到Characteristics描述的block
- (void)setBlockOnDiscoverDescriptorsForCharacteristic:(void (^)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error))block {
[[babySpeaker callback]setBlockOnDiscoverDescriptorsForCharacteristic:block];
}
//设置读取到Characteristics描述的值的block
- (void)setBlockOnReadValueForDescriptors:(void (^)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error))block {
[[babySpeaker callback]setBlockOnReadValueForDescriptors:block];
}
//写Characteristic成功后的block
- (void)setBlockOnDidWriteValueForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block {
[[babySpeaker callback]setBlockOnDidWriteValueForCharacteristic:block];
}
//写descriptor成功后的block
- (void)setBlockOnDidWriteValueForDescriptor:(void (^)(CBDescriptor *descriptor,NSError *error))block {
[[babySpeaker callback]setBlockOnDidWriteValueForDescriptor:block];
}
//characteristic订阅状态改变的block
- (void)setBlockOnDidUpdateNotificationStateForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block {
[[babySpeaker callback]setBlockOnDidUpdateNotificationStateForCharacteristic:block];
}
//读取RSSI的委托
- (void)setBlockOnDidReadRSSI:(void (^)(NSNumber *RSSI,NSError *error))block {
[[babySpeaker callback]setBlockOnDidReadRSSI:block];
}
//discoverIncludedServices的回调,暂时在babybluetooth中无作用
- (void)setBlockOnDidDiscoverIncludedServicesForService:(void (^)(CBService *service,NSError *error))block {
[[babySpeaker callback]setBlockOnDidDiscoverIncludedServicesForService:block];
}
//外设更新名字后的block
- (void)setBlockOnDidUpdateName:(void (^)(CBPeripheral *peripheral))block {
[[babySpeaker callback]setBlockOnDidUpdateName:block];
}
//外设更新服务后的block
- (void)setBlockOnDidModifyServices:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block {
[[babySpeaker callback]setBlockOnDidModifyServices:block];
}
//设置蓝牙使用的参数参数
- (void)setBabyOptionsWithScanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
discoverWithServices:(NSArray *)discoverWithServices
discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics {
BabyOptions *option = [[BabyOptions alloc]initWithscanForPeripheralsWithOptions:scanForPeripheralsWithOptions connectPeripheralWithOptions:connectPeripheralWithOptions scanForPeripheralsWithServices:scanForPeripheralsWithServices discoverWithServices:discoverWithServices discoverWithCharacteristics:discoverWithCharacteristics];
[[babySpeaker callback]setBabyOptions:option];
}
/*
channel的委托
*/
//设备状态改变的委托
- (void)setBlockOnCentralManagerDidUpdateStateAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnCentralManagerDidUpdateState:block];
}
//找到Peripherals的委托
- (void)setBlockOnDiscoverToPeripheralsAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDiscoverPeripherals:block];
}
//连接Peripherals成功的委托
- (void)setBlockOnConnectedAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnConnectedPeripheral:block];
}
//连接Peripherals失败的委托
- (void)setBlockOnFailToConnectAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnFailToConnect:block];
}
//断开Peripherals的连接
- (void)setBlockOnDisconnectAtChannel:(NSString *)channel
block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDisconnect:block];
}
//设置查找服务回叫
- (void)setBlockOnDiscoverServicesAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDiscoverServices:block];
}
//设置查找到Characteristics的block
- (void)setBlockOnDiscoverCharacteristicsAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,CBService *service,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDiscoverCharacteristics:block];
}
//设置获取到最新Characteristics值的block
- (void)setBlockOnReadValueForCharacteristicAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnReadValueForCharacteristic:block];
}
//设置查找到Characteristics描述的block
- (void)setBlockOnDiscoverDescriptorsForCharacteristicAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDiscoverDescriptorsForCharacteristic:block];
}
//设置读取到Characteristics描述的值的block
- (void)setBlockOnReadValueForDescriptorsAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnReadValueForDescriptors:block];
}
//写Characteristic成功后的block
- (void)setBlockOnDidWriteValueForCharacteristicAtChannel:(NSString *)channel
block:(void (^)(CBCharacteristic *characteristic,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidWriteValueForCharacteristic:block];
}
//写descriptor成功后的block
- (void)setBlockOnDidWriteValueForDescriptorAtChannel:(NSString *)channel
block:(void (^)(CBDescriptor *descriptor,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidWriteValueForDescriptor:block];
}
//characteristic订阅状态改变的block
- (void)setBlockOnDidUpdateNotificationStateForCharacteristicAtChannel:(NSString *)channel
block:(void (^)(CBCharacteristic *characteristic,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidUpdateNotificationStateForCharacteristic:block];
}
//读取RSSI的委托
- (void)setBlockOnDidReadRSSIAtChannel:(NSString *)channel
block:(void (^)(NSNumber *RSSI,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidReadRSSI:block];
}
//discoverIncludedServices的回调,暂时在babybluetooth中无作用
- (void)setBlockOnDidDiscoverIncludedServicesForServiceAtChannel:(NSString *)channel
block:(void (^)(CBService *service,NSError *error))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidDiscoverIncludedServicesForService:block];
}
//外设更新名字后的block
- (void)setBlockOnDidUpdateNameAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidUpdateName:block];
}
//外设更新服务后的block
- (void)setBlockOnDidModifyServicesAtChannel:(NSString *)channel
block:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidModifyServices:block];
}
//设置蓝牙运行时的参数
- (void)setBabyOptionsAtChannel:(NSString *)channel
scanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
discoverWithServices:(NSArray *)discoverWithServices
discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics {
BabyOptions *option = [[BabyOptions alloc]initWithscanForPeripheralsWithOptions:scanForPeripheralsWithOptions connectPeripheralWithOptions:connectPeripheralWithOptions scanForPeripheralsWithServices:scanForPeripheralsWithServices discoverWithServices:discoverWithServices discoverWithCharacteristics:discoverWithCharacteristics];
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBabyOptions:option];
}
#pragma mark - babybluetooth filter委托
//设置查找Peripherals的规则
- (void)setFilterOnDiscoverPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter {
[[babySpeaker callback]setFilterOnDiscoverPeripherals:filter];
}
//设置连接Peripherals的规则
- (void)setFilterOnConnectToPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter {
[[babySpeaker callback]setFilterOnconnectToPeripherals:filter];
}
//设置查找Peripherals的规则
- (void)setFilterOnDiscoverPeripheralsAtChannel:(NSString *)channel
filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setFilterOnDiscoverPeripherals:filter];
}
//设置连接Peripherals的规则
- (void)setFilterOnConnectToPeripheralsAtChannel:(NSString *)channel
filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setFilterOnconnectToPeripherals:filter];
}
#pragma mark - babybluetooth Special
//babyBluettooth cancelScan方法调用后的回调
- (void)setBlockOnCancelScanBlock:(void(^)(CBCentralManager *centralManager))block {
[[babySpeaker callback]setBlockOnCancelScan:block];
}
//babyBluettooth cancelAllPeripheralsConnectionBlock 方法调用后的回调
- (void)setBlockOnCancelAllPeripheralsConnectionBlock:(void(^)(CBCentralManager *centralManager))block{
[[babySpeaker callback]setBlockOnCancelAllPeripheralsConnection:block];
}
//babyBluettooth cancelScan方法调用后的回调
- (void)setBlockOnCancelScanBlockAtChannel:(NSString *)channel
block:(void(^)(CBCentralManager *centralManager))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnCancelScan:block];
}
//babyBluettooth cancelAllPeripheralsConnectionBlock 方法调用后的回调
- (void)setBlockOnCancelAllPeripheralsConnectionBlockAtChannel:(NSString *)channel
block:(void(^)(CBCentralManager *centralManager))block {
[[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnCancelAllPeripheralsConnection:block];
}
#pragma mark - 链式函数
//查找Peripherals
- (BabyBluetooth *(^)()) scanForPeripherals {
return ^BabyBluetooth *() {
[babyCentralManager->pocket setObject:@"YES" forKey:@"needScanForPeripherals"];
return self;
};
}
//连接Peripherals
- (BabyBluetooth *(^)()) connectToPeripherals {
return ^BabyBluetooth *() {
[babyCentralManager->pocket setObject:@"YES" forKey:@"needConnectPeripheral"];
return self;
};
}
//发现Services
- (BabyBluetooth *(^)()) discoverServices {
return ^BabyBluetooth *() {
[babyCentralManager->pocket setObject:@"YES" forKey:@"needDiscoverServices"];
return self;
};
}
//获取Characteristics
- (BabyBluetooth *(^)()) discoverCharacteristics {
return ^BabyBluetooth *() {
[babyCentralManager->pocket setObject:@"YES" forKey:@"needDiscoverCharacteristics"];
return self;
};
}
//更新Characteristics的值
- (BabyBluetooth *(^)()) readValueForCharacteristic {
return ^BabyBluetooth *() {
[babyCentralManager->pocket setObject:@"YES" forKey:@"needReadValueForCharacteristic"];
return self;
};
}
//设置查找到Descriptors名称的block
- (BabyBluetooth *(^)()) discoverDescriptorsForCharacteristic {
return ^BabyBluetooth *() {
[babyCentralManager->pocket setObject:@"YES" forKey:@"needDiscoverDescriptorsForCharacteristic"];
return self;
};
}
//设置读取到Descriptors值的block
- (BabyBluetooth *(^)()) readValueForDescriptors {
return ^BabyBluetooth *() {
[babyCentralManager->pocket setObject:@"YES" forKey:@"needReadValueForDescriptors"];
return self;
};
}
//开始并执行
- (BabyBluetooth *(^)()) begin {
return ^BabyBluetooth *() {
//取消未执行的stop定时任务
[timerForStop invalidate];
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self resetSeriseParmeter];
//处理链式函数缓存的数据
if ([[babyCentralManager->pocket valueForKey:@"needScanForPeripherals"] isEqualToString:@"YES"]) {
babyCentralManager->needScanForPeripherals = YES;
}
if ([[babyCentralManager->pocket valueForKey:@"needConnectPeripheral"] isEqualToString:@"YES"]) {
babyCentralManager->needConnectPeripheral = YES;
}
if ([[babyCentralManager->pocket valueForKey:@"needDiscoverServices"] isEqualToString:@"YES"]) {
babyCentralManager->needDiscoverServices = YES;
}
if ([[babyCentralManager->pocket valueForKey:@"needDiscoverCharacteristics"] isEqualToString:@"YES"]) {
babyCentralManager->needDiscoverCharacteristics = YES;
}
if ([[babyCentralManager->pocket valueForKey:@"needReadValueForCharacteristic"] isEqualToString:@"YES"]) {
babyCentralManager->needReadValueForCharacteristic = YES;
}
if ([[babyCentralManager->pocket valueForKey:@"needDiscoverDescriptorsForCharacteristic"] isEqualToString:@"YES"]) {
babyCentralManager->needDiscoverDescriptorsForCharacteristic = YES;
}
if ([[babyCentralManager->pocket valueForKey:@"needReadValueForDescriptors"] isEqualToString:@"YES"]) {
babyCentralManager->needReadValueForDescriptors = YES;
}
//调整委托方法的channel,如果没设置默认为缺省频道
NSString *channel = [babyCentralManager->pocket valueForKey:@"channel"];
[babySpeaker switchChannel:channel];
//缓存的peripheral
CBPeripheral *cachedPeripheral = [babyCentralManager->pocket valueForKey:NSStringFromClass([CBPeripheral class])];
//校验series合法性
[self validateProcess];
//清空pocjet
babyCentralManager->pocket = [[NSMutableDictionary alloc]init];
//开始扫描或连接设备
[self start:cachedPeripheral];
});
return self;
};
}
//私有方法,扫描或连接设备
- (void)start:(CBPeripheral *)cachedPeripheral {
if (babyCentralManager->centralManager.state == CBCentralManagerStatePoweredOn) {
CENTRAL_MANAGER_INIT_WAIT_TIMES = 0;
//扫描后连接
if (babyCentralManager->needScanForPeripherals) {
//开始扫描peripherals
[babyCentralManager scanPeripherals];
}
//直接连接
else {
if (cachedPeripheral) {
[babyCentralManager connectToPeripheral:cachedPeripheral];
}
}
return;
}
//尝试重新等待CBCentralManager打开
CENTRAL_MANAGER_INIT_WAIT_TIMES ++;
if (CENTRAL_MANAGER_INIT_WAIT_TIMES >= KBABY_CENTRAL_MANAGER_INIT_WAIT_TIMES ) {
BabyLog(@">>> 第%d次等待CBCentralManager 打开任然失败,请检查你蓝牙使用权限或检查设备问题。",CENTRAL_MANAGER_INIT_WAIT_TIMES);
return;
//[NSException raise:@"CBCentralManager打开异常" format:@"尝试等待打开CBCentralManager5次,但任未能打开"];
}
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, KBABY_CENTRAL_MANAGER_INIT_WAIT_SECOND * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self start:cachedPeripheral];
});
BabyLog(@">>> 第%d次等待CBCentralManager打开",CENTRAL_MANAGER_INIT_WAIT_TIMES);
}
//sec秒后停止
- (BabyBluetooth *(^)(int sec)) stop {
return ^BabyBluetooth *(int sec) {
BabyLog(@">>> stop in %d sec",sec);
//听见定时器执行babyStop
timerForStop = [NSTimer timerWithTimeInterval:sec target:self selector:@selector(babyStop) userInfo:nil repeats:NO];
[timerForStop setFireDate: [[NSDate date]dateByAddingTimeInterval:sec]];
[[NSRunLoop currentRunLoop] addTimer:timerForStop forMode:NSRunLoopCommonModes];
return self;
};
}
//私有方法,停止扫描和断开连接,清空pocket
- (void)babyStop {
BabyLog(@">>>did stop");
[timerForStop invalidate];
[self resetSeriseParmeter];
babyCentralManager->pocket = [[NSMutableDictionary alloc]init];
//停止扫描,断开连接
[babyCentralManager cancelScan];
[babyCentralManager cancelAllPeripheralsConnection];
}
//重置串行方法参数
- (void)resetSeriseParmeter {
babyCentralManager->needScanForPeripherals = NO;
babyCentralManager->needConnectPeripheral = NO;
babyCentralManager->needDiscoverServices = NO;
babyCentralManager->needDiscoverCharacteristics = NO;
babyCentralManager->needReadValueForCharacteristic = NO;
babyCentralManager->needDiscoverDescriptorsForCharacteristic = NO;
babyCentralManager->needReadValueForDescriptors = NO;
}
//持有对象
- (BabyBluetooth *(^)(id obj)) having {
return ^(id obj) {
[babyCentralManager->pocket setObject:obj forKey:NSStringFromClass([obj class])];
return self;
};
}
//切换委托频道
- (BabyBluetooth *(^)(NSString *channel)) channel {
return ^BabyBluetooth *(NSString *channel) {
//先缓存数据,到begin方法统一处理
[babyCentralManager->pocket setValue:channel forKey:@"channel"];
return self;
};
}
- (void)validateProcess {
NSMutableArray *faildReason = [[NSMutableArray alloc]init];
//规则:不执行discoverDescriptorsForCharacteristic()时,不能执行readValueForDescriptors()
if (!babyCentralManager->needDiscoverDescriptorsForCharacteristic) {
if (babyCentralManager->needReadValueForDescriptors) {
[faildReason addObject:@"未执行discoverDescriptorsForCharacteristic()不能执行readValueForDescriptors()"];
}
}
//规则:不执行discoverCharacteristics()时,不能执行readValueForCharacteristic()或者是discoverDescriptorsForCharacteristic()
if (!babyCentralManager->needDiscoverCharacteristics) {
if (babyCentralManager->needReadValueForCharacteristic||babyCentralManager->needDiscoverDescriptorsForCharacteristic) {
[faildReason addObject:@"未执行discoverCharacteristics()不能执行readValueForCharacteristic()或discoverDescriptorsForCharacteristic()"];
}
}
//规则: 不执行discoverServices()不能执行discoverCharacteristics()、readValueForCharacteristic()、discoverDescriptorsForCharacteristic()、readValueForDescriptors()
if (!babyCentralManager->needDiscoverServices) {
if (babyCentralManager->needDiscoverCharacteristics||babyCentralManager->needDiscoverDescriptorsForCharacteristic ||babyCentralManager->needReadValueForCharacteristic ||babyCentralManager->needReadValueForDescriptors) {
[faildReason addObject:@"未执行discoverServices()不能执行discoverCharacteristics()、readValueForCharacteristic()、discoverDescriptorsForCharacteristic()、readValueForDescriptors()"];
}
}
//规则:不执行connectToPeripherals()时,不能执行discoverServices()
if(!babyCentralManager->needConnectPeripheral) {
if (babyCentralManager->needDiscoverServices) {
[faildReason addObject:@"未执行connectToPeripherals()不能执行discoverServices()"];
}
}
//规则:不执行needScanForPeripherals(),那么执行connectToPeripheral()方法时必须用having(peripheral)传入peripheral实例
if (!babyCentralManager->needScanForPeripherals) {
CBPeripheral *peripheral = [babyCentralManager->pocket valueForKey:NSStringFromClass([CBPeripheral class])];
if (!peripheral) {
[faildReason addObject:@"若不执行scanForPeripherals()方法,则必须执行connectToPeripheral方法并且需要传入参数(CBPeripheral *)peripheral"];
}
}
//抛出异常
if ([faildReason lastObject]) {
NSException *e = [NSException exceptionWithName:@"BadyBluetooth usage exception" reason:[faildReason lastObject] userInfo:nil];
@throw e;
}
}
- (BabyBluetooth *) and {
return self;
}
- (BabyBluetooth *) then {
return self;
}
- (BabyBluetooth *) with {
return self;
}
- (BabyBluetooth *(^)()) enjoy {
return ^BabyBluetooth *(int sec) {
self.connectToPeripherals().discoverServices().discoverCharacteristics()
.readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin();
return self;
};
}
#pragma mark - 工具方法
//断开连接
- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral {
[babyCentralManager cancelPeripheralConnection:peripheral];
}
//断开所有连接
- (void)cancelAllPeripheralsConnection {
[babyCentralManager cancelAllPeripheralsConnection];
}
//停止扫描
- (void)cancelScan{
[babyCentralManager cancelScan];
}
//读取Characteristic的详细信息
- (BabyBluetooth *(^)(CBPeripheral *peripheral,CBCharacteristic *characteristic)) characteristicDetails {
//切换频道
[babySpeaker switchChannel:[babyCentralManager->pocket valueForKey:@"channel"]];
babyCentralManager->pocket = [[NSMutableDictionary alloc]init];
return ^(CBPeripheral *peripheral,CBCharacteristic *characteristic) {
//判断连接状态
if (peripheral.state == CBPeripheralStateConnected) {
self->babyCentralManager->oneReadValueForDescriptors = YES;
[peripheral readValueForCharacteristic:characteristic];
[peripheral discoverDescriptorsForCharacteristic:characteristic];
}
else {
BabyLog(@"!!!设备当前处于非连接状态");
}
return self;
};
}
- (void)notify:(CBPeripheral *)peripheral
characteristic:(CBCharacteristic *)characteristic
block:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block {
//设置通知
[peripheral setNotifyValue:YES forCharacteristic:characteristic];
[babySpeaker addNotifyCallback:characteristic withBlock:block];
}
- (void)cancelNotify:(CBPeripheral *)peripheral
characteristic:(CBCharacteristic *)characteristic {
[peripheral setNotifyValue:NO forCharacteristic:characteristic];
[babySpeaker removeNotifyCallback:characteristic];
}
//获取当前连接的peripherals
- (NSArray *)findConnectedPeripherals {
return [babyCentralManager findConnectedPeripherals];
}
//获取当前连接的peripheral
- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName {
return [babyCentralManager findConnectedPeripheral:peripheralName];
}
//获取当前corebluetooth的centralManager对象
- (CBCentralManager *)centralManager {
return babyCentralManager->centralManager;
}
/**
添加断开自动重连的外设
*/
- (void)AutoReconnect:(CBPeripheral *)peripheral{
[babyCentralManager sometimes_ever:peripheral];
}
/**
删除断开自动重连的外设
*/
- (void)AutoReconnectCancel:(CBPeripheral *)peripheral{
[babyCentralManager sometimes_never:peripheral];
}
- (CBPeripheral *)retrievePeripheralWithUUIDString:(NSString *)UUIDString {
CBPeripheral *p = nil;
@try {
NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:UUIDString];
p = [self.centralManager retrievePeripheralsWithIdentifiers:@[uuid]][0];
} @catch (NSException *exception) {
BabyLog(@">>> retrievePeripheralWithUUIDString error:%@",exception)
} @finally {
}
return p;
}
#pragma mark - peripheral model
//进入外设模式
- (CBPeripheralManager *)peripheralManager {
return babyPeripheralManager.peripheralManager;
}
- (BabyPeripheralManager *(^)()) bePeripheral {
return ^BabyPeripheralManager* () {
return babyPeripheralManager;
};
}
- (BabyPeripheralManager *(^)(NSString *localName)) bePeripheralWithName {
return ^BabyPeripheralManager* (NSString *localName) {
babyPeripheralManager.localName = localName;
return babyPeripheralManager;
};
}
- (void)peripheralModelBlockOnPeripheralManagerDidUpdateState:(void(^)(CBPeripheralManager *peripheral))block {
[[babySpeaker callback]setBlockOnPeripheralModelDidUpdateState:block];
}
- (void)peripheralModelBlockOnDidAddService:(void(^)(CBPeripheralManager *peripheral,CBService *service,NSError *error))block {
[[babySpeaker callback]setBlockOnPeripheralModelDidAddService:block];
}
- (void)peripheralModelBlockOnDidStartAdvertising:(void(^)(CBPeripheralManager *peripheral,NSError *error))block {
[[babySpeaker callback]setBlockOnPeripheralModelDidStartAdvertising:block];
}
- (void)peripheralModelBlockOnDidReceiveReadRequest:(void(^)(CBPeripheralManager *peripheral,CBATTRequest *request))block {
[[babySpeaker callback]setBlockOnPeripheralModelDidReceiveReadRequest:block];
}
- (void)peripheralModelBlockOnDidReceiveWriteRequests:(void(^)(CBPeripheralManager *peripheral,NSArray *requests))block {
[[babySpeaker callback]setBlockOnPeripheralModelDidReceiveWriteRequests:block];
}
- (void)peripheralModelBlockOnDidSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block {
[[babySpeaker callback]setBlockOnPeripheralModelDidSubscribeToCharacteristic:block];
}
- (void)peripheralModelBlockOnDidUnSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block {
[[babySpeaker callback]setBlockOnPeripheralModelDidUnSubscribeToCharacteristic:block];
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth 的block定义和储存
*/
// Created by 刘彦玮 on 15/9/2.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import <CoreBluetooth/CoreBluetooth.h>
#import "BabyOptions.h"
//设备状态改变的委托
typedef void (^BBCentralManagerDidUpdateStateBlock)(CBCentralManager *central);
//找到设备的委托
typedef void (^BBDiscoverPeripheralsBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI);
//连接设备成功的block
typedef void (^BBConnectedPeripheralBlock)(CBCentralManager *central,CBPeripheral *peripheral);
//连接设备失败的block
typedef void (^BBFailToConnectBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error);
//断开设备连接的bock
typedef void (^BBDisconnectBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error);
//找到服务的block
typedef void (^BBDiscoverServicesBlock)(CBPeripheral *peripheral,NSError *error);
//找到Characteristics的block
typedef void (^BBDiscoverCharacteristicsBlock)(CBPeripheral *peripheral,CBService *service,NSError *error);
//更新(获取)Characteristics的value的block
typedef void (^BBReadValueForCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error);
//获取Characteristics的名称
typedef void (^BBDiscoverDescriptorsForCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error);
//获取Descriptors的值
typedef void (^BBReadValueForDescriptorsBlock)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error);
//babyBluettooth cancelScanBlock方法调用后的回调
typedef void (^BBCancelScanBlock)(CBCentralManager *centralManager);
//babyBluettooth cancelAllPeripheralsConnection 方法调用后的回调
typedef void (^BBCancelAllPeripheralsConnectionBlock)(CBCentralManager *centralManager);
typedef void (^BBDidWriteValueForCharacteristicBlock)(CBCharacteristic *characteristic,NSError *error);
typedef void (^BBDidWriteValueForDescriptorBlock)(CBDescriptor *descriptor,NSError *error);
typedef void (^BBDidUpdateNotificationStateForCharacteristicBlock)(CBCharacteristic *characteristic,NSError *error);
typedef void (^BBDidReadRSSIBlock)(NSNumber *RSSI,NSError *error);
typedef void (^BBDidDiscoverIncludedServicesForServiceBlock)(CBService *service,NSError *error);
typedef void (^BBDidUpdateNameBlock)(CBPeripheral *peripheral);
typedef void (^BBDidModifyServicesBlock)(CBPeripheral *peripheral,NSArray *invalidatedServices);
//peripheral model
typedef void (^BBPeripheralModelDidUpdateState)(CBPeripheralManager *peripheral);
typedef void (^BBPeripheralModelDidAddService)(CBPeripheralManager *peripheral,CBService *service,NSError *error);
typedef void (^BBPeripheralModelDidStartAdvertising)(CBPeripheralManager *peripheral,NSError *error);
typedef void (^BBPeripheralModelDidReceiveReadRequest)(CBPeripheralManager *peripheral,CBATTRequest *request);
typedef void (^BBPeripheralModelDidReceiveWriteRequests)(CBPeripheralManager *peripheral,NSArray *requests);
typedef void (^BBPeripheralModelDidSubscribeToCharacteristic)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic);
typedef void (^BBPeripheralModelDidUnSubscribeToCharacteristic)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic);
@interface BabyCallback : NSObject
#pragma mark - callback block
//设备状态改变的委托
@property (nonatomic, copy) BBCentralManagerDidUpdateStateBlock blockOnCentralManagerDidUpdateState;
//发现peripherals
@property (nonatomic, copy) BBDiscoverPeripheralsBlock blockOnDiscoverPeripherals;
//连接callback
@property (nonatomic, copy) BBConnectedPeripheralBlock blockOnConnectedPeripheral;
//连接设备失败的block
@property (nonatomic, copy) BBFailToConnectBlock blockOnFailToConnect;
//断开设备连接的bock
@property (nonatomic, copy) BBDisconnectBlock blockOnDisconnect;
//发现services
@property (nonatomic, copy) BBDiscoverServicesBlock blockOnDiscoverServices;
//发现Characteristics
@property (nonatomic, copy) BBDiscoverCharacteristicsBlock blockOnDiscoverCharacteristics;
//发现更新Characteristics的
@property (nonatomic, copy) BBReadValueForCharacteristicBlock blockOnReadValueForCharacteristic;
//获取Characteristics的名称
@property (nonatomic, copy) BBDiscoverDescriptorsForCharacteristicBlock blockOnDiscoverDescriptorsForCharacteristic;
//获取Descriptors的值
@property (nonatomic,copy) BBReadValueForDescriptorsBlock blockOnReadValueForDescriptors;
@property (nonatomic, copy) BBDidWriteValueForCharacteristicBlock blockOnDidWriteValueForCharacteristic;
@property (nonatomic, copy) BBDidWriteValueForDescriptorBlock blockOnDidWriteValueForDescriptor;
@property (nonatomic, copy) BBDidUpdateNotificationStateForCharacteristicBlock blockOnDidUpdateNotificationStateForCharacteristic;
@property (nonatomic, copy) BBDidReadRSSIBlock blockOnDidReadRSSI;
@property (nonatomic, copy) BBDidDiscoverIncludedServicesForServiceBlock blockOnDidDiscoverIncludedServicesForService;
@property (nonatomic, copy) BBDidUpdateNameBlock blockOnDidUpdateName;
@property (nonatomic, copy) BBDidModifyServicesBlock blockOnDidModifyServices;
//babyBluettooth stopScan方法调用后的回调
@property(nonatomic,copy) BBCancelScanBlock blockOnCancelScan;
//babyBluettooth stopConnectAllPerihperals 方法调用后的回调
@property(nonatomic,copy) BBCancelAllPeripheralsConnectionBlock blockOnCancelAllPeripheralsConnection;
//babyBluettooth 蓝牙使用的参数参数
@property(nonatomic,strong) BabyOptions *babyOptions;
#pragma mark - 过滤器Filter
//发现peripherals规则
@property (nonatomic, copy) BOOL (^filterOnDiscoverPeripherals)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI);
//连接peripherals规则
@property (nonatomic, copy) BOOL (^filterOnconnectToPeripherals)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI);
#pragma mark - peripheral model
//peripheral model
@property (nonatomic, copy) BBPeripheralModelDidUpdateState blockOnPeripheralModelDidUpdateState;
@property (nonatomic, copy) BBPeripheralModelDidAddService blockOnPeripheralModelDidAddService;
@property (nonatomic, copy) BBPeripheralModelDidStartAdvertising blockOnPeripheralModelDidStartAdvertising;
@property (nonatomic, copy) BBPeripheralModelDidReceiveReadRequest blockOnPeripheralModelDidReceiveReadRequest;
@property (nonatomic, copy) BBPeripheralModelDidReceiveWriteRequests blockOnPeripheralModelDidReceiveWriteRequests;
@property (nonatomic, copy) BBPeripheralModelDidSubscribeToCharacteristic blockOnPeripheralModelDidSubscribeToCharacteristic;
@property (nonatomic, copy) BBPeripheralModelDidUnSubscribeToCharacteristic blockOnPeripheralModelDidUnSubscribeToCharacteristic;
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
*/
// Created by 刘彦玮 on 15/9/2.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyCallback.h"
@implementation BabyCallback
- (instancetype)init {
self = [super init];
if (self) {
[self setFilterOnDiscoverPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
if (![peripheralName isEqualToString:@""]) {
return YES;
}
return NO;
}];
[self setFilterOnconnectToPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
if (![peripheralName isEqualToString:@""]) {
return YES;
}
return NO;
}];
}
return self;
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief 蓝牙中心模式实现类
*/
// Created by 刘彦玮 on 15/7/30.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BabyToy.h"
#import "BabySpeaker.h"
#import "BabyDefine.h"
@interface BabyCentralManager : NSObject<CBCentralManagerDelegate,CBPeripheralDelegate> {
@public
//方法是否处理
BOOL needScanForPeripherals;//是否扫描Peripherals
BOOL needConnectPeripheral;//是否连接Peripherals
BOOL needDiscoverServices;//是否发现Services
BOOL needDiscoverCharacteristics;//是否获取Characteristics
BOOL needReadValueForCharacteristic;//是否获取(更新)Characteristics的值
BOOL needDiscoverDescriptorsForCharacteristic;//是否获取Characteristics的描述
BOOL needReadValueForDescriptors;//是否获取Descriptors的值
//一次性处理
BOOL oneReadValueForDescriptors;
//方法执行时间
int executeTime;
NSTimer *connectTimer;
//pocket
NSMutableDictionary *pocket;
//主设备
CBCentralManager *centralManager;
//回叫方法
BabySpeaker *babySpeaker;
@private
//已经连接的设备
NSMutableArray *connectedPeripherals;
//已经连接的设备
NSMutableArray *discoverPeripherals;
//需要自动重连的外设
NSMutableArray *reConnectPeripherals;
}
//扫描Peripherals
- (void)scanPeripherals;
//连接Peripherals
- (void)connectToPeripheral:(CBPeripheral *)peripheral;
//断开设备连接
- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral;
//断开所有已连接的设备
- (void)cancelAllPeripheralsConnection;
//停止扫描
- (void)cancelScan;
//获取当前连接的peripherals
- (NSArray *)findConnectedPeripherals;
//获取当前连接的peripheral
- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName;
/**
sometimes ever,sometimes never. 相聚有时,后会无期
this is center with peripheral's story
**/
//sometimes ever:添加断开重连接的设备
- (void)sometimes_ever:(CBPeripheral *)peripheral ;
//sometimes never:删除需要重连接的设备
- (void)sometimes_never:(CBPeripheral *)peripheral ;
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
*/
// Created by 刘彦玮 on 15/7/30.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyCentralManager.h"
#import "BabyCallback.h"
@implementation BabyCentralManager
#define currChannel [babySpeaker callbackOnCurrChannel]
- (instancetype)init {
self = [super init];
if (self) {
#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
//蓝牙power没打开时alert提示框
[NSNumber numberWithBool:YES],CBCentralManagerOptionShowPowerAlertKey,
//重设centralManager恢复的IdentifierKey
@"babyBluetoothRestore",CBCentralManagerOptionRestoreIdentifierKey,
nil];
#else
NSDictionary *options = nil;
#endif
NSArray *backgroundModes = [[[NSBundle mainBundle] infoDictionary]objectForKey:@"UIBackgroundModes"];
if ([backgroundModes containsObject:@"bluetooth-central"]) {
//后台模式
centralManager = [[CBCentralManager alloc]initWithDelegate:self queue:nil options:options];
}
else {
//非后台模式
centralManager = [[CBCentralManager alloc]initWithDelegate:self queue:nil];
}
//pocket
pocket = [[NSMutableDictionary alloc]init];
connectedPeripherals = [[NSMutableArray alloc]init];
discoverPeripherals = [[NSMutableArray alloc]init];
reConnectPeripherals = [[NSMutableArray alloc]init];
}
return self;
}
#pragma mark - 接收到通知
//扫描Peripherals
- (void)scanPeripherals {
[centralManager scanForPeripheralsWithServices:[currChannel babyOptions].scanForPeripheralsWithServices options:[currChannel babyOptions].scanForPeripheralsWithOptions];
}
//连接Peripherals
- (void)connectToPeripheral:(CBPeripheral *)peripheral{
[centralManager connectPeripheral:peripheral options:[currChannel babyOptions].connectPeripheralWithOptions];
}
//断开设备连接
- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral {
[centralManager cancelPeripheralConnection:peripheral];
}
//断开所有已连接的设备
- (void)cancelAllPeripheralsConnection {
for (int i=0;i<connectedPeripherals.count;i++) {
[centralManager cancelPeripheralConnection:connectedPeripherals[i]];
}
}
//停止扫描
- (void)cancelScan {
[centralManager stopScan];
//停止扫描callback
if([currChannel blockOnCancelScan]) {
[currChannel blockOnCancelScan](centralManager);
}
}
#pragma mark - CBCentralManagerDelegate委托方法
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
//发送通知
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtCentralManagerDidUpdateState object:@{@"central":central}];
switch (central.state) {
case CBCentralManagerStateUnknown:
BabyLog(@">>>CBCentralManagerStateUnknown");
break;
case CBCentralManagerStateResetting:
BabyLog(@">>>CBCentralManagerStateResetting");
break;
case CBCentralManagerStateUnsupported:
BabyLog(@">>>CBCentralManagerStateUnsupported");
break;
case CBCentralManagerStateUnauthorized:
BabyLog(@">>>CBCentralManagerStateUnauthorized");
break;
case CBCentralManagerStatePoweredOff:
BabyLog(@">>>CBCentralManagerStatePoweredOff");
break;
case CBCentralManagerStatePoweredOn:
BabyLog(@">>>CBCentralManagerStatePoweredOn");
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtCentralManagerEnable object:@{@"central":central}];
break;
default:
break;
}
//状态改变callback
if ([currChannel blockOnCentralManagerDidUpdateState]) {
[currChannel blockOnCentralManagerDidUpdateState](central);
}
}
- (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary *)dict {
}
//扫描到Peripherals
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
//日志
//BabyLog(@"当扫描到设备:%@",peripheral.name);
[self addDiscoverPeripheral:peripheral];
//发出通知
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidDiscoverPeripheral
object:@{@"central":central,@"peripheral":peripheral,@"advertisementData":advertisementData,@"RSSI":RSSI}];
//扫描到设备callback
if ([currChannel filterOnDiscoverPeripherals]) {
if ([currChannel filterOnDiscoverPeripherals](peripheral.name,advertisementData,RSSI)) {
if ([currChannel blockOnDiscoverPeripherals]) {
[[babySpeaker callbackOnCurrChannel] blockOnDiscoverPeripherals](central,peripheral,advertisementData,RSSI);
}
}
}
//处理连接设备
if (needConnectPeripheral) {
if ([currChannel filterOnconnectToPeripherals](peripheral.name,advertisementData,RSSI)) {
[centralManager connectPeripheral:peripheral options:[currChannel babyOptions].connectPeripheralWithOptions];
//开一个定时器监控连接超时的情况
connectTimer = [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(disconnect:) userInfo:peripheral repeats:NO];
}
}
}
//停止扫描
- (void)disconnect:(id)sender {
[centralManager stopScan];
}
//连接到Peripherals-成功
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
//发出通知
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidConnectPeripheral
object:@{@"central":central,@"peripheral":peripheral}];
//设置委托
[peripheral setDelegate:self];
//BabyLog(@">>>连接到名称为(%@)的设备-成功",peripheral.name);
[connectTimer invalidate];//停止时钟
[self addPeripheral:peripheral];
//执行回叫
//扫描到设备callback
if ([currChannel blockOnConnectedPeripheral]) {
[currChannel blockOnConnectedPeripheral](central,peripheral);
}
//扫描外设的服务
if (needDiscoverServices) {
[peripheral discoverServices:[currChannel babyOptions].discoverWithServices];
//discoverIncludedServices
}
}
//连接到Peripherals-失败
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
//发出通知
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidFailToConnectPeripheral
object:@{@"central":central,@"peripheral":peripheral,@"error":error?error:@""}];
// BabyLog(@">>>连接到名称为(%@)的设备-失败,原因:%@",[peripheral name],[error localizedDescription]);
if ([currChannel blockOnFailToConnect]) {
[currChannel blockOnFailToConnect](central,peripheral,error);
}
}
//Peripherals断开连接
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
//发出通知
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidDisconnectPeripheral
object:@{@"central":central,@"peripheral":peripheral,@"error":error?error:@""}];
// BabyLog(@">>>外设连接断开连接 %@: %@\n", [peripheral name], [error localizedDescription]);
if (error)
{
BabyLog(@">>> didDisconnectPeripheral for %@ with error: %@", peripheral.name, [error localizedDescription]);
}
[self deletePeripheral:peripheral];
if ([currChannel blockOnDisconnect]) {
[currChannel blockOnDisconnect](central,peripheral,error);
}
//判断是否全部链接都已经段开,调用blockOnCancelAllPeripheralsConnection委托
if ([self findConnectedPeripherals].count == 0) {
//停止扫描callback
if ([currChannel blockOnCancelAllPeripheralsConnection]) {
[currChannel blockOnCancelAllPeripheralsConnection](centralManager);
}
// BabyLog(@">>> stopConnectAllPerihperals");
}
//检查并重新连接需要重连的设备
if ([reConnectPeripherals containsObject:peripheral]) {
[self connectToPeripheral:peripheral];
}
}
//扫描到服务
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
//发出通知
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidDiscoverServices
object:@{@"peripheral":peripheral,@"error":error?error:@""}];
// BabyLog(@">>>扫描到服务:%@",peripheral.services);
if (error) {
BabyLog(@">>>didDiscoverServices for %@ with error: %@", peripheral.name, [error localizedDescription]);
}
//回叫block
if ([currChannel blockOnDiscoverServices]) {
[currChannel blockOnDiscoverServices](peripheral,error);
}
//discover characteristics
if (needDiscoverCharacteristics) {
for (CBService *service in peripheral.services) {
[peripheral discoverCharacteristics:[currChannel babyOptions].discoverWithCharacteristics forService:service];
}
}
}
//发现服务的Characteristics
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
//发出通知
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidDiscoverCharacteristicsForService
object:@{@"peripheral":peripheral,@"service":service,@"error":error?error:@""}];
if (error) {
BabyLog(@"error didDiscoverCharacteristicsForService for %@ with error: %@", service.UUID, [error localizedDescription]);
// return;
}
//回叫block
if ([currChannel blockOnDiscoverCharacteristics]) {
[currChannel blockOnDiscoverCharacteristics](peripheral,service,error);
}
//如果需要更新Characteristic的值
if (needReadValueForCharacteristic) {
for (CBCharacteristic *characteristic in service.characteristics) {
[peripheral readValueForCharacteristic:characteristic];
//判断读写权限
// if (characteristic.properties & CBCharacteristicPropertyRead ) {
// [peripheral readValueForCharacteristic:characteristic];
// }
}
}
//如果搜索Characteristic的Descriptors
if (needDiscoverDescriptorsForCharacteristic) {
for (CBCharacteristic *characteristic in service.characteristics) {
[peripheral discoverDescriptorsForCharacteristic:characteristic];
}
}
}
//读取Characteristics的值
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
//发出通知
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidUpdateValueForCharacteristic
object:@{@"peripheral":peripheral,@"characteristic":characteristic,@"error":error?error:@""}];
if (error) {
BabyLog(@"error didUpdateValueForCharacteristic %@ with error: %@", characteristic.UUID, [error localizedDescription]);
// return;
}
//查找字段订阅
if ([babySpeaker notifyCallback:characteristic]) {
[babySpeaker notifyCallback:characteristic](peripheral,characteristic,error);
return;
}
//回叫block
if ([currChannel blockOnReadValueForCharacteristic]) {
[currChannel blockOnReadValueForCharacteristic](peripheral,characteristic,error);
}
}
//发现Characteristics的Descriptors
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
if (error) {
BabyLog(@"error Discovered DescriptorsForCharacteristic for %@ with error: %@", characteristic.UUID, [error localizedDescription]);
// return;
}
//回叫block
if ([currChannel blockOnDiscoverDescriptorsForCharacteristic]) {
[currChannel blockOnDiscoverDescriptorsForCharacteristic](peripheral,characteristic,error);
}
//如果需要更新Characteristic的Descriptors
if (needReadValueForDescriptors) {
for (CBDescriptor *d in characteristic.descriptors) {
[peripheral readValueForDescriptor:d];
}
}
//执行一次的方法
if (oneReadValueForDescriptors) {
for (CBDescriptor *d in characteristic.descriptors) {
[peripheral readValueForDescriptor:d];
}
oneReadValueForDescriptors = NO;
}
}
//读取Characteristics的Descriptors的值
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error {
if (error) {
BabyLog(@"error didUpdateValueForDescriptor for %@ with error: %@", descriptor.UUID, [error localizedDescription]);
// return;
}
//回叫block
if ([currChannel blockOnReadValueForDescriptors]) {
[currChannel blockOnReadValueForDescriptors](peripheral,descriptor,error);
}
}
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidWriteValueForCharacteristic object:@{@"characteristic":characteristic,@"error":error?error:@""}];
// BabyLog(@">>>didWriteValueForCharacteristic");
// BabyLog(@">>>uuid:%@,new value:%@",characteristic.UUID,characteristic.value);
if ([currChannel blockOnDidWriteValueForCharacteristic]) {
[currChannel blockOnDidWriteValueForCharacteristic](characteristic,error);
}
}
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error {
// BabyLog(@">>>didWriteValueForCharacteristic");
// BabyLog(@">>>uuid:%@,new value:%@",descriptor.UUID,descriptor.value);
if ([currChannel blockOnDidWriteValueForDescriptor]) {
[currChannel blockOnDidWriteValueForDescriptor](descriptor,error);
}
}
//characteristic.isNotifying 状态改变
- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidUpdateNotificationStateForCharacteristic object:@{@"characteristic":characteristic,@"error":error?error:@""}];
BabyLog(@">>>didUpdateNotificationStateForCharacteristic");
BabyLog(@">>>uuid:%@,isNotifying:%@",characteristic.UUID,characteristic.isNotifying?@"isNotifying":@"Notifying");
if ([currChannel blockOnDidUpdateNotificationStateForCharacteristic]) {
[currChannel blockOnDidUpdateNotificationStateForCharacteristic](characteristic,error);
}
}
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverIncludedServicesForService:(CBService *)service error:(NSError *)error {
if ([currChannel blockOnDidDiscoverIncludedServicesForService]) {
[currChannel blockOnDidDiscoverIncludedServicesForService](service,error);
}
}
# if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
- (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(nullable NSError *)error {
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidReadRSSI object:@{@"peripheral":peripheral,@"RSSI":peripheral.RSSI,@"error":error?error:@""}];
BabyLog(@">>>peripheralDidUpdateRSSI -> RSSI:%@",peripheral.RSSI);
if ([currChannel blockOnDidReadRSSI]) {
[currChannel blockOnDidReadRSSI](peripheral.RSSI,error);
}
}
#else
- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(NSError *)error {
[[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidReadRSSI object:@{@"peripheral":peripheral,@"RSSI":RSSI,@"error":error?error:@""}];
BabyLog(@">>>peripheralDidUpdateRSSI -> RSSI:%@",RSSI);
if ([currChannel blockOnDidReadRSSI]) {
[currChannel blockOnDidReadRSSI](RSSI,error);
}
}
#endif
- (void)peripheralDidUpdateName:(CBPeripheral *)peripheral {
if ([currChannel blockOnDidUpdateName]) {
[currChannel blockOnDidUpdateName](peripheral);
}
}
- (void)peripheral:(CBPeripheral *)peripheral didModifyServices:(NSArray *)invalidatedServices {
if ([currChannel blockOnDidModifyServices]) {
[currChannel blockOnDidModifyServices](peripheral,invalidatedServices);
}
}
/**
sometimes ever,sometimes never. 相聚有时,后会无期
this is center with peripheral's story
**/
//sometimes ever:添加断开重连接的设备
- (void)sometimes_ever:(CBPeripheral *)peripheral {
if (![reConnectPeripherals containsObject:peripheral]) {
[reConnectPeripherals addObject:peripheral];
}
}
//sometimes never:删除需要重连接的设备
- (void)sometimes_never:(CBPeripheral *)peripheral {
[reConnectPeripherals removeObject:peripheral];
}
#pragma mark - 私有方法
#pragma mark - 设备list管理
- (void)addDiscoverPeripheral:(CBPeripheral *)peripheral{
if (![discoverPeripherals containsObject:peripheral]) {
[discoverPeripherals addObject:peripheral];
}
}
- (void)addPeripheral:(CBPeripheral *)peripheral {
if (![connectedPeripherals containsObject:peripheral]) {
[connectedPeripherals addObject:peripheral];
}
}
- (void)deletePeripheral:(CBPeripheral *)peripheral{
[connectedPeripherals removeObject:peripheral];
}
- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName {
for (CBPeripheral *p in connectedPeripherals) {
if ([p.name isEqualToString:peripheralName]) {
return p;
}
}
return nil;
}
- (NSArray *)findConnectedPeripherals{
return connectedPeripherals;
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief 预定义一些库的执行行为和配置
*/
// Created by 刘彦玮 on 6/4/19.
// Copyright © 2016年 liuyanwei. All rights reserved.
//
#import <Foundation/Foundation.h>
# pragma mark - baby 行为定义
//Baby if show log 是否打印日志,默认1:打印 ,0:不打印
#define KBABY_IS_SHOW_LOG 1
//CBcentralManager等待设备打开次数
# define KBABY_CENTRAL_MANAGER_INIT_WAIT_TIMES 5
//CBcentralManager等待设备打开间隔时间
# define KBABY_CENTRAL_MANAGER_INIT_WAIT_SECOND 2.0
//BabyRhythm默认心跳时间间隔
#define KBABYRHYTHM_BEATS_DEFAULT_INTERVAL 3;
//Baby默认链式方法channel名称
#define KBABY_DETAULT_CHANNEL @"babyDefault"
# pragma mark - baby通知
//蓝牙系统通知
//centralManager status did change notification
#define BabyNotificationAtCentralManagerDidUpdateState @"BabyNotificationAtCentralManagerDidUpdateState"
//did discover peripheral notification
#define BabyNotificationAtDidDiscoverPeripheral @"BabyNotificationAtDidDiscoverPeripheral"
//did connection peripheral notification
#define BabyNotificationAtDidConnectPeripheral @"BabyNotificationAtDidConnectPeripheral"
//did filed connect peripheral notification
#define BabyNotificationAtDidFailToConnectPeripheral @"BabyNotificationAtDidFailToConnectPeripheral"
//did disconnect peripheral notification
#define BabyNotificationAtDidDisconnectPeripheral @"BabyNotificationAtDidDisconnectPeripheral"
//did discover service notification
#define BabyNotificationAtDidDiscoverServices @"BabyNotificationAtDidDiscoverServices"
//did discover characteristics notification
#define BabyNotificationAtDidDiscoverCharacteristicsForService @"BabyNotificationAtDidDiscoverCharacteristicsForService"
//did read or notify characteristic when received value notification
#define BabyNotificationAtDidUpdateValueForCharacteristic @"BabyNotificationAtDidUpdateValueForCharacteristic"
//did write characteristic and response value notification
#define BabyNotificationAtDidWriteValueForCharacteristic @"BabyNotificationAtDidWriteValueForCharacteristic"
//did change characteristis notify status notification
#define BabyNotificationAtDidUpdateNotificationStateForCharacteristic @"BabyNotificationAtDidUpdateNotificationStateForCharacteristic"
//did read rssi and receiced value notification
#define BabyNotificationAtDidReadRSSI @"BabyNotificationAtDidReadRSSI"
//蓝牙扩展通知
// did centralManager enable notification
#define BabyNotificationAtCentralManagerEnable @"BabyNotificationAtCentralManagerEnable"
# pragma mark - baby 定义的方法
//Baby log
#define BabyLog(fmt, ...) if(KBABY_IS_SHOW_LOG) { NSLog(fmt,##__VA_ARGS__); }
@interface BabyDefine : NSObject
@end
//
// BabyBlueDefine.m
// BabyTestProject
//
// Created by xuanyan.lyw on 16/4/19.
// Copyright © 2016年 liuyanwei. All rights reserved.
//
#import "BabyDefine.h"
@implementation BabyDefine
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth 封装蓝牙外设模式的运行时参数,可以实现后台模式,重复接收广播,查找service参数,查找characteristic参数
*/
// Created by 刘彦玮 on 15/9/27.
// Copyright © 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
@interface BabyOptions : NSObject
#pragma mark - 属性
/*!
* 扫描参数,centralManager:scanForPeripheralsWithServices:self.scanForPeripheralsWithServices options:self.scanForPeripheralsWithOptions
* @param An optional dictionary specifying options for the scan.
* @see centralManager:scanForPeripheralsWithServices
* @seealso CBCentralManagerScanOptionAllowDuplicatesKey :忽略同一个Peripheral端的多个发现事件被聚合成一个发现事件
* @seealso CBCentralManagerScanOptionSolicitedServiceUUIDsKey
*/
@property (nonatomic, copy) NSDictionary *scanForPeripheralsWithOptions;
/*!
* 连接设备的参数
* @method connectPeripheral:options:
* @param An optional dictionary specifying connection behavior options.
* @see centralManager:didConnectPeripheral:
* @see centralManager:didFailToConnectPeripheral:error:
* @seealso CBConnectPeripheralOptionNotifyOnConnectionKey
* @seealso CBConnectPeripheralOptionNotifyOnDisconnectionKey
* @seealso CBConnectPeripheralOptionNotifyOnNotificationKey
*/
@property (nonatomic, copy) NSDictionary *connectPeripheralWithOptions;
/*!
* 扫描参数,centralManager:scanForPeripheralsWithServices:self.scanForPeripheralsWithServices options:self.scanForPeripheralsWithOptions
*@param serviceUUIDs A list of <code>CBUUID</code> objects representing the service(s) to scan for.
*@see centralManager:scanForPeripheralsWithServices
*/
@property (nonatomic, copy) NSArray *scanForPeripheralsWithServices;
// [peripheral discoverServices:self.discoverWithServices];
@property (nonatomic, copy) NSArray *discoverWithServices;
// [peripheral discoverCharacteristics:self.discoverWithCharacteristics forService:service];
@property (nonatomic, copy) NSArray *discoverWithCharacteristics;
#pragma mark - 构造方法
- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions;
- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
discoverWithServices:(NSArray *)discoverWithServices
discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;
@end
//
// BabyClothes.m
// BabyBluetoothAppDemo
//
// Created by 刘彦玮 on 15/9/27.
// Copyright © 2015年 刘彦玮. All rights reserved.
//
#import "BabyOptions.h"
@implementation BabyOptions
- (instancetype)init {
self = [super init];
if (self) {
_scanForPeripheralsWithOptions = nil;
_connectPeripheralWithOptions = nil;
_scanForPeripheralsWithServices = nil;
_discoverWithServices = nil;
_discoverWithCharacteristics = nil;
}
return self;
}
- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
{
self = [super init];
if (self) {
[self setScanForPeripheralsWithOptions:scanForPeripheralsWithOptions];
[self setConnectPeripheralWithOptions:connectPeripheralWithOptions];
}
return self;
}
- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
discoverWithServices:(NSArray *)discoverWithServices
discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics
{
self = [self initWithscanForPeripheralsWithOptions:scanForPeripheralsWithOptions connectPeripheralWithOptions:connectPeripheralWithOptions];
if (self) {
[self setScanForPeripheralsWithServices:scanForPeripheralsWithServices];
[self setDiscoverWithServices:discoverWithServices];
[self setDiscoverWithCharacteristics:discoverWithCharacteristics];
}
return self;
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief 蓝牙外设模式实现类
*/
// Created by 刘彦玮 on 15/12/12.
// Copyright © 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BabyToy.h"
#import "BabySpeaker.h"
@interface BabyPeripheralManager : NSObject<CBPeripheralManagerDelegate> {
@public
//回叫方法
BabySpeaker *babySpeaker;
}
/**
添加服务
*/
- (BabyPeripheralManager *(^)(NSArray *array))addServices;
/**
启动广播
*/
- (BabyPeripheralManager *(^)())startAdvertising;
//外设管理器
@property (nonatomic, strong) CBPeripheralManager *peripheralManager;
@property (nonatomic, copy) NSString *localName;
@property (nonatomic, strong) NSMutableArray *services;
@end
/**
* 构造Characteristic,并加入service
* service:CBService
* param`ter for properties :option 'r' | 'w' | 'n' or combination
* r CBCharacteristicPropertyRead
* w CBCharacteristicPropertyWrite
* n CBCharacteristicPropertyNotify
* default value is rw Read-Write
* paramter for descriptor:be uesd descriptor for characteristic
*/
void makeCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *properties,NSString *descriptor);
/**
* 构造一个包含初始值的Characteristic,并加入service,包含了初值的characteristic必须设置permissions和properties都为只读
* make characteristic then add to service, a static characteristic mean it has a initial value .according apple rule, it must set properties and permissions to CBCharacteristicPropertyRead and CBAttributePermissionsReadable
*/
void makeStaticCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *descriptor,NSData *data);
/**
生成CBService
*/
CBMutableService* makeCBService(NSString *UUID);
/**
生成UUID
*/
NSString* genUUID();
//
// BabyPeripheralManager.m
// BluetoothStubOnIOS
//
// Created by 刘彦玮 on 15/12/12.
// Copyright © 2015年 刘彦玮. All rights reserved.
//
#import "BabyPeripheralManager.h"
#import "BabyDefine.h"
#define callbackBlock(...) if ([[babySpeaker callback] __VA_ARGS__]) [[babySpeaker callback] __VA_ARGS__ ]
@implementation BabyPeripheralManager {
int PERIPHERAL_MANAGER_INIT_WAIT_TIMES;
int didAddServices;
NSTimer *addServiceTask;
}
- (instancetype)init {
self = [super init];
if (self) {
_localName = @"baby-default-name";
_peripheralManager = [[CBPeripheralManager alloc]initWithDelegate:self queue:nil options:nil];
}
return self;
}
- (BabyPeripheralManager *(^)())startAdvertising {
return ^BabyPeripheralManager *() {
if ([self canStartAdvertising]) {
PERIPHERAL_MANAGER_INIT_WAIT_TIMES = 0;
NSMutableArray *UUIDS = [NSMutableArray array];
for (CBMutableService *s in _services) {
[UUIDS addObject:s.UUID];
}
//启动广播
[_peripheralManager startAdvertising:
@{
CBAdvertisementDataServiceUUIDsKey : UUIDS
,CBAdvertisementDataLocalNameKey : _localName
}];
}
else {
PERIPHERAL_MANAGER_INIT_WAIT_TIMES++;
if (PERIPHERAL_MANAGER_INIT_WAIT_TIMES > 5) {
BabyLog(@">>>error: 第%d次等待peripheralManager打开任然失败,请检查蓝牙设备是否可用",PERIPHERAL_MANAGER_INIT_WAIT_TIMES);
}
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 3.0 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
self.startAdvertising();
});
BabyLog(@">>> 第%d次等待peripheralManager打开",PERIPHERAL_MANAGER_INIT_WAIT_TIMES);
}
return self;
};
}
- (BOOL)canStartAdvertising {
if (_peripheralManager.state != CBPeripheralManagerStatePoweredOn) {
return NO;
}
if (didAddServices != _services.count) {
return NO;
}
return YES;
}
- (BOOL)isPoweredOn {
if (_peripheralManager.state != CBPeripheralManagerStatePoweredOn) {
return NO;
}
return YES;
}
- (BabyPeripheralManager *(^)(NSArray *array))addServices {
return ^BabyPeripheralManager*(NSArray *array) {
_services = [NSMutableArray arrayWithArray:array];
[self addServicesToPeripheral];
return self;
};
}
- (void)addServicesToPeripheral {
if ([self isPoweredOn]) {
for (CBMutableService *s in _services) {
[_peripheralManager addService:s];
}
}
else {
[addServiceTask setFireDate:[NSDate distantPast]];
addServiceTask = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(addServicesToPeripheral) userInfo:nil repeats:NO];
}
}
#pragma mark - peripheralManager delegate
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
switch (peripheral.state) {
case CBPeripheralManagerStateUnknown:
BabyLog(@">>>CBPeripheralManagerStateUnknown");
break;
case CBPeripheralManagerStateResetting:
BabyLog(@">>>CBPeripheralManagerStateResetting");
break;
case CBPeripheralManagerStateUnsupported:
BabyLog(@">>>CBPeripheralManagerStateUnsupported");
break;
case CBPeripheralManagerStateUnauthorized:
BabyLog(@">>>CBPeripheralManagerStateUnauthorized");
break;
case CBPeripheralManagerStatePoweredOff:
BabyLog(@">>>CBPeripheralManagerStatePoweredOff");
break;
case CBPeripheralManagerStatePoweredOn:
BabyLog(@">>>CBPeripheralManagerStatePoweredOn");
//发送centralManagerDidUpdateState通知
[[NSNotificationCenter defaultCenter]postNotificationName:@"CBPeripheralManagerStatePoweredOn" object:nil];
break;
default:
break;
}
// if([babySpeaker callback] blockOnPeripheralModelDidUpdateState) {
// [currChannel blockOnCancelScan](centralManager);
// }
callbackBlock(blockOnPeripheralModelDidUpdateState)(peripheral);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral didAddService:(CBService *)service error:(NSError *)error {
didAddServices++;
callbackBlock(blockOnPeripheralModelDidAddService)(peripheral,service,error);
}
- (void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral error:(NSError *)error {
callbackBlock(blockOnPeripheralModelDidStartAdvertising)(peripheral,error);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request {
callbackBlock(blockOnPeripheralModelDidReceiveReadRequest)(peripheral, request);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray *)requests {
callbackBlock(blockOnPeripheralModelDidReceiveWriteRequests)(peripheral,requests);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic {
callbackBlock(blockOnPeripheralModelDidSubscribeToCharacteristic)(peripheral,central,characteristic);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didUnsubscribeFromCharacteristic:(CBCharacteristic *)characteristic {
callbackBlock(blockOnPeripheralModelDidUnSubscribeToCharacteristic)(peripheral,central,characteristic);
}
@end
void makeCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *properties,NSString *descriptor) {
//paramter for properties
CBCharacteristicProperties prop = 0x00;
if ([properties containsString:@"r"]) {
prop = prop | CBCharacteristicPropertyRead;
}
if ([properties containsString:@"w"]) {
prop = prop | CBCharacteristicPropertyWrite;
}
if ([properties containsString:@"n"]) {
prop = prop | CBCharacteristicPropertyNotify;
}
if (properties == nil || [properties isEqualToString:@""]) {
prop = CBCharacteristicPropertyRead | CBCharacteristicPropertyWrite;
}
CBMutableCharacteristic *c = [[CBMutableCharacteristic alloc]initWithType:[CBUUID UUIDWithString:UUID] properties:prop value:nil permissions:CBAttributePermissionsReadable | CBAttributePermissionsWriteable];
//paramter for descriptor
if (!(descriptor == nil || [descriptor isEqualToString:@""])) {
//c设置description对应的haracteristics字段描述
CBUUID *CBUUIDCharacteristicUserDescriptionStringUUID = [CBUUID UUIDWithString:CBUUIDCharacteristicUserDescriptionString];
CBMutableDescriptor *desc = [[CBMutableDescriptor alloc]initWithType: CBUUIDCharacteristicUserDescriptionStringUUID value:descriptor];
[c setDescriptors:@[desc]];
}
if (!service.characteristics) {
service.characteristics = @[];
}
NSMutableArray *cs = [service.characteristics mutableCopy];
[cs addObject:c];
service.characteristics = [cs copy];
}
void makeStaticCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *descriptor,NSData *data) {
CBMutableCharacteristic *c = [[CBMutableCharacteristic alloc]initWithType:[CBUUID UUIDWithString:UUID] properties:CBCharacteristicPropertyRead value:data permissions:CBAttributePermissionsReadable];
//paramter for descriptor
if (!(descriptor == nil || [descriptor isEqualToString:@""])) {
//c设置description对应的haracteristics字段描述
CBUUID *CBUUIDCharacteristicUserDescriptionStringUUID = [CBUUID UUIDWithString:CBUUIDCharacteristicUserDescriptionString];
CBMutableDescriptor *desc = [[CBMutableDescriptor alloc]initWithType: CBUUIDCharacteristicUserDescriptionStringUUID value:descriptor];
[c setDescriptors:@[desc]];
}
if (!service.characteristics) {
service.characteristics = @[];
}
NSMutableArray *cs = [service.characteristics mutableCopy];
[cs addObject:c];
service.characteristics = [cs copy];
}
CBMutableService* makeCBService(NSString *UUID)
{
CBMutableService *s = [[CBMutableService alloc]initWithType:[CBUUID UUIDWithString:UUID] primary:YES];
return s;
}
NSString * genUUID()
{
CFUUIDRef uuid_ref = CFUUIDCreate(NULL);
CFStringRef uuid_string_ref= CFUUIDCreateString(NULL, uuid_ref);
CFRelease(uuid_ref);
NSString *uuid = [NSString stringWithString:(__bridge NSString*)uuid_string_ref];
CFRelease(uuid_string_ref);
return uuid;
}
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth Rhythm用于检测蓝牙的任务执行情况,处理复杂的蓝牙流程操作
*/
//
// Created by ZTELiuyw on 15/9/15.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BabyDefine.h"
@interface BabyRhythm : NSObject
typedef void (^BBBeatsBreakBlock)(BabyRhythm *bry);
typedef void (^BBBeatsOverBlock)(BabyRhythm *bry);
//timer for beats
@property (nonatomic, strong) NSTimer *beatsTimer;
//beat interval
@property NSInteger beatsInterval;
#pragma mark beats
//心跳
- (void)beats;
//主动中断心跳
- (void)beatsBreak;
//结束心跳,结束后会进入BlockOnBeatOver,并且结束后再不会在触发BlockOnBeatBreak
- (void)beatsOver;
//恢复心跳,beatsOver操作后可以使用beatsRestart恢复心跳,恢复后又可以进入BlockOnBeatBreak方法
- (void)beatsRestart;
//心跳中断的委托
- (void)setBlockOnBeatsBreak:(void(^)(BabyRhythm *bry))block;
//心跳结束的委托
- (void)setBlockOnBeatsOver:(void(^)(BabyRhythm *bry))block;
@end
//
// BabyBeats.m
// BabyBluetoothAppDemo
//
// Created by ZTELiuyw on 15/9/15.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyRhythm.h"
#import "BabyDefine.h"
@implementation BabyRhythm {
BOOL isOver;
BBBeatsBreakBlock blockOnBeatBreak;
BBBeatsOverBlock blockOnBeatOver;
}
- (instancetype)init {
self = [super init];
if (self) {
//beatsInterval
_beatsInterval = KBABYRHYTHM_BEATS_DEFAULT_INTERVAL;
}
return self;
}
- (void)beats {
if (isOver) {
BabyLog(@">>>beats isOver");
return;
}
BabyLog(@">>>beats at :%@",[NSDate date]);
if (self.beatsTimer) {
[self.beatsTimer setFireDate: [[NSDate date]dateByAddingTimeInterval:self.beatsInterval]];
}
else {
self.beatsTimer = [NSTimer timerWithTimeInterval:self.beatsInterval target:self selector:@selector(beatsBreak) userInfo:nil repeats:YES];
[self.beatsTimer setFireDate: [[NSDate date]dateByAddingTimeInterval:self.beatsInterval]];
[[NSRunLoop currentRunLoop] addTimer:self.beatsTimer forMode:NSRunLoopCommonModes];
}
}
- (void)beatsBreak {
BabyLog(@">>>beatsBreak :%@",[NSDate date]);
[self.beatsTimer setFireDate:[NSDate distantFuture]];
if (blockOnBeatBreak) {
blockOnBeatBreak(self);
}
}
- (void)beatsOver {
BabyLog(@">>>beatsOver :%@",[NSDate date]);
[self.beatsTimer setFireDate:[NSDate distantFuture]];
isOver = YES;
if (blockOnBeatOver) {
blockOnBeatOver(self);
}
}
- (void)beatsRestart {
BabyLog(@">>>beatsRestart :%@",[NSDate date]);
isOver = NO;
[self beats];
}
- (void)setBlockOnBeatsBreak:(void(^)(BabyRhythm *bry))block {
blockOnBeatBreak = block;
}
- (void)setBlockOnBeatsOver:(void(^)(BabyRhythm *bry))block {
blockOnBeatOver = block;
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth block查找和channel切换
*/
// Created by 刘彦玮 on 15/9/2.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyCallback.h"
#import <CoreBluetooth/CoreBluetooth.h>
@interface BabySpeaker : NSObject
- (BabyCallback *)callback;
- (BabyCallback *)callbackOnCurrChannel;
- (BabyCallback *)callbackOnChnnel:(NSString *)channel;
- (BabyCallback *)callbackOnChnnel:(NSString *)channel
createWhenNotExist:(BOOL)createWhenNotExist;
//切换频道
- (void)switchChannel:(NSString *)channel;
//添加到notify list
- (void)addNotifyCallback:(CBCharacteristic *)c
withBlock:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block;
//添加到notify list
- (void)removeNotifyCallback:(CBCharacteristic *)c;
//获取notify list
- (NSMutableDictionary *)notifyCallBackList;
//获取notityBlock
- (void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))notifyCallback:(CBCharacteristic *)c;
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
*/
// Created by 刘彦玮 on 15/9/2.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabySpeaker.h"
#import "BabyDefine.h"
typedef NS_ENUM(NSUInteger, BabySpeakerType) {
BabySpeakerTypeDiscoverPeripherals,
BabySpeakerTypeConnectedPeripheral,
BabySpeakerTypeDiscoverPeripheralsFailToConnect,
BabySpeakerTypeDiscoverPeripheralsDisconnect,
BabySpeakerTypeDiscoverPeripheralsDiscoverServices,
BabySpeakerTypeDiscoverPeripheralsDiscoverCharacteristics,
BabySpeakerTypeDiscoverPeripheralsReadValueForCharacteristic,
BabySpeakerTypeDiscoverPeripheralsDiscoverDescriptorsForCharacteristic,
BabySpeakerTypeDiscoverPeripheralsReadValueForDescriptorsBlock
};
@implementation BabySpeaker {
//所有委托频道
NSMutableDictionary *channels;
//当前委托频道
NSString *currChannel;
//notifyList
NSMutableDictionary *notifyList;
}
- (instancetype)init {
self = [super init];
if (self) {
BabyCallback *defaultCallback = [[BabyCallback alloc]init];
notifyList = [[NSMutableDictionary alloc]init];
channels = [[NSMutableDictionary alloc]init];
currChannel = KBABY_DETAULT_CHANNEL;
[channels setObject:defaultCallback forKey:KBABY_DETAULT_CHANNEL];
}
return self;
}
- (BabyCallback *)callback {
return [channels objectForKey:KBABY_DETAULT_CHANNEL];
}
- (BabyCallback *)callbackOnCurrChannel {
return [self callbackOnChnnel:currChannel];
}
- (BabyCallback *)callbackOnChnnel:(NSString *)channel {
if (!channel) {
[self callback];
}
return [channels objectForKey:channel];
}
- (BabyCallback *)callbackOnChnnel:(NSString *)channel
createWhenNotExist:(BOOL)createWhenNotExist {
BabyCallback *callback = [channels objectForKey:channel];
if (!callback && createWhenNotExist) {
callback = [[BabyCallback alloc]init];
[channels setObject:callback forKey:channel];
}
return callback;
}
- (void)switchChannel:(NSString *)channel {
if (channel) {
if ([self callbackOnChnnel:channel]) {
currChannel = channel;
BabyLog(@">>>已切换到%@",channel);
}
else {
BabyLog(@">>>所要切换的channel不存在");
}
}
else {
currChannel = KBABY_DETAULT_CHANNEL;
BabyLog(@">>>已切换到默认频道");
}
}
//添加到notify list
- (void)addNotifyCallback:(CBCharacteristic *)c
withBlock:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block {
[notifyList setObject:block forKey:c.UUID.description];
}
//添加到notify list
- (void)removeNotifyCallback:(CBCharacteristic *)c {
[notifyList removeObjectForKey:c.UUID.description];
}
//获取notify list
- (NSMutableDictionary *)notifyCallBackList {
return notifyList;
}
//获取notityBlock
- (void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))notifyCallback:(CBCharacteristic *)c {
return [notifyList objectForKey:c.UUID.description];
}
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
@brief babybluetooth 工具类
*/
// Created by 刘彦玮 on 15/8/1.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
@interface BabyToy : NSObject
//十六进制转换为普通字符串的。
+ (NSString *)ConvertHexStringToString:(NSString *)hexString;
//普通字符串转换为十六进制
+ (NSString *)ConvertStringToHexString:(NSString *)string;
//int转data
+(NSData *)ConvertIntToData:(int)i;
//data转int
+(int)ConvertDataToInt:(NSData *)data;
//十六进制转换为普通字符串的。
+ (NSData *)ConvertHexStringToData:(NSString *)hexString;
//根据UUIDString查找CBCharacteristic
+(CBCharacteristic *)findCharacteristicFormServices:(NSMutableArray *)services
UUIDString:(NSString *)UUIDString;
@end
/*
BabyBluetooth
简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
https://github.com/coolnameismy/BabyBluetooth
*/
// Created by 刘彦玮 on 15/8/1.
// Copyright (c) 2015年 刘彦玮. All rights reserved.
//
#import "BabyToy.h"
@implementation BabyToy
//十六进制转换为普通字符串的。
+ (NSString *)ConvertHexStringToString:(NSString *)hexString {
char *myBuffer = (char *)malloc((int)[hexString length] / 2 + 1);
bzero(myBuffer, [hexString length] / 2 + 1);
for (int i = 0; i < [hexString length] - 1; i += 2) {
unsigned int anInt;
NSString * hexCharStr = [hexString substringWithRange:NSMakeRange(i, 2)];
NSScanner *scanner = [[NSScanner alloc] initWithString:hexCharStr];
[scanner scanHexInt:&anInt];
myBuffer[i / 2] = (char)anInt;
}
NSString *unicodeString = [NSString stringWithCString:myBuffer encoding:4];
// BabyLog(@"===字符串===%@",unicodeString);
return unicodeString;
}
//普通字符串转换为十六进制
+ (NSString *)ConvertStringToHexString:(NSString *)string {
NSData *myD = [string dataUsingEncoding:NSUTF8StringEncoding];
Byte *bytes = (Byte *)[myD bytes];
//下面是Byte 转换为16进制。
NSString *hexStr=@"";
for (int i=0;i<[myD length];i++) {
NSString *newHexStr = [NSString stringWithFormat:@"%x",bytes[i]&0xff];///16进制数
if ([newHexStr length]==1) {
hexStr = [NSString stringWithFormat:@"%@0%@",hexStr,newHexStr];
}
else{
hexStr = [NSString stringWithFormat:@"%@%@",hexStr,newHexStr];
}
}
return hexStr;
}
//int转data
+ (NSData *)ConvertIntToData:(int)i {
NSData *data = [NSData dataWithBytes: &i length: sizeof(i)];
return data;
}
//data转int
+ (int)ConvertDataToInt:(NSData *)data {
int i;
[data getBytes:&i length:sizeof(i)];
return i;
}
//十六进制转换为普通字符串的。
+ (NSData *)ConvertHexStringToData:(NSString *)hexString {
NSData *data = [[BabyToy ConvertHexStringToString:hexString] dataUsingEncoding:NSUTF8StringEncoding];
return data;
}
//根据UUIDString查找CBCharacteristic
+ (CBCharacteristic *)findCharacteristicFormServices:(NSMutableArray *)services
UUIDString:(NSString *)UUIDString {
for (CBService *s in services) {
for (CBCharacteristic *c in s.characteristics) {
if ([c.UUID.UUIDString isEqualToString:UUIDString]) {
return c;
}
}
}
return nil;
}
@end
The MIT License (MIT)
Copyright (c) 2015 liuyanwei
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
![](http://images.jumppo.com/uploads/BabyBluetooth_logo.png)
The easiest way to use Bluetooth (BLE )in ios,even bady can use. 简单易用的蓝牙库,基于CoreBluetooth的封装,并兼容ios和mac osx.
**为什么使用它?**
- 1:基于原生CoreBluetooth框架封装的轻量级的开源库,可以帮你更简单地使用CoreBluetooth API。
- 2:CoreBluetooth所有方法都是通过委托完成,代码冗余且顺序凌乱。BabyBluetooth使用block方法,可以重新按照功能和顺序组织代码,并提供许多方法减少蓝牙开发过程中的代码量。
- 3:链式方法体,代码更简洁、优雅。
- 4:通过channel切换区分委托调用,并方便切换
- 5:便利的工具方法
- 6:完善的文档,且项目处于活跃状态,不断的更新中
- 7:github上star最多的纯Bluetooth类库
- 8:包含多种类型的demo和ios蓝牙开发教程
- 9:同时支持蓝牙设备中心模式和外设模式(central model and peripheral model)
当前版本 0.6.0
详细文档请参考wiki The full documentation of the project is available on its wiki.
# [english readme link,please click it!](https://github.com/coolnameismy/BabyBluetooth/blob/master/README_en.md)
# Table Of Contents
* [QuickExample](#user-content-QuickExample)
* [如何安装](#如何安装)
* [如何使用](#如何使用)
* [示例程序说明](#示例程序说明)
* [兼容性](#兼容性)
* [后期更新](#后期更新)
* [蓝牙学习资源](#蓝牙学习资源)
* [期待](#期待)
# QuickExample
## 中心模式 central model
> app作为中心,连接其他BLE4.0外设
```objc
//导入.h文件和系统蓝牙库的头文件
#import "BabyBluetooth.h"
//定义变量
BabyBluetooth *baby;
-(void)viewDidLoad {
[super viewDidLoad];
//初始化BabyBluetooth 蓝牙库
baby = [BabyBluetooth shareBabyBluetooth];
//设置蓝牙委托
[self babyDelegate];
//设置委托后直接可以使用,无需等待CBCentralManagerStatePoweredOn状态
baby.scanForPeripherals().begin();
}
//设置蓝牙委托
-(void)babyDelegate{
//设置扫描到设备的委托
[baby setBlockOnDiscoverToPeripherals:^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
NSLog(@"搜索到了设备:%@",peripheral.name);
}];
//过滤器
//设置查找设备的过滤器
[baby setFilterOnDiscoverPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
//最常用的场景是查找某一个前缀开头的设备 most common usage is discover for peripheral that name has common prefix
//if ([peripheralName hasPrefix:@"Pxxxx"] ) {
// return YES;
//}
//return NO;
//设置查找规则是名称大于1 , the search rule is peripheral.name length > 1
if (peripheralName.length >1) {
return YES;
}
return NO;
}];
//.......
}
```
更多蓝牙操作方法和委托请参考[wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
中心模式使用示例请参考:[BabyBluetoothAppDemo](https://github.com/coolnameismy//BabyBluetoothExamples/BabyBluetoothAppDemo)
## 外设模式 peripheral model
> app模拟一个,BLE4.0外设,可以被其他设备连接和使用
模拟一个有2个service和6个characteristic的外设
````objc
//导入.h文件和系统蓝牙库的头文件
#import "BabyBluetooth.h"
//定义变量
BabyBluetooth *baby;
-(void)viewDidLoad {
[super viewDidLoad];
//配置第一个服务s1
CBMutableService *s1 = makeCBService(@"FFF0");
//配置s1的3个characteristic
makeCharacteristicToService(s1, @"FFF1", @"r", @"hello1");//读
makeCharacteristicToService(s1, @"FFF2", @"w", @"hello2");//写
makeCharacteristicToService(s1, genUUID(), @"rw", @"hello3");//可读写,uuid自动生成
makeCharacteristicToService(s1, @"FFF4", nil, @"hello4");//默认读写字段
makeCharacteristicToService(s1, @"FFF5", @"n", @"hello5");//notify字段
//配置第一个服务s2
CBMutableService *s2 = makeCBService(@"FFE0");
makeStaticCharacteristicToService(s2, genUUID(), @"hello6", [@"a" dataUsingEncoding:NSUTF8StringEncoding]);//一个含初值的字段,该字段权限只能是只读
//实例化baby
baby = [BabyBluetooth shareBabyBluetooth];
//配置委托
[self babyDelegate];
//启动外设
baby.bePeripheral().addServices(@[s1,s2]).startAdvertising();
}
//设置蓝牙外设模式的委托
-(void)babyDelegate{
//设置添加service委托 | set didAddService block
[baby peripheralModelBlockOnPeripheralManagerDidUpdateState:^(CBPeripheralManager *peripheral) {
NSLog(@"PeripheralManager trun status code: %ld",(long)peripheral.state);
}];
//设置添加service委托 | set didAddService block
[baby peripheralModelBlockOnDidStartAdvertising:^(CBPeripheralManager *peripheral, NSError *error) {
NSLog(@"didStartAdvertising !!!");
}];
//设置添加service委托 | set didAddService block
[baby peripheralModelBlockOnDidAddService:^(CBPeripheralManager *peripheral, CBService *service, NSError *error) {
NSLog(@"Did Add Service uuid: %@ ",service.UUID);
}];
//.....
}
````
更多蓝牙外设模式委托请参考[wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
中心模式使用示例请参考:[BluetoothStubOnIOS](https://github.com/coolnameismy//BabyBluetoothExamples/BluetoothStubOnIOS)
# 如何安装
##1 手动安装
step1:将项目Classes/objc 文件夹中的文件直接拖入你的项目中即可
step2:导入.h文件
````objc
#import "BabyBluetooth.h"
````
##2 cocoapods
step1:add the following line to your Podfile:
````
pod 'BabyBluetooth','~> 0.6.0'
````
step2:导入.h文件
````objc
#import "BabyBluetooth.h"
````
# 如何使用
[用法请见wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
# 示例程序说明
**BabyBluetoothExamples/BabyBluetoothAppDemo** :一个类似lightblue的程序,蓝牙操作全部使用BabyBluetooth完成。
功能:
- 1:扫描周围设备
- 2:连接设备,扫描设备的全部services和characteristic
- 3:显示characteristic,读取characteristic的value,和descriptors以及Descriptors对应的value
- 4:写0x01到characteristic
- 5:订阅/取消订阅 characteristic的notify
**BabyBluetoothExamples/BluetoothStubOnIOS** : 一个iOS程序,启动后会用手机模拟一个外设,提供2个服务和若干characteristic。
该程序作为Babybluetooth 外设模式使用的示例程序
**BabyBluetoothExamples/BabyBluetoothOSDemo** :一个mac os程序,因为os和ios的蓝牙底层方法都一样,所以BabyBluetooth可以ios/os通用。但是os程序有个好处就是直接可以在mac上跑蓝牙设备,不像ios,必须要真机才能跑蓝牙设备。所以不能真机调试时可以使用os尝试蓝牙库的使用。
功能:
- 1:扫描周围设备、连接设备、显示characteristic,读取characteristic的value,和descriptors以及Descriptors对应的value的委托设置,并使用nslog打印信息。
**BabyBluetoothExamples/BluetoothStubOnOSX** :一个mac os程序,该程序可以作为蓝牙外设使用,解决学习蓝牙时没有外设可用的囧境,并且可以作为peripheral model模式的学习示例。改程序用swift编码。
功能:
- 1:作为蓝牙外设使用,可以被发现,连接,读写,订阅
- 2:提供1个service,包含了3个characteristic,分别具有读、读写、订阅功能
# 兼容性
- 蓝牙4.0,也叫做ble,ios6以上和iPhone4s以上可以自由使用
- os和ios通用
- 蓝牙设备相关程序必须使用真机才能运行。如果不能使用真机调试的情况,可以使用os程序调试蓝牙。可以参考示例程序中的BabyBluetoothOSDemo
- 本项目和示例程序是使用ios 8.3开发,使用者可以自行降版本,但必须大于6.0
# 后期更新
- 优化babyBluetooch的子类类名
- 增加对Carthage Install的支持
- swift版本开发
已经更新的版本说明,请在wiki中查看
# 蓝牙学习资源
> 温馨提示:零基础做蓝牙开发很困难,所以就算使用babybluetooth降低了代码量,仍然任很有必要花上几天时间把蓝牙的基础概念弄明白后才开始动手~
- [ios蓝牙开发(一)蓝牙相关基础知识](http://liuyanwei.jumppo.com/2015/07/17/ios-BLE-1.html)
- [ios蓝牙开发(二)蓝牙中心模式的ios代码实现](http://liuyanwei.jumppo.com/2015/08/14/ios-BLE-2.html)
- [ios蓝牙开发(三)app作为外设被连接的实现](http://liuyanwei.jumppo.com/2015/09/07/ios-BLE-3.html)
- [ios蓝牙开发(四)BabyBluetooth蓝牙库介绍](http://liuyanwei.jumppo.com/2015/09/11/ios-BLE-4.html)
- 暂未完成-ios蓝牙开发(五)BabyBluetooth实现原理
- 待定...
- [官方CoreBuetooth支持页](https://developer.apple.com/bluetooth)
- [Bluetooth Accessory Design Guidelines for Apple Products](https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf)
qq交流群4: 313084771
qq交流群3:530142592(满)
qq交流群2:168756967(满)
qq交流群1:426603940(满)
# 期待
- 蓝牙库写起来很辛苦,不要忘记点击右上角小星星star和[follow](https://github.com/coolnameismy)支持一下~
- 如果在使用过程中遇到BUG,或发现功能不够用,希望你能Issues我,谢谢
- 期待大家也能一起为BabyBluetooth输出代码,这里我只是给BabyBluetooth开了个头,他可以增加和优化的地方还是非常多。也期待和大家在Pull Requests一起学习,交流,成长。
PODS: PODS:
- Alamofire (4.9.1) - Alamofire (4.9.1)
- BabyBluetooth (0.7.0)
- CryptoSwift (1.3.0) - CryptoSwift (1.3.0)
- Dollar (9.0.0) - Dollar (9.0.0)
- ESTabBarController-swift (2.8.0) - ESTabBarController-swift (2.8.0)
...@@ -17,6 +18,7 @@ PODS: ...@@ -17,6 +18,7 @@ PODS:
- Realm (= 4.4.0) - Realm (= 4.4.0)
- SkeletonView (1.8.7) - SkeletonView (1.8.7)
- SnapKit (4.2.0) - SnapKit (4.2.0)
- SVProgressHUD (2.2.5)
- SwiftDate (6.1.0) - SwiftDate (6.1.0)
- SwifterSwift (5.1.0): - SwifterSwift (5.1.0):
- SwifterSwift/AppKit (= 5.1.0) - SwifterSwift/AppKit (= 5.1.0)
...@@ -45,6 +47,7 @@ PODS: ...@@ -45,6 +47,7 @@ PODS:
DEPENDENCIES: DEPENDENCIES:
- Alamofire - Alamofire
- BabyBluetooth
- CryptoSwift - CryptoSwift
- Dollar - Dollar
- ESTabBarController-swift - ESTabBarController-swift
...@@ -58,6 +61,7 @@ DEPENDENCIES: ...@@ -58,6 +61,7 @@ DEPENDENCIES:
- RealmSwift - RealmSwift
- SkeletonView - SkeletonView
- SnapKit - SnapKit
- SVProgressHUD
- SwiftDate - SwiftDate
- SwifterSwift - SwifterSwift
- SwiftyJSON - SwiftyJSON
...@@ -67,6 +71,7 @@ DEPENDENCIES: ...@@ -67,6 +71,7 @@ DEPENDENCIES:
SPEC REPOS: SPEC REPOS:
trunk: trunk:
- Alamofire - Alamofire
- BabyBluetooth
- CryptoSwift - CryptoSwift
- Dollar - Dollar
- ESTabBarController-swift - ESTabBarController-swift
...@@ -81,6 +86,7 @@ SPEC REPOS: ...@@ -81,6 +86,7 @@ SPEC REPOS:
- RealmSwift - RealmSwift
- SkeletonView - SkeletonView
- SnapKit - SnapKit
- SVProgressHUD
- SwiftDate - SwiftDate
- SwifterSwift - SwifterSwift
- SwiftyJSON - SwiftyJSON
...@@ -89,6 +95,7 @@ SPEC REPOS: ...@@ -89,6 +95,7 @@ SPEC REPOS:
SPEC CHECKSUMS: SPEC CHECKSUMS:
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18 Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
BabyBluetooth: d50758aecf24d4a0ab9271d69f0f116d6bee51c9
CryptoSwift: 1283821600233bdbeb96d7b389c3288c3bf77211 CryptoSwift: 1283821600233bdbeb96d7b389c3288c3bf77211
Dollar: 2fc9bdeeb2d3ae1f251461803240d5c93829ee0c Dollar: 2fc9bdeeb2d3ae1f251461803240d5c93829ee0c
ESTabBarController-swift: 05593a6ad64700b03c0eb60ff625916370aa4136 ESTabBarController-swift: 05593a6ad64700b03c0eb60ff625916370aa4136
...@@ -103,12 +110,13 @@ SPEC CHECKSUMS: ...@@ -103,12 +110,13 @@ SPEC CHECKSUMS:
RealmSwift: 33656a42bd300959a081fc13347376bc478071af RealmSwift: 33656a42bd300959a081fc13347376bc478071af
SkeletonView: ba5370f41280b2f0a76918bb143c1294232bb4f4 SkeletonView: ba5370f41280b2f0a76918bb143c1294232bb4f4
SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a SnapKit: fe8a619752f3f27075cc9a90244d75c6c3f27e2a
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftDate: fa2bb3962056bb44047b4b85a30044e5eae30b03 SwiftDate: fa2bb3962056bb44047b4b85a30044e5eae30b03
SwifterSwift: a9e8e144832638c2850b43da5feaf9598c6ad65b SwifterSwift: a9e8e144832638c2850b43da5feaf9598c6ad65b
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7 SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7
ViewAnimator: 5af1c6f3b310f012bf081259c43717aa54fbae73 ViewAnimator: 5af1c6f3b310f012bf081259c43717aa54fbae73
WYAutoLayout: 3cb136ddc2efa9faaecf15876e6a9b2a6fd7c6cb WYAutoLayout: 3cb136ddc2efa9faaecf15876e6a9b2a6fd7c6cb
PODFILE CHECKSUM: f7cea575720bdb85bdc196fb0c179b4966897e6e PODFILE CHECKSUM: 5362542ba7b343b78bf3e0ee7359bad79d3db6ae
COCOAPODS: 1.9.1 COCOAPODS: 1.9.1
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "25A41AE5E52F6C0CE6354B9305FD89EE"
BuildableName = "BabyBluetooth.framework"
BlueprintName = "BabyBluetooth"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FD999FE212F29E29DEEA0A85E1DC4D4E"
BuildableName = "LGButton.framework"
BlueprintName = "LGButton"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1C8D67D8B72D6BA42CCEDB648537A340"
BuildableName = "SVProgressHUD.framework"
BlueprintName = "SVProgressHUD"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "930887923DC0E8AC2A3589A7987F2BDD"
BuildableName = "WYAutoLayout.framework"
BlueprintName = "WYAutoLayout"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
</dict> </dict>
<key>BabyBluetooth.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>CryptoSwift.xcscheme</key> <key>CryptoSwift.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
...@@ -39,6 +44,11 @@ ...@@ -39,6 +44,11 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
</dict> </dict>
<key>LGButton.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>MJRefresh.xcscheme</key> <key>MJRefresh.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
...@@ -69,6 +79,11 @@ ...@@ -69,6 +79,11 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
</dict> </dict>
<key>SVProgressHUD.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>SkeletonView.xcscheme</key> <key>SkeletonView.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
...@@ -99,6 +114,11 @@ ...@@ -99,6 +114,11 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
</dict> </dict>
<key>WYAutoLayout.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
<dict/> <dict/>
......
MIT License
Copyright (c) 2011-2018 Sam Vermette, Tobias Tiemerding and contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# SVProgressHUD
![Pod Version](https://img.shields.io/cocoapods/v/SVProgressHUD.svg?style=flat)
![Pod Platform](https://img.shields.io/cocoapods/p/SVProgressHUD.svg?style=flat)
![Pod License](https://img.shields.io/cocoapods/l/SVProgressHUD.svg?style=flat)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-green.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods compatible](https://img.shields.io/badge/CocoaPods-compatible-green.svg?style=flat)](https://cocoapods.org)
`SVProgressHUD` is a clean and easy-to-use HUD meant to display the progress of an ongoing task on iOS and tvOS.
![SVProgressHUD](http://f.cl.ly/items/2G1F1Z0M0k0h2U3V1p39/SVProgressHUD.gif)
## Demo
Try `SVProgressHUD` on [Appetize.io](https://appetize.io/app/p8r2cvy8kq74x7q7tjqf5gyatr).
## Installation
### From CocoaPods
[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like `SVProgressHUD` in your projects. First, add the following line to your [Podfile](http://guides.cocoapods.org/using/using-cocoapods.html):
```ruby
pod 'SVProgressHUD'
```
If you want to use the latest features of `SVProgressHUD` use normal external source dependencies.
```ruby
pod 'SVProgressHUD', :git => 'https://github.com/SVProgressHUD/SVProgressHUD.git'
```
This pulls from the `master` branch directly.
Second, install `SVProgressHUD` into your project:
```ruby
pod install
```
### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate `SVProgressHUD` into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl
github "SVProgressHUD/SVProgressHUD"
```
Run `carthage bootstrap` to build the framework in your repository's Carthage directory. You can then include it in your target's `carthage copy-frameworks` build phase. For more information on this, please see [Carthage's documentation](https://github.com/carthage/carthage#if-youre-building-for-ios-tvos-or-watchos).
### Manually
* Drag the `SVProgressHUD/SVProgressHUD` folder into your project.
* Take care that `SVProgressHUD.bundle` is added to `Targets->Build Phases->Copy Bundle Resources`.
* Add the **QuartzCore** framework to your project.
## Swift
Even though `SVProgressHUD` is written in Objective-C, it can be used in Swift with no hassle. If you use [CocoaPods](http://cocoapods.org) add the following line to your [Podfile](http://guides.cocoapods.org/using/using-cocoapods.html):
```ruby
use_frameworks!
```
If you added `SVProgressHUD` manually, just add a [bridging header](https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html) file to your project with the `SVProgressHUD` header included.
## Usage
(see sample Xcode project in `/Demo`)
`SVProgressHUD` is created as a singleton (i.e. it doesn't need to be explicitly allocated and instantiated; you directly call `[SVProgressHUD method]`).
**Use `SVProgressHUD` wisely! Only use it if you absolutely need to perform a task before taking the user forward. Bad use case examples: pull to refresh, infinite scrolling, sending message.**
Using `SVProgressHUD` in your app will usually look as simple as this (using Grand Central Dispatch):
```objective-c
[SVProgressHUD show];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// time-consuming task
dispatch_async(dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
});
});
```
### Showing the HUD
You can show the status of indeterminate tasks using one of the following:
```objective-c
+ (void)show;
+ (void)showWithStatus:(NSString*)string;
```
If you'd like the HUD to reflect the progress of a task, use one of these:
```objective-c
+ (void)showProgress:(CGFloat)progress;
+ (void)showProgress:(CGFloat)progress status:(NSString*)status;
```
### Dismissing the HUD
The HUD can be dismissed using:
```objective-c
+ (void)dismiss;
+ (void)dismissWithDelay:(NSTimeInterval)delay;
```
If you'd like to stack HUDs, you can balance out every show call using:
```
+ (void)popActivity;
```
The HUD will get dismissed once the popActivity calls will match the number of show calls.
Or show a confirmation glyph before before getting dismissed a little bit later. The display time depends on `minimumDismissTimeInterval` and the length of the given string.
```objective-c
+ (void)showInfoWithStatus:(NSString*)string;
+ (void)showSuccessWithStatus:(NSString*)string;
+ (void)showErrorWithStatus:(NSString*)string;
+ (void)showImage:(UIImage*)image status:(NSString*)string;
```
## Customization
`SVProgressHUD` can be customized via the following methods:
```objective-c
+ (void)setDefaultStyle:(SVProgressHUDStyle)style; // default is SVProgressHUDStyleLight
+ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; // default is SVProgressHUDMaskTypeNone
+ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type; // default is SVProgressHUDAnimationTypeFlat
+ (void)setContainerView:(UIView*)containerView; // default is window level
+ (void)setMinimumSize:(CGSize)minimumSize; // default is CGSizeZero, can be used to avoid resizing
+ (void)setRingThickness:(CGFloat)width; // default is 2 pt
+ (void)setRingRadius:(CGFloat)radius; // default is 18 pt
+ (void)setRingNoTextRadius:(CGFloat)radius; // default is 24 pt
+ (void)setCornerRadius:(CGFloat)cornerRadius; // default is 14 pt
+ (void)setBorderColor:(nonnull UIColor*)color; // default is nil
+ (void)setBorderWidth:(CGFloat)width; // default is 0
+ (void)setFont:(UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
+ (void)setForegroundColor:(UIColor*)color; // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundColor:(UIColor*)color; // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundLayerColor:(UIColor*)color; // default is [UIColor colorWithWhite:0 alpha:0.4], only used for SVProgressHUDMaskTypeCustom
+ (void)setImageViewSize:(CGSize)size; // default is 28x28 pt
+ (void)setShouldTintImages:(BOOL)shouldTintImages; // default is YES
+ (void)setInfoImage:(UIImage*)image; // default is the bundled info image provided by Freepik
+ (void)setSuccessImage:(UIImage*)image; // default is bundled success image from Freepik
+ (void)setErrorImage:(UIImage*)image; // default is bundled error image from Freepik
+ (void)setViewForExtension:(UIView*)view; // default is nil, only used if #define SV_APP_EXTENSIONS is set
+ (void)setGraceTimeInterval:(NSTimeInterval)interval; // default is 0 seconds
+ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval; // default is 5.0 seconds
+ (void)setMaximumDismissTimeInterval:(NSTimeInterval)interval; // default is CGFLOAT_MAX
+ (void)setFadeInAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
+ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
+ (void)setMaxSupportedWindowLevel:(UIWindowLevel)windowLevel; // default is UIWindowLevelNormal
+ (void)setHapticsEnabled:(BOOL)hapticsEnabled; // default is NO
```
Additionally `SVProgressHUD` supports the `UIAppearance` protocol for most of the above methods.
### Hint
As standard `SVProgressHUD` offers two preconfigured styles:
* `SVProgressHUDStyleLight`: White background with black spinner and text
* `SVProgressHUDStyleDark`: Black background with white spinner and text
If you want to use custom colors use `setForegroundColor` and `setBackgroundColor:`. These implicitly set the HUD's style to `SVProgressHUDStyleCustom`.
## Haptic Feedback
For users with newer devices (starting with the iPhone 7), `SVProgressHUD` can automatically trigger haptic feedback depending on which HUD is being displayed. The feedback maps as follows:
* `showSuccessWithStatus:` <-> `UINotificationFeedbackTypeSuccess`
* `showInfoWithStatus:` <-> `UINotificationFeedbackTypeWarning`
* `showErrorWithStatus:` <-> `UINotificationFeedbackTypeError`
To enable this functionality, use `setHapticsEnabled:`.
Users with devices prior to iPhone 7 will have no change in functionality.
## Notifications
`SVProgressHUD` posts four notifications via `NSNotificationCenter` in response to being shown/dismissed:
* `SVProgressHUDWillAppearNotification` when the show animation starts
* `SVProgressHUDDidAppearNotification` when the show animation completes
* `SVProgressHUDWillDisappearNotification` when the dismiss animation starts
* `SVProgressHUDDidDisappearNotification` when the dismiss animation completes
Each notification passes a `userInfo` dictionary holding the HUD's status string (if any), retrievable via `SVProgressHUDStatusUserInfoKey`.
`SVProgressHUD` also posts `SVProgressHUDDidReceiveTouchEventNotification` when users touch on the overall screen or `SVProgressHUDDidTouchDownInsideNotification` when a user touches on the HUD directly. For this notifications `userInfo` is not passed but the object parameter contains the `UIEvent` that related to the touch.
## App Extensions
When using `SVProgressHUD` in an App Extension, `#define SV_APP_EXTENSIONS` to avoid using unavailable APIs. Additionally call `setViewForExtension:` from your extensions view controller with `self.view`.
## Contributing to this project
If you have feature requests or bug reports, feel free to help out by sending pull requests or by [creating new issues](https://github.com/SVProgressHUD/SVProgressHUD/issues/new). Please take a moment to
review the guidelines written by [Nicolas Gallagher](https://github.com/necolas):
* [Bug reports](https://github.com/necolas/issue-guidelines/blob/master/CONTRIBUTING.md#bugs)
* [Feature requests](https://github.com/necolas/issue-guidelines/blob/master/CONTRIBUTING.md#features)
* [Pull requests](https://github.com/necolas/issue-guidelines/blob/master/CONTRIBUTING.md#pull-requests)
## License
`SVProgressHUD` is distributed under the terms and conditions of the [MIT license](https://github.com/SVProgressHUD/SVProgressHUD/blob/master/LICENSE.txt). The success, error and info icons are made by [Freepik](http://www.freepik.com) from [Flaticon](http://www.flaticon.com) and are licensed under [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/).
## Credits
`SVProgressHUD` is brought to you by [Sam Vermette](http://samvermette.com), [Tobias Tiemerding](http://tiemerding.com) and [contributors to the project](https://github.com/SVProgressHUD/SVProgressHUD/contributors). If you're using `SVProgressHUD` in your project, attribution would be very appreciated.
//
// SVIndefiniteAnimatedView.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2014-2018 Guillaume Campagna. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SVIndefiniteAnimatedView : UIView
@property (nonatomic, assign) CGFloat strokeThickness;
@property (nonatomic, assign) CGFloat radius;
@property (nonatomic, strong) UIColor *strokeColor;
@end
//
// SVIndefiniteAnimatedView.m
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2014-2018 Guillaume Campagna. All rights reserved.
//
#import "SVIndefiniteAnimatedView.h"
#import "SVProgressHUD.h"
@interface SVIndefiniteAnimatedView ()
@property (nonatomic, strong) CAShapeLayer *indefiniteAnimatedLayer;
@end
@implementation SVIndefiniteAnimatedView
- (void)willMoveToSuperview:(UIView*)newSuperview {
if (newSuperview) {
[self layoutAnimatedLayer];
} else {
[_indefiniteAnimatedLayer removeFromSuperlayer];
_indefiniteAnimatedLayer = nil;
}
}
- (void)layoutAnimatedLayer {
CALayer *layer = self.indefiniteAnimatedLayer;
[self.layer addSublayer:layer];
CGFloat widthDiff = CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds);
CGFloat heightDiff = CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds);
layer.position = CGPointMake(CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds) / 2 - widthDiff / 2, CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds) / 2 - heightDiff / 2);
}
- (CAShapeLayer*)indefiniteAnimatedLayer {
if(!_indefiniteAnimatedLayer) {
CGPoint arcCenter = CGPointMake(self.radius+self.strokeThickness/2+5, self.radius+self.strokeThickness/2+5);
UIBezierPath* smoothedPath = [UIBezierPath bezierPathWithArcCenter:arcCenter radius:self.radius startAngle:(CGFloat) (M_PI*3/2) endAngle:(CGFloat) (M_PI/2+M_PI*5) clockwise:YES];
_indefiniteAnimatedLayer = [CAShapeLayer layer];
_indefiniteAnimatedLayer.contentsScale = [[UIScreen mainScreen] scale];
_indefiniteAnimatedLayer.frame = CGRectMake(0.0f, 0.0f, arcCenter.x*2, arcCenter.y*2);
_indefiniteAnimatedLayer.fillColor = [UIColor clearColor].CGColor;
_indefiniteAnimatedLayer.strokeColor = self.strokeColor.CGColor;
_indefiniteAnimatedLayer.lineWidth = self.strokeThickness;
_indefiniteAnimatedLayer.lineCap = kCALineCapRound;
_indefiniteAnimatedLayer.lineJoin = kCALineJoinBevel;
_indefiniteAnimatedLayer.path = smoothedPath.CGPath;
CALayer *maskLayer = [CALayer layer];
NSBundle *bundle = [NSBundle bundleForClass:[SVProgressHUD class]];
NSURL *url = [bundle URLForResource:@"SVProgressHUD" withExtension:@"bundle"];
NSBundle *imageBundle = [NSBundle bundleWithURL:url];
NSString *path = [imageBundle pathForResource:@"angle-mask" ofType:@"png"];
maskLayer.contents = (__bridge id)[[UIImage imageWithContentsOfFile:path] CGImage];
maskLayer.frame = _indefiniteAnimatedLayer.bounds;
_indefiniteAnimatedLayer.mask = maskLayer;
NSTimeInterval animationDuration = 1;
CAMediaTimingFunction *linearCurve = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
animation.fromValue = (id) 0;
animation.toValue = @(M_PI*2);
animation.duration = animationDuration;
animation.timingFunction = linearCurve;
animation.removedOnCompletion = NO;
animation.repeatCount = INFINITY;
animation.fillMode = kCAFillModeForwards;
animation.autoreverses = NO;
[_indefiniteAnimatedLayer.mask addAnimation:animation forKey:@"rotate"];
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.duration = animationDuration;
animationGroup.repeatCount = INFINITY;
animationGroup.removedOnCompletion = NO;
animationGroup.timingFunction = linearCurve;
CABasicAnimation *strokeStartAnimation = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
strokeStartAnimation.fromValue = @0.015;
strokeStartAnimation.toValue = @0.515;
CABasicAnimation *strokeEndAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
strokeEndAnimation.fromValue = @0.485;
strokeEndAnimation.toValue = @0.985;
animationGroup.animations = @[strokeStartAnimation, strokeEndAnimation];
[_indefiniteAnimatedLayer addAnimation:animationGroup forKey:@"progress"];
}
return _indefiniteAnimatedLayer;
}
- (void)setFrame:(CGRect)frame {
if(!CGRectEqualToRect(frame, super.frame)) {
[super setFrame:frame];
if(self.superview) {
[self layoutAnimatedLayer];
}
}
}
- (void)setRadius:(CGFloat)radius {
if(radius != _radius) {
_radius = radius;
[_indefiniteAnimatedLayer removeFromSuperlayer];
_indefiniteAnimatedLayer = nil;
if(self.superview) {
[self layoutAnimatedLayer];
}
}
}
- (void)setStrokeColor:(UIColor*)strokeColor {
_strokeColor = strokeColor;
_indefiniteAnimatedLayer.strokeColor = strokeColor.CGColor;
}
- (void)setStrokeThickness:(CGFloat)strokeThickness {
_strokeThickness = strokeThickness;
_indefiniteAnimatedLayer.lineWidth = _strokeThickness;
}
- (CGSize)sizeThatFits:(CGSize)size {
return CGSizeMake((self.radius+self.strokeThickness/2+5)*2, (self.radius+self.strokeThickness/2+5)*2);
}
@end
//
// SVProgressAnimatedView.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2017-2018 Tobias Tiemerding. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SVProgressAnimatedView : UIView
@property (nonatomic, assign) CGFloat radius;
@property (nonatomic, assign) CGFloat strokeThickness;
@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, assign) CGFloat strokeEnd;
@end
//
// SVProgressAnimatedView.m
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2017-2018 Tobias Tiemerding. All rights reserved.
//
#import "SVProgressAnimatedView.h"
@interface SVProgressAnimatedView ()
@property (nonatomic, strong) CAShapeLayer *ringAnimatedLayer;
@end
@implementation SVProgressAnimatedView
- (void)willMoveToSuperview:(UIView*)newSuperview {
if (newSuperview) {
[self layoutAnimatedLayer];
} else {
[_ringAnimatedLayer removeFromSuperlayer];
_ringAnimatedLayer = nil;
}
}
- (void)layoutAnimatedLayer {
CALayer *layer = self.ringAnimatedLayer;
[self.layer addSublayer:layer];
CGFloat widthDiff = CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds);
CGFloat heightDiff = CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds);
layer.position = CGPointMake(CGRectGetWidth(self.bounds) - CGRectGetWidth(layer.bounds) / 2 - widthDiff / 2, CGRectGetHeight(self.bounds) - CGRectGetHeight(layer.bounds) / 2 - heightDiff / 2);
}
- (CAShapeLayer*)ringAnimatedLayer {
if(!_ringAnimatedLayer) {
CGPoint arcCenter = CGPointMake(self.radius+self.strokeThickness/2+5, self.radius+self.strokeThickness/2+5);
UIBezierPath* smoothedPath = [UIBezierPath bezierPathWithArcCenter:arcCenter radius:self.radius startAngle:(CGFloat)-M_PI_2 endAngle:(CGFloat) (M_PI + M_PI_2) clockwise:YES];
_ringAnimatedLayer = [CAShapeLayer layer];
_ringAnimatedLayer.contentsScale = [[UIScreen mainScreen] scale];
_ringAnimatedLayer.frame = CGRectMake(0.0f, 0.0f, arcCenter.x*2, arcCenter.y*2);
_ringAnimatedLayer.fillColor = [UIColor clearColor].CGColor;
_ringAnimatedLayer.strokeColor = self.strokeColor.CGColor;
_ringAnimatedLayer.lineWidth = self.strokeThickness;
_ringAnimatedLayer.lineCap = kCALineCapRound;
_ringAnimatedLayer.lineJoin = kCALineJoinBevel;
_ringAnimatedLayer.path = smoothedPath.CGPath;
}
return _ringAnimatedLayer;
}
- (void)setFrame:(CGRect)frame {
if(!CGRectEqualToRect(frame, super.frame)) {
[super setFrame:frame];
if(self.superview) {
[self layoutAnimatedLayer];
}
}
}
- (void)setRadius:(CGFloat)radius {
if(radius != _radius) {
_radius = radius;
[_ringAnimatedLayer removeFromSuperlayer];
_ringAnimatedLayer = nil;
if(self.superview) {
[self layoutAnimatedLayer];
}
}
}
- (void)setStrokeColor:(UIColor*)strokeColor {
_strokeColor = strokeColor;
_ringAnimatedLayer.strokeColor = strokeColor.CGColor;
}
- (void)setStrokeThickness:(CGFloat)strokeThickness {
_strokeThickness = strokeThickness;
_ringAnimatedLayer.lineWidth = _strokeThickness;
}
- (void)setStrokeEnd:(CGFloat)strokeEnd {
_strokeEnd = strokeEnd;
_ringAnimatedLayer.strokeEnd = _strokeEnd;
}
- (CGSize)sizeThatFits:(CGSize)size {
return CGSizeMake((self.radius+self.strokeThickness/2+5)*2, (self.radius+self.strokeThickness/2+5)*2);
}
@end
//
// SVProgressHUD.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2011-2018 Sam Vermette and contributors. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <AvailabilityMacros.h>
extern NSString * _Nonnull const SVProgressHUDDidReceiveTouchEventNotification;
extern NSString * _Nonnull const SVProgressHUDDidTouchDownInsideNotification;
extern NSString * _Nonnull const SVProgressHUDWillDisappearNotification;
extern NSString * _Nonnull const SVProgressHUDDidDisappearNotification;
extern NSString * _Nonnull const SVProgressHUDWillAppearNotification;
extern NSString * _Nonnull const SVProgressHUDDidAppearNotification;
extern NSString * _Nonnull const SVProgressHUDStatusUserInfoKey;
typedef NS_ENUM(NSInteger, SVProgressHUDStyle) {
SVProgressHUDStyleLight, // default style, white HUD with black text, HUD background will be blurred
SVProgressHUDStyleDark, // black HUD and white text, HUD background will be blurred
SVProgressHUDStyleCustom // uses the fore- and background color properties
};
typedef NS_ENUM(NSUInteger, SVProgressHUDMaskType) {
SVProgressHUDMaskTypeNone = 1, // default mask type, allow user interactions while HUD is displayed
SVProgressHUDMaskTypeClear, // don't allow user interactions with background objects
SVProgressHUDMaskTypeBlack, // don't allow user interactions with background objects and dim the UI in the back of the HUD (as seen in iOS 7 and above)
SVProgressHUDMaskTypeGradient, // don't allow user interactions with background objects and dim the UI with a a-la UIAlertView background gradient (as seen in iOS 6)
SVProgressHUDMaskTypeCustom // don't allow user interactions with background objects and dim the UI in the back of the HUD with a custom color
};
typedef NS_ENUM(NSUInteger, SVProgressHUDAnimationType) {
SVProgressHUDAnimationTypeFlat, // default animation type, custom flat animation (indefinite animated ring)
SVProgressHUDAnimationTypeNative // iOS native UIActivityIndicatorView
};
typedef void (^SVProgressHUDShowCompletion)(void);
typedef void (^SVProgressHUDDismissCompletion)(void);
@interface SVProgressHUD : UIView
#pragma mark - Customization
@property (assign, nonatomic) SVProgressHUDStyle defaultStyle UI_APPEARANCE_SELECTOR; // default is SVProgressHUDStyleLight
@property (assign, nonatomic) SVProgressHUDMaskType defaultMaskType UI_APPEARANCE_SELECTOR; // default is SVProgressHUDMaskTypeNone
@property (assign, nonatomic) SVProgressHUDAnimationType defaultAnimationType UI_APPEARANCE_SELECTOR; // default is SVProgressHUDAnimationTypeFlat
@property (strong, nonatomic, nullable) UIView *containerView; // if nil then use default window level
@property (assign, nonatomic) CGSize minimumSize UI_APPEARANCE_SELECTOR; // default is CGSizeZero, can be used to avoid resizing for a larger message
@property (assign, nonatomic) CGFloat ringThickness UI_APPEARANCE_SELECTOR; // default is 2 pt
@property (assign, nonatomic) CGFloat ringRadius UI_APPEARANCE_SELECTOR; // default is 18 pt
@property (assign, nonatomic) CGFloat ringNoTextRadius UI_APPEARANCE_SELECTOR; // default is 24 pt
@property (assign, nonatomic) CGFloat cornerRadius UI_APPEARANCE_SELECTOR; // default is 14 pt
@property (strong, nonatomic, nonnull) UIFont *font UI_APPEARANCE_SELECTOR; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
@property (strong, nonatomic, nonnull) UIColor *backgroundColor UI_APPEARANCE_SELECTOR; // default is [UIColor whiteColor]
@property (strong, nonatomic, nonnull) UIColor *foregroundColor UI_APPEARANCE_SELECTOR; // default is [UIColor blackColor]
@property (strong, nonatomic, nonnull) UIColor *backgroundLayerColor UI_APPEARANCE_SELECTOR;// default is [UIColor colorWithWhite:0 alpha:0.4]
@property (assign, nonatomic) CGSize imageViewSize UI_APPEARANCE_SELECTOR; // default is 28x28 pt
@property (assign, nonatomic) BOOL shouldTintImages UI_APPEARANCE_SELECTOR; // default is YES
@property (strong, nonatomic, nonnull) UIImage *infoImage UI_APPEARANCE_SELECTOR; // default is the bundled info image provided by Freepik
@property (strong, nonatomic, nonnull) UIImage *successImage UI_APPEARANCE_SELECTOR; // default is the bundled success image provided by Freepik
@property (strong, nonatomic, nonnull) UIImage *errorImage UI_APPEARANCE_SELECTOR; // default is the bundled error image provided by Freepik
@property (strong, nonatomic, nonnull) UIView *viewForExtension UI_APPEARANCE_SELECTOR; // default is nil, only used if #define SV_APP_EXTENSIONS is set
@property (assign, nonatomic) NSTimeInterval graceTimeInterval; // default is 0 seconds
@property (assign, nonatomic) NSTimeInterval minimumDismissTimeInterval; // default is 5.0 seconds
@property (assign, nonatomic) NSTimeInterval maximumDismissTimeInterval; // default is CGFLOAT_MAX
@property (assign, nonatomic) UIOffset offsetFromCenter UI_APPEARANCE_SELECTOR; // default is 0, 0
@property (assign, nonatomic) NSTimeInterval fadeInAnimationDuration UI_APPEARANCE_SELECTOR; // default is 0.15
@property (assign, nonatomic) NSTimeInterval fadeOutAnimationDuration UI_APPEARANCE_SELECTOR; // default is 0.15
@property (assign, nonatomic) UIWindowLevel maxSupportedWindowLevel; // default is UIWindowLevelNormal
@property (assign, nonatomic) BOOL hapticsEnabled; // default is NO
+ (void)setDefaultStyle:(SVProgressHUDStyle)style; // default is SVProgressHUDStyleLight
+ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType; // default is SVProgressHUDMaskTypeNone
+ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type; // default is SVProgressHUDAnimationTypeFlat
+ (void)setContainerView:(nullable UIView*)containerView; // default is window level
+ (void)setMinimumSize:(CGSize)minimumSize; // default is CGSizeZero, can be used to avoid resizing for a larger message
+ (void)setRingThickness:(CGFloat)ringThickness; // default is 2 pt
+ (void)setRingRadius:(CGFloat)radius; // default is 18 pt
+ (void)setRingNoTextRadius:(CGFloat)radius; // default is 24 pt
+ (void)setCornerRadius:(CGFloat)cornerRadius; // default is 14 pt
+ (void)setBorderColor:(nonnull UIColor*)color; // default is nil
+ (void)setBorderWidth:(CGFloat)width; // default is 0
+ (void)setFont:(nonnull UIFont*)font; // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
+ (void)setForegroundColor:(nonnull UIColor*)color; // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundColor:(nonnull UIColor*)color; // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundLayerColor:(nonnull UIColor*)color; // default is [UIColor colorWithWhite:0 alpha:0.5], only used for SVProgressHUDMaskTypeCustom
+ (void)setImageViewSize:(CGSize)size; // default is 28x28 pt
+ (void)setShouldTintImages:(BOOL)shouldTintImages; // default is YES
+ (void)setInfoImage:(nonnull UIImage*)image; // default is the bundled info image provided by Freepik
+ (void)setSuccessImage:(nonnull UIImage*)image; // default is the bundled success image provided by Freepik
+ (void)setErrorImage:(nonnull UIImage*)image; // default is the bundled error image provided by Freepik
+ (void)setViewForExtension:(nonnull UIView*)view; // default is nil, only used if #define SV_APP_EXTENSIONS is set
+ (void)setGraceTimeInterval:(NSTimeInterval)interval; // default is 0 seconds
+ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval; // default is 5.0 seconds
+ (void)setMaximumDismissTimeInterval:(NSTimeInterval)interval; // default is infinite
+ (void)setFadeInAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
+ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration; // default is 0.15 seconds
+ (void)setMaxSupportedWindowLevel:(UIWindowLevel)windowLevel; // default is UIWindowLevelNormal
+ (void)setHapticsEnabled:(BOOL)hapticsEnabled; // default is NO
#pragma mark - Show Methods
+ (void)show;
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use show and setDefaultMaskType: instead.")));
+ (void)showWithStatus:(nullable NSString*)status;
+ (void)showWithStatus:(nullable NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showWithStatus: and setDefaultMaskType: instead.")));
+ (void)showProgress:(float)progress;
+ (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showProgress: and setDefaultMaskType: instead.")));
+ (void)showProgress:(float)progress status:(nullable NSString*)status;
+ (void)showProgress:(float)progress status:(nullable NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showProgress:status: and setDefaultMaskType: instead.")));
+ (void)setStatus:(nullable NSString*)status; // change the HUD loading status while it's showing
// stops the activity indicator, shows a glyph + status, and dismisses the HUD a little bit later
+ (void)showInfoWithStatus:(nullable NSString*)status;
+ (void)showInfoWithStatus:(nullable NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showInfoWithStatus: and setDefaultMaskType: instead.")));
+ (void)showSuccessWithStatus:(nullable NSString*)status;
+ (void)showSuccessWithStatus:(nullable NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showSuccessWithStatus: and setDefaultMaskType: instead.")));
+ (void)showErrorWithStatus:(nullable NSString*)status;
+ (void)showErrorWithStatus:(nullable NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showErrorWithStatus: and setDefaultMaskType: instead.")));
// shows a image + status, use white PNGs with the imageViewSize (default is 28x28 pt)
+ (void)showImage:(nonnull UIImage*)image status:(nullable NSString*)status;
+ (void)showImage:(nonnull UIImage*)image status:(nullable NSString*)status maskType:(SVProgressHUDMaskType)maskType __attribute__((deprecated("Use showImage:status: and setDefaultMaskType: instead.")));
+ (void)setOffsetFromCenter:(UIOffset)offset;
+ (void)resetOffsetFromCenter;
+ (void)popActivity; // decrease activity count, if activity count == 0 the HUD is dismissed
+ (void)dismiss;
+ (void)dismissWithCompletion:(nullable SVProgressHUDDismissCompletion)completion;
+ (void)dismissWithDelay:(NSTimeInterval)delay;
+ (void)dismissWithDelay:(NSTimeInterval)delay completion:(nullable SVProgressHUDDismissCompletion)completion;
+ (BOOL)isVisible;
+ (NSTimeInterval)displayDurationForString:(nullable NSString*)string;
@end
//
// SVProgressHUD.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2011-2018 Sam Vermette and contributors. All rights reserved.
//
#if !__has_feature(objc_arc)
#error SVProgressHUD is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif
#import "SVProgressHUD.h"
#import "SVIndefiniteAnimatedView.h"
#import "SVProgressAnimatedView.h"
#import "SVRadialGradientLayer.h"
NSString * const SVProgressHUDDidReceiveTouchEventNotification = @"SVProgressHUDDidReceiveTouchEventNotification";
NSString * const SVProgressHUDDidTouchDownInsideNotification = @"SVProgressHUDDidTouchDownInsideNotification";
NSString * const SVProgressHUDWillDisappearNotification = @"SVProgressHUDWillDisappearNotification";
NSString * const SVProgressHUDDidDisappearNotification = @"SVProgressHUDDidDisappearNotification";
NSString * const SVProgressHUDWillAppearNotification = @"SVProgressHUDWillAppearNotification";
NSString * const SVProgressHUDDidAppearNotification = @"SVProgressHUDDidAppearNotification";
NSString * const SVProgressHUDStatusUserInfoKey = @"SVProgressHUDStatusUserInfoKey";
static const CGFloat SVProgressHUDParallaxDepthPoints = 10.0f;
static const CGFloat SVProgressHUDUndefinedProgress = -1;
static const CGFloat SVProgressHUDDefaultAnimationDuration = 0.15f;
static const CGFloat SVProgressHUDVerticalSpacing = 12.0f;
static const CGFloat SVProgressHUDHorizontalSpacing = 12.0f;
static const CGFloat SVProgressHUDLabelSpacing = 8.0f;
@interface SVProgressHUD ()
@property (nonatomic, strong) NSTimer *graceTimer;
@property (nonatomic, strong) NSTimer *fadeOutTimer;
@property (nonatomic, strong) UIControl *controlView;
@property (nonatomic, strong) UIView *backgroundView;
@property (nonatomic, strong) SVRadialGradientLayer *backgroundRadialGradientLayer;
@property (nonatomic, strong) UIVisualEffectView *hudView;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIView *indefiniteAnimatedView;
@property (nonatomic, strong) SVProgressAnimatedView *ringView;
@property (nonatomic, strong) SVProgressAnimatedView *backgroundRingView;
@property (nonatomic, readwrite) CGFloat progress;
@property (nonatomic, readwrite) NSUInteger activityCount;
@property (nonatomic, readonly) CGFloat visibleKeyboardHeight;
@property (nonatomic, readonly) UIWindow *frontWindow;
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
@property (nonatomic, strong) UINotificationFeedbackGenerator *hapticGenerator NS_AVAILABLE_IOS(10_0);
#endif
@end
@implementation SVProgressHUD {
BOOL _isInitializing;
}
+ (SVProgressHUD*)sharedView {
static dispatch_once_t once;
static SVProgressHUD *sharedView;
#if !defined(SV_APP_EXTENSIONS)
dispatch_once(&once, ^{ sharedView = [[self alloc] initWithFrame:[[[UIApplication sharedApplication] delegate] window].bounds]; });
#else
dispatch_once(&once, ^{ sharedView = [[self alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; });
#endif
return sharedView;
}
#pragma mark - Setters
+ (void)setStatus:(NSString*)status {
[[self sharedView] setStatus:status];
}
+ (void)setDefaultStyle:(SVProgressHUDStyle)style {
[self sharedView].defaultStyle = style;
}
+ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType {
[self sharedView].defaultMaskType = maskType;
}
+ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type {
[self sharedView].defaultAnimationType = type;
}
+ (void)setContainerView:(nullable UIView*)containerView {
[self sharedView].containerView = containerView;
}
+ (void)setMinimumSize:(CGSize)minimumSize {
[self sharedView].minimumSize = minimumSize;
}
+ (void)setRingThickness:(CGFloat)ringThickness {
[self sharedView].ringThickness = ringThickness;
}
+ (void)setRingRadius:(CGFloat)radius {
[self sharedView].ringRadius = radius;
}
+ (void)setRingNoTextRadius:(CGFloat)radius {
[self sharedView].ringNoTextRadius = radius;
}
+ (void)setCornerRadius:(CGFloat)cornerRadius {
[self sharedView].cornerRadius = cornerRadius;
}
+ (void)setBorderColor:(nonnull UIColor*)color {
[self sharedView].hudView.layer.borderColor = color.CGColor;
}
+ (void)setBorderWidth:(CGFloat)width {
[self sharedView].hudView.layer.borderWidth = width;
}
+ (void)setFont:(UIFont*)font {
[self sharedView].font = font;
}
+ (void)setForegroundColor:(UIColor*)color {
[self sharedView].foregroundColor = color;
[self setDefaultStyle:SVProgressHUDStyleCustom];
}
+ (void)setBackgroundColor:(UIColor*)color {
[self sharedView].backgroundColor = color;
[self setDefaultStyle:SVProgressHUDStyleCustom];
}
+ (void)setBackgroundLayerColor:(UIColor*)color {
[self sharedView].backgroundLayerColor = color;
}
+ (void)setImageViewSize:(CGSize)size {
[self sharedView].imageViewSize = size;
}
+ (void)setShouldTintImages:(BOOL)shouldTintImages {
[self sharedView].shouldTintImages = shouldTintImages;
}
+ (void)setInfoImage:(UIImage*)image {
[self sharedView].infoImage = image;
}
+ (void)setSuccessImage:(UIImage*)image {
[self sharedView].successImage = image;
}
+ (void)setErrorImage:(UIImage*)image {
[self sharedView].errorImage = image;
}
+ (void)setViewForExtension:(UIView*)view {
[self sharedView].viewForExtension = view;
}
+ (void)setGraceTimeInterval:(NSTimeInterval)interval {
[self sharedView].graceTimeInterval = interval;
}
+ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval {
[self sharedView].minimumDismissTimeInterval = interval;
}
+ (void)setMaximumDismissTimeInterval:(NSTimeInterval)interval {
[self sharedView].maximumDismissTimeInterval = interval;
}
+ (void)setFadeInAnimationDuration:(NSTimeInterval)duration {
[self sharedView].fadeInAnimationDuration = duration;
}
+ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration {
[self sharedView].fadeOutAnimationDuration = duration;
}
+ (void)setMaxSupportedWindowLevel:(UIWindowLevel)windowLevel {
[self sharedView].maxSupportedWindowLevel = windowLevel;
}
+ (void)setHapticsEnabled:(BOOL)hapticsEnabled {
[self sharedView].hapticsEnabled = hapticsEnabled;
}
#pragma mark - Show Methods
+ (void)show {
[self showWithStatus:nil];
}
+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self show];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showWithStatus:(NSString*)status {
[self showProgress:SVProgressHUDUndefinedProgress status:status];
}
+ (void)showWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showWithStatus:status];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showProgress:(float)progress {
[self showProgress:progress status:nil];
}
+ (void)showProgress:(float)progress maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showProgress:progress];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showProgress:(float)progress status:(NSString*)status {
[[self sharedView] showProgress:progress status:status];
}
+ (void)showProgress:(float)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showProgress:progress status:status];
[self setDefaultMaskType:existingMaskType];
}
#pragma mark - Show, then automatically dismiss methods
+ (void)showInfoWithStatus:(NSString*)status {
[self showImage:[self sharedView].infoImage status:status];
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
if (@available(iOS 10.0, *)) {
dispatch_async(dispatch_get_main_queue(), ^{
[[self sharedView].hapticGenerator notificationOccurred:UINotificationFeedbackTypeWarning];
});
}
#endif
}
+ (void)showInfoWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showInfoWithStatus:status];
[self setDefaultMaskType:existingMaskType];
}
+ (void)showSuccessWithStatus:(NSString*)status {
[self showImage:[self sharedView].successImage status:status];
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
if (@available(iOS 10, *)) {
dispatch_async(dispatch_get_main_queue(), ^{
[[self sharedView].hapticGenerator notificationOccurred:UINotificationFeedbackTypeSuccess];
});
}
#endif
}
+ (void)showSuccessWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showSuccessWithStatus:status];
[self setDefaultMaskType:existingMaskType];
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
if (@available(iOS 10.0, *)) {
dispatch_async(dispatch_get_main_queue(), ^{
[[self sharedView].hapticGenerator notificationOccurred:UINotificationFeedbackTypeSuccess];
});
}
#endif
}
+ (void)showErrorWithStatus:(NSString*)status {
[self showImage:[self sharedView].errorImage status:status];
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
if (@available(iOS 10.0, *)) {
dispatch_async(dispatch_get_main_queue(), ^{
[[self sharedView].hapticGenerator notificationOccurred:UINotificationFeedbackTypeError];
});
}
#endif
}
+ (void)showErrorWithStatus:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showErrorWithStatus:status];
[self setDefaultMaskType:existingMaskType];
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
if (@available(iOS 10.0, *)) {
dispatch_async(dispatch_get_main_queue(), ^{
[[self sharedView].hapticGenerator notificationOccurred:UINotificationFeedbackTypeError];
});
}
#endif
}
+ (void)showImage:(UIImage*)image status:(NSString*)status {
NSTimeInterval displayInterval = [self displayDurationForString:status];
[[self sharedView] showImage:image status:status duration:displayInterval];
}
+ (void)showImage:(UIImage*)image status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType {
SVProgressHUDMaskType existingMaskType = [self sharedView].defaultMaskType;
[self setDefaultMaskType:maskType];
[self showImage:image status:status];
[self setDefaultMaskType:existingMaskType];
}
#pragma mark - Dismiss Methods
+ (void)popActivity {
if([self sharedView].activityCount > 0) {
[self sharedView].activityCount--;
}
if([self sharedView].activityCount == 0) {
[[self sharedView] dismiss];
}
}
+ (void)dismiss {
[self dismissWithDelay:0.0 completion:nil];
}
+ (void)dismissWithCompletion:(SVProgressHUDDismissCompletion)completion {
[self dismissWithDelay:0.0 completion:completion];
}
+ (void)dismissWithDelay:(NSTimeInterval)delay {
[self dismissWithDelay:delay completion:nil];
}
+ (void)dismissWithDelay:(NSTimeInterval)delay completion:(SVProgressHUDDismissCompletion)completion {
[[self sharedView] dismissWithDelay:delay completion:completion];
}
#pragma mark - Offset
+ (void)setOffsetFromCenter:(UIOffset)offset {
[self sharedView].offsetFromCenter = offset;
}
+ (void)resetOffsetFromCenter {
[self setOffsetFromCenter:UIOffsetZero];
}
#pragma mark - Instance Methods
- (instancetype)initWithFrame:(CGRect)frame {
if((self = [super initWithFrame:frame])) {
_isInitializing = YES;
self.userInteractionEnabled = NO;
self.activityCount = 0;
self.backgroundView.alpha = 0.0f;
self.imageView.alpha = 0.0f;
self.statusLabel.alpha = 0.0f;
self.indefiniteAnimatedView.alpha = 0.0f;
self.ringView.alpha = self.backgroundRingView.alpha = 0.0f;
_backgroundColor = [UIColor whiteColor];
_foregroundColor = [UIColor blackColor];
_backgroundLayerColor = [UIColor colorWithWhite:0 alpha:0.4];
// Set default values
_defaultMaskType = SVProgressHUDMaskTypeNone;
_defaultStyle = SVProgressHUDStyleLight;
_defaultAnimationType = SVProgressHUDAnimationTypeFlat;
_minimumSize = CGSizeZero;
_font = [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
_imageViewSize = CGSizeMake(28.0f, 28.0f);
_shouldTintImages = YES;
NSBundle *bundle = [NSBundle bundleForClass:[SVProgressHUD class]];
NSURL *url = [bundle URLForResource:@"SVProgressHUD" withExtension:@"bundle"];
NSBundle *imageBundle = [NSBundle bundleWithURL:url];
_infoImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"info" ofType:@"png"]];
_successImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"success" ofType:@"png"]];
_errorImage = [UIImage imageWithContentsOfFile:[imageBundle pathForResource:@"error" ofType:@"png"]];
_ringThickness = 2.0f;
_ringRadius = 18.0f;
_ringNoTextRadius = 24.0f;
_cornerRadius = 14.0f;
_graceTimeInterval = 0.0f;
_minimumDismissTimeInterval = 5.0;
_maximumDismissTimeInterval = CGFLOAT_MAX;
_fadeInAnimationDuration = SVProgressHUDDefaultAnimationDuration;
_fadeOutAnimationDuration = SVProgressHUDDefaultAnimationDuration;
_maxSupportedWindowLevel = UIWindowLevelNormal;
_hapticsEnabled = NO;
// Accessibility support
self.accessibilityIdentifier = @"SVProgressHUD";
self.isAccessibilityElement = YES;
_isInitializing = NO;
}
return self;
}
- (void)updateHUDFrame {
// Check if an image or progress ring is displayed
BOOL imageUsed = (self.imageView.image) && !(self.imageView.hidden);
BOOL progressUsed = self.imageView.hidden;
// Calculate size of string
CGRect labelRect = CGRectZero;
CGFloat labelHeight = 0.0f;
CGFloat labelWidth = 0.0f;
if(self.statusLabel.text) {
CGSize constraintSize = CGSizeMake(200.0f, 300.0f);
labelRect = [self.statusLabel.text boundingRectWithSize:constraintSize
options:(NSStringDrawingOptions)(NSStringDrawingUsesFontLeading | NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin)
attributes:@{NSFontAttributeName: self.statusLabel.font}
context:NULL];
labelHeight = ceilf(CGRectGetHeight(labelRect));
labelWidth = ceilf(CGRectGetWidth(labelRect));
}
// Calculate hud size based on content
// For the beginning use default values, these
// might get update if string is too large etc.
CGFloat hudWidth;
CGFloat hudHeight;
CGFloat contentWidth = 0.0f;
CGFloat contentHeight = 0.0f;
if(imageUsed || progressUsed) {
contentWidth = CGRectGetWidth(imageUsed ? self.imageView.frame : self.indefiniteAnimatedView.frame);
contentHeight = CGRectGetHeight(imageUsed ? self.imageView.frame : self.indefiniteAnimatedView.frame);
}
// |-spacing-content-spacing-|
hudWidth = SVProgressHUDHorizontalSpacing + MAX(labelWidth, contentWidth) + SVProgressHUDHorizontalSpacing;
// |-spacing-content-(labelSpacing-label-)spacing-|
hudHeight = SVProgressHUDVerticalSpacing + labelHeight + contentHeight + SVProgressHUDVerticalSpacing;
if(self.statusLabel.text && (imageUsed || progressUsed)){
// Add spacing if both content and label are used
hudHeight += SVProgressHUDLabelSpacing;
}
// Update values on subviews
self.hudView.bounds = CGRectMake(0.0f, 0.0f, MAX(self.minimumSize.width, hudWidth), MAX(self.minimumSize.height, hudHeight));
// Animate value update
[CATransaction begin];
[CATransaction setDisableActions:YES];
// Spinner and image view
CGFloat centerY;
if(self.statusLabel.text) {
CGFloat yOffset = MAX(SVProgressHUDVerticalSpacing, (self.minimumSize.height - contentHeight - SVProgressHUDLabelSpacing - labelHeight) / 2.0f);
centerY = yOffset + contentHeight / 2.0f;
} else {
centerY = CGRectGetMidY(self.hudView.bounds);
}
self.indefiniteAnimatedView.center = CGPointMake(CGRectGetMidX(self.hudView.bounds), centerY);
if(self.progress != SVProgressHUDUndefinedProgress) {
self.backgroundRingView.center = self.ringView.center = CGPointMake(CGRectGetMidX(self.hudView.bounds), centerY);
}
self.imageView.center = CGPointMake(CGRectGetMidX(self.hudView.bounds), centerY);
// Label
if(imageUsed || progressUsed) {
centerY = CGRectGetMaxY(imageUsed ? self.imageView.frame : self.indefiniteAnimatedView.frame) + SVProgressHUDLabelSpacing + labelHeight / 2.0f;
} else {
centerY = CGRectGetMidY(self.hudView.bounds);
}
self.statusLabel.frame = labelRect;
self.statusLabel.center = CGPointMake(CGRectGetMidX(self.hudView.bounds), centerY);
[CATransaction commit];
}
#if TARGET_OS_IOS
- (void)updateMotionEffectForOrientation:(UIInterfaceOrientation)orientation {
UIInterpolatingMotionEffectType xMotionEffectType = UIInterfaceOrientationIsPortrait(orientation) ? UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis : UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis;
UIInterpolatingMotionEffectType yMotionEffectType = UIInterfaceOrientationIsPortrait(orientation) ? UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis : UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis;
[self updateMotionEffectForXMotionEffectType:xMotionEffectType yMotionEffectType:yMotionEffectType];
}
#endif
- (void)updateMotionEffectForXMotionEffectType:(UIInterpolatingMotionEffectType)xMotionEffectType yMotionEffectType:(UIInterpolatingMotionEffectType)yMotionEffectType {
UIInterpolatingMotionEffect *effectX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:xMotionEffectType];
effectX.minimumRelativeValue = @(-SVProgressHUDParallaxDepthPoints);
effectX.maximumRelativeValue = @(SVProgressHUDParallaxDepthPoints);
UIInterpolatingMotionEffect *effectY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:yMotionEffectType];
effectY.minimumRelativeValue = @(-SVProgressHUDParallaxDepthPoints);
effectY.maximumRelativeValue = @(SVProgressHUDParallaxDepthPoints);
UIMotionEffectGroup *effectGroup = [UIMotionEffectGroup new];
effectGroup.motionEffects = @[effectX, effectY];
// Clear old motion effect, then add new motion effects
self.hudView.motionEffects = @[];
[self.hudView addMotionEffect:effectGroup];
}
- (void)updateViewHierarchy {
// Add the overlay to the application window if necessary
if(!self.controlView.superview) {
if(self.containerView){
[self.containerView addSubview:self.controlView];
} else {
#if !defined(SV_APP_EXTENSIONS)
[self.frontWindow addSubview:self.controlView];
#else
// If SVProgressHUD is used inside an app extension add it to the given view
if(self.viewForExtension) {
[self.viewForExtension addSubview:self.controlView];
}
#endif
}
} else {
// The HUD is already on screen, but maybe not in front. Therefore
// ensure that overlay will be on top of rootViewController (which may
// be changed during runtime).
[self.controlView.superview bringSubviewToFront:self.controlView];
}
// Add self to the overlay view
if(!self.superview) {
[self.controlView addSubview:self];
}
}
- (void)setStatus:(NSString*)status {
self.statusLabel.text = status;
self.statusLabel.hidden = status.length == 0;
[self updateHUDFrame];
}
- (void)setGraceTimer:(NSTimer*)timer {
if(_graceTimer) {
[_graceTimer invalidate];
_graceTimer = nil;
}
if(timer) {
_graceTimer = timer;
}
}
- (void)setFadeOutTimer:(NSTimer*)timer {
if(_fadeOutTimer) {
[_fadeOutTimer invalidate];
_fadeOutTimer = nil;
}
if(timer) {
_fadeOutTimer = timer;
}
}
#pragma mark - Notifications and their handling
- (void)registerNotifications {
#if TARGET_OS_IOS
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardWillHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardDidHideNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIKeyboardDidShowNotification
object:nil];
#endif
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionHUD:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
- (NSDictionary*)notificationUserInfo {
return (self.statusLabel.text ? @{SVProgressHUDStatusUserInfoKey : self.statusLabel.text} : nil);
}
- (void)positionHUD:(NSNotification*)notification {
CGFloat keyboardHeight = 0.0f;
double animationDuration = 0.0;
#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS
self.frame = [[[UIApplication sharedApplication] delegate] window].bounds;
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation;
#elif !defined(SV_APP_EXTENSIONS) && !TARGET_OS_IOS
self.frame= [UIApplication sharedApplication].keyWindow.bounds;
#else
if (self.viewForExtension) {
self.frame = self.viewForExtension.frame;
} else {
self.frame = UIScreen.mainScreen.bounds;
}
#if TARGET_OS_IOS
UIInterfaceOrientation orientation = CGRectGetWidth(self.frame) > CGRectGetHeight(self.frame) ? UIInterfaceOrientationLandscapeLeft : UIInterfaceOrientationPortrait;
#endif
#endif
#if TARGET_OS_IOS
// Get keyboardHeight in regard to current state
if(notification) {
NSDictionary* keyboardInfo = [notification userInfo];
CGRect keyboardFrame = [keyboardInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
animationDuration = [keyboardInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
if(notification.name == UIKeyboardWillShowNotification || notification.name == UIKeyboardDidShowNotification) {
keyboardHeight = CGRectGetWidth(keyboardFrame);
if(UIInterfaceOrientationIsPortrait(orientation)) {
keyboardHeight = CGRectGetHeight(keyboardFrame);
}
}
} else {
keyboardHeight = self.visibleKeyboardHeight;
}
#endif
// Get the currently active frame of the display (depends on orientation)
CGRect orientationFrame = self.bounds;
#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS
CGRect statusBarFrame = UIApplication.sharedApplication.statusBarFrame;
#else
CGRect statusBarFrame = CGRectZero;
#endif
#if TARGET_OS_IOS
// Update the motion effects in regard to orientation
[self updateMotionEffectForOrientation:orientation];
#else
[self updateMotionEffectForXMotionEffectType:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis yMotionEffectType:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
#endif
// Calculate available height for display
CGFloat activeHeight = CGRectGetHeight(orientationFrame);
if(keyboardHeight > 0) {
activeHeight += CGRectGetHeight(statusBarFrame) * 2;
}
activeHeight -= keyboardHeight;
CGFloat posX = CGRectGetMidX(orientationFrame);
CGFloat posY = floorf(activeHeight*0.45f);
CGFloat rotateAngle = 0.0;
CGPoint newCenter = CGPointMake(posX, posY);
if(notification) {
// Animate update if notification was present
[UIView animateWithDuration:animationDuration
delay:0
options:(UIViewAnimationOptions) (UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState)
animations:^{
[self moveToPoint:newCenter rotateAngle:rotateAngle];
[self.hudView setNeedsDisplay];
} completion:nil];
} else {
[self moveToPoint:newCenter rotateAngle:rotateAngle];
}
}
- (void)moveToPoint:(CGPoint)newCenter rotateAngle:(CGFloat)angle {
self.hudView.transform = CGAffineTransformMakeRotation(angle);
if (self.containerView) {
self.hudView.center = CGPointMake(self.containerView.center.x + self.offsetFromCenter.horizontal, self.containerView.center.y + self.offsetFromCenter.vertical);
} else {
self.hudView.center = CGPointMake(newCenter.x + self.offsetFromCenter.horizontal, newCenter.y + self.offsetFromCenter.vertical);
}
}
#pragma mark - Event handling
- (void)controlViewDidReceiveTouchEvent:(id)sender forEvent:(UIEvent*)event {
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidReceiveTouchEventNotification
object:self
userInfo:[self notificationUserInfo]];
UITouch *touch = event.allTouches.anyObject;
CGPoint touchLocation = [touch locationInView:self];
if(CGRectContainsPoint(self.hudView.frame, touchLocation)) {
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidTouchDownInsideNotification
object:self
userInfo:[self notificationUserInfo]];
}
}
#pragma mark - Master show/dismiss methods
- (void)showProgress:(float)progress status:(NSString*)status {
__weak SVProgressHUD *weakSelf = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf){
if(strongSelf.fadeOutTimer) {
strongSelf.activityCount = 0;
}
// Stop timer
strongSelf.fadeOutTimer = nil;
strongSelf.graceTimer = nil;
// Update / Check view hierarchy to ensure the HUD is visible
[strongSelf updateViewHierarchy];
// Reset imageView and fadeout timer if an image is currently displayed
strongSelf.imageView.hidden = YES;
strongSelf.imageView.image = nil;
// Update text and set progress to the given value
strongSelf.statusLabel.hidden = status.length == 0;
strongSelf.statusLabel.text = status;
strongSelf.progress = progress;
// Choose the "right" indicator depending on the progress
if(progress >= 0) {
// Cancel the indefiniteAnimatedView, then show the ringLayer
[strongSelf cancelIndefiniteAnimatedViewAnimation];
// Add ring to HUD
if(!strongSelf.ringView.superview){
[strongSelf.hudView.contentView addSubview:strongSelf.ringView];
}
if(!strongSelf.backgroundRingView.superview){
[strongSelf.hudView.contentView addSubview:strongSelf.backgroundRingView];
}
// Set progress animated
[CATransaction begin];
[CATransaction setDisableActions:YES];
strongSelf.ringView.strokeEnd = progress;
[CATransaction commit];
// Update the activity count
if(progress == 0) {
strongSelf.activityCount++;
}
} else {
// Cancel the ringLayer animation, then show the indefiniteAnimatedView
[strongSelf cancelRingLayerAnimation];
// Add indefiniteAnimatedView to HUD
[strongSelf.hudView.contentView addSubview:strongSelf.indefiniteAnimatedView];
if([strongSelf.indefiniteAnimatedView respondsToSelector:@selector(startAnimating)]) {
[(id)strongSelf.indefiniteAnimatedView startAnimating];
}
// Update the activity count
strongSelf.activityCount++;
}
// Fade in delayed if a grace time is set
if (self.graceTimeInterval > 0.0 && self.backgroundView.alpha == 0.0f) {
strongSelf.graceTimer = [NSTimer timerWithTimeInterval:self.graceTimeInterval target:strongSelf selector:@selector(fadeIn:) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:strongSelf.graceTimer forMode:NSRunLoopCommonModes];
} else {
[strongSelf fadeIn:nil];
}
// Tell the Haptics Generator to prepare for feedback, which may come soon
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
if (@available(iOS 10.0, *)) {
[strongSelf.hapticGenerator prepare];
}
#endif
}
}];
}
- (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration {
__weak SVProgressHUD *weakSelf = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf){
// Stop timer
strongSelf.fadeOutTimer = nil;
strongSelf.graceTimer = nil;
// Update / Check view hierarchy to ensure the HUD is visible
[strongSelf updateViewHierarchy];
// Reset progress and cancel any running animation
strongSelf.progress = SVProgressHUDUndefinedProgress;
[strongSelf cancelRingLayerAnimation];
[strongSelf cancelIndefiniteAnimatedViewAnimation];
// Update imageView
if (self.shouldTintImages) {
if (image.renderingMode != UIImageRenderingModeAlwaysTemplate) {
strongSelf.imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
strongSelf.imageView.tintColor = strongSelf.foregroundColorForStyle;;
} else {
strongSelf.imageView.image = image;
}
strongSelf.imageView.hidden = NO;
// Update text
strongSelf.statusLabel.hidden = status.length == 0;
strongSelf.statusLabel.text = status;
// Fade in delayed if a grace time is set
// An image will be dismissed automatically. Thus pass the duration as userInfo.
if (self.graceTimeInterval > 0.0 && self.backgroundView.alpha == 0.0f) {
strongSelf.graceTimer = [NSTimer timerWithTimeInterval:self.graceTimeInterval target:strongSelf selector:@selector(fadeIn:) userInfo:@(duration) repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:strongSelf.graceTimer forMode:NSRunLoopCommonModes];
} else {
[strongSelf fadeIn:@(duration)];
}
}
}];
}
- (void)fadeIn:(id)data {
// Update the HUDs frame to the new content and position HUD
[self updateHUDFrame];
[self positionHUD:nil];
// Update accessibility as well as user interaction
if(self.defaultMaskType != SVProgressHUDMaskTypeNone) {
self.controlView.userInteractionEnabled = YES;
self.accessibilityLabel = self.statusLabel.text ?: NSLocalizedString(@"Loading", nil);
self.isAccessibilityElement = YES;
} else {
self.controlView.userInteractionEnabled = NO;
self.hudView.accessibilityLabel = self.statusLabel.text ?: NSLocalizedString(@"Loading", nil);
self.hudView.isAccessibilityElement = YES;
}
// Get duration
id duration = [data isKindOfClass:[NSTimer class]] ? ((NSTimer *)data).userInfo : data;
// Show if not already visible
if(self.backgroundView.alpha != 1.0f) {
// Post notification to inform user
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDWillAppearNotification
object:self
userInfo:[self notificationUserInfo]];
// Shrink HUD to to make a nice appear / pop up animation
self.hudView.transform = self.hudView.transform = CGAffineTransformScale(self.hudView.transform, 1/1.5f, 1/1.5f);
__block void (^animationsBlock)(void) = ^{
// Zoom HUD a little to make a nice appear / pop up animation
self.hudView.transform = CGAffineTransformIdentity;
// Fade in all effects (colors, blur, etc.)
[self fadeInEffects];
};
__block void (^completionBlock)(void) = ^{
// Check if we really achieved to show the HUD (<=> alpha)
// and the change of these values has not been cancelled in between e.g. due to a dismissal
if(self.backgroundView.alpha == 1.0f){
// Register observer <=> we now have to handle orientation changes etc.
[self registerNotifications];
// Post notification to inform user
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidAppearNotification
object:self
userInfo:[self notificationUserInfo]];
// Update accessibility
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.statusLabel.text);
// Dismiss automatically if a duration was passed as userInfo. We start a timer
// which then will call dismiss after the predefined duration
if(duration){
self.fadeOutTimer = [NSTimer timerWithTimeInterval:[(NSNumber *)duration doubleValue] target:self selector:@selector(dismiss) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:self.fadeOutTimer forMode:NSRunLoopCommonModes];
}
}
};
// Animate appearance
if (self.fadeInAnimationDuration > 0) {
// Animate appearance
[UIView animateWithDuration:self.fadeInAnimationDuration
delay:0
options:(UIViewAnimationOptions) (UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseIn | UIViewAnimationOptionBeginFromCurrentState)
animations:^{
animationsBlock();
} completion:^(BOOL finished) {
completionBlock();
}];
} else {
animationsBlock();
completionBlock();
}
// Inform iOS to redraw the view hierarchy
[self setNeedsDisplay];
} else {
// Update accessibility
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.statusLabel.text);
// Dismiss automatically if a duration was passed as userInfo. We start a timer
// which then will call dismiss after the predefined duration
if(duration){
self.fadeOutTimer = [NSTimer timerWithTimeInterval:[(NSNumber *)duration doubleValue] target:self selector:@selector(dismiss) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:self.fadeOutTimer forMode:NSRunLoopCommonModes];
}
}
}
- (void)dismiss {
[self dismissWithDelay:0.0 completion:nil];
}
- (void)dismissWithDelay:(NSTimeInterval)delay completion:(SVProgressHUDDismissCompletion)completion {
__weak SVProgressHUD *weakSelf = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
__strong SVProgressHUD *strongSelf = weakSelf;
if(strongSelf){
// Stop timer
strongSelf.graceTimer = nil;
// Post notification to inform user
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDWillDisappearNotification
object:nil
userInfo:[strongSelf notificationUserInfo]];
// Reset activity count
strongSelf.activityCount = 0;
__block void (^animationsBlock)(void) = ^{
// Shrink HUD a little to make a nice disappear animation
strongSelf.hudView.transform = CGAffineTransformScale(strongSelf.hudView.transform, 1/1.3f, 1/1.3f);
// Fade out all effects (colors, blur, etc.)
[strongSelf fadeOutEffects];
};
__block void (^completionBlock)(void) = ^{
// Check if we really achieved to dismiss the HUD (<=> alpha values are applied)
// and the change of these values has not been cancelled in between e.g. due to a new show
if(self.backgroundView.alpha == 0.0f){
// Clean up view hierarchy (overlays)
[strongSelf.controlView removeFromSuperview];
[strongSelf.backgroundView removeFromSuperview];
[strongSelf.hudView removeFromSuperview];
[strongSelf removeFromSuperview];
// Reset progress and cancel any running animation
strongSelf.progress = SVProgressHUDUndefinedProgress;
[strongSelf cancelRingLayerAnimation];
[strongSelf cancelIndefiniteAnimatedViewAnimation];
// Remove observer <=> we do not have to handle orientation changes etc.
[[NSNotificationCenter defaultCenter] removeObserver:strongSelf];
// Post notification to inform user
[[NSNotificationCenter defaultCenter] postNotificationName:SVProgressHUDDidDisappearNotification
object:strongSelf
userInfo:[strongSelf notificationUserInfo]];
// Tell the rootViewController to update the StatusBar appearance
#if !defined(SV_APP_EXTENSIONS) && TARGET_OS_IOS
UIViewController *rootController = [[UIApplication sharedApplication] keyWindow].rootViewController;
[rootController setNeedsStatusBarAppearanceUpdate];
#endif
// Run an (optional) completionHandler
if (completion) {
completion();
}
}
};
// UIViewAnimationOptionBeginFromCurrentState AND a delay doesn't always work as expected
// When UIViewAnimationOptionBeginFromCurrentState is set, animateWithDuration: evaluates the current
// values to check if an animation is necessary. The evaluation happens at function call time and not
// after the delay => the animation is sometimes skipped. Therefore we delay using dispatch_after.
dispatch_time_t dipatchTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC));
dispatch_after(dipatchTime, dispatch_get_main_queue(), ^{
if (strongSelf.fadeOutAnimationDuration > 0) {
// Animate appearance
[UIView animateWithDuration:strongSelf.fadeOutAnimationDuration
delay:0
options:(UIViewAnimationOptions) (UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveEaseOut | UIViewAnimationOptionBeginFromCurrentState)
animations:^{
animationsBlock();
} completion:^(BOOL finished) {
completionBlock();
}];
} else {
animationsBlock();
completionBlock();
}
});
// Inform iOS to redraw the view hierarchy
[strongSelf setNeedsDisplay];
}
}];
}
#pragma mark - Ring progress animation
- (UIView*)indefiniteAnimatedView {
// Get the correct spinner for defaultAnimationType
if(self.defaultAnimationType == SVProgressHUDAnimationTypeFlat){
// Check if spinner exists and is an object of different class
if(_indefiniteAnimatedView && ![_indefiniteAnimatedView isKindOfClass:[SVIndefiniteAnimatedView class]]){
[_indefiniteAnimatedView removeFromSuperview];
_indefiniteAnimatedView = nil;
}
if(!_indefiniteAnimatedView){
_indefiniteAnimatedView = [[SVIndefiniteAnimatedView alloc] initWithFrame:CGRectZero];
}
// Update styling
SVIndefiniteAnimatedView *indefiniteAnimatedView = (SVIndefiniteAnimatedView*)_indefiniteAnimatedView;
indefiniteAnimatedView.strokeColor = self.foregroundColorForStyle;
indefiniteAnimatedView.strokeThickness = self.ringThickness;
indefiniteAnimatedView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius;
} else {
// Check if spinner exists and is an object of different class
if(_indefiniteAnimatedView && ![_indefiniteAnimatedView isKindOfClass:[UIActivityIndicatorView class]]){
[_indefiniteAnimatedView removeFromSuperview];
_indefiniteAnimatedView = nil;
}
if(!_indefiniteAnimatedView){
_indefiniteAnimatedView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
}
// Update styling
UIActivityIndicatorView *activityIndicatorView = (UIActivityIndicatorView*)_indefiniteAnimatedView;
activityIndicatorView.color = self.foregroundColorForStyle;
}
[_indefiniteAnimatedView sizeToFit];
return _indefiniteAnimatedView;
}
- (SVProgressAnimatedView*)ringView {
if(!_ringView) {
_ringView = [[SVProgressAnimatedView alloc] initWithFrame:CGRectZero];
}
// Update styling
_ringView.strokeColor = self.foregroundColorForStyle;
_ringView.strokeThickness = self.ringThickness;
_ringView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius;
return _ringView;
}
- (SVProgressAnimatedView*)backgroundRingView {
if(!_backgroundRingView) {
_backgroundRingView = [[SVProgressAnimatedView alloc] initWithFrame:CGRectZero];
_backgroundRingView.strokeEnd = 1.0f;
}
// Update styling
_backgroundRingView.strokeColor = [self.foregroundColorForStyle colorWithAlphaComponent:0.1f];
_backgroundRingView.strokeThickness = self.ringThickness;
_backgroundRingView.radius = self.statusLabel.text ? self.ringRadius : self.ringNoTextRadius;
return _backgroundRingView;
}
- (void)cancelRingLayerAnimation {
// Animate value update, stop animation
[CATransaction begin];
[CATransaction setDisableActions:YES];
[self.hudView.layer removeAllAnimations];
self.ringView.strokeEnd = 0.0f;
[CATransaction commit];
// Remove from view
[self.ringView removeFromSuperview];
[self.backgroundRingView removeFromSuperview];
}
- (void)cancelIndefiniteAnimatedViewAnimation {
// Stop animation
if([self.indefiniteAnimatedView respondsToSelector:@selector(stopAnimating)]) {
[(id)self.indefiniteAnimatedView stopAnimating];
}
// Remove from view
[self.indefiniteAnimatedView removeFromSuperview];
}
#pragma mark - Utilities
+ (BOOL)isVisible {
// Checking one alpha value is sufficient as they are all the same
return [self sharedView].backgroundView.alpha > 0.0f;
}
#pragma mark - Getters
+ (NSTimeInterval)displayDurationForString:(NSString*)string {
CGFloat minimum = MAX((CGFloat)string.length * 0.06 + 0.5, [self sharedView].minimumDismissTimeInterval);
return MIN(minimum, [self sharedView].maximumDismissTimeInterval);
}
- (UIColor*)foregroundColorForStyle {
if(self.defaultStyle == SVProgressHUDStyleLight) {
return [UIColor blackColor];
} else if(self.defaultStyle == SVProgressHUDStyleDark) {
return [UIColor whiteColor];
} else {
return self.foregroundColor;
}
}
- (UIColor*)backgroundColorForStyle {
if(self.defaultStyle == SVProgressHUDStyleLight) {
return [UIColor whiteColor];
} else if(self.defaultStyle == SVProgressHUDStyleDark) {
return [UIColor blackColor];
} else {
return self.backgroundColor;
}
}
- (UIControl*)controlView {
if(!_controlView) {
_controlView = [UIControl new];
_controlView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_controlView.backgroundColor = [UIColor clearColor];
_controlView.userInteractionEnabled = YES;
[_controlView addTarget:self action:@selector(controlViewDidReceiveTouchEvent:forEvent:) forControlEvents:UIControlEventTouchDown];
}
// Update frames
#if !defined(SV_APP_EXTENSIONS)
CGRect windowBounds = [[[UIApplication sharedApplication] delegate] window].bounds;
_controlView.frame = windowBounds;
#else
_controlView.frame = [UIScreen mainScreen].bounds;
#endif
return _controlView;
}
-(UIView *)backgroundView {
if(!_backgroundView){
_backgroundView = [UIView new];
_backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
if(!_backgroundView.superview){
[self insertSubview:_backgroundView belowSubview:self.hudView];
}
// Update styling
if(self.defaultMaskType == SVProgressHUDMaskTypeGradient){
if(!_backgroundRadialGradientLayer){
_backgroundRadialGradientLayer = [SVRadialGradientLayer layer];
}
if(!_backgroundRadialGradientLayer.superlayer){
[_backgroundView.layer insertSublayer:_backgroundRadialGradientLayer atIndex:0];
}
_backgroundView.backgroundColor = [UIColor clearColor];
} else {
if(_backgroundRadialGradientLayer && _backgroundRadialGradientLayer.superlayer){
[_backgroundRadialGradientLayer removeFromSuperlayer];
}
if(self.defaultMaskType == SVProgressHUDMaskTypeBlack){
_backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
} else if(self.defaultMaskType == SVProgressHUDMaskTypeCustom){
_backgroundView.backgroundColor = self.backgroundLayerColor;
} else {
_backgroundView.backgroundColor = [UIColor clearColor];
}
}
// Update frame
if(_backgroundView){
_backgroundView.frame = self.bounds;
}
if(_backgroundRadialGradientLayer){
_backgroundRadialGradientLayer.frame = self.bounds;
// Calculate the new center of the gradient, it may change if keyboard is visible
CGPoint gradientCenter = self.center;
gradientCenter.y = (self.bounds.size.height - self.visibleKeyboardHeight)/2;
_backgroundRadialGradientLayer.gradientCenter = gradientCenter;
[_backgroundRadialGradientLayer setNeedsDisplay];
}
return _backgroundView;
}
- (UIVisualEffectView*)hudView {
if(!_hudView) {
_hudView = [UIVisualEffectView new];
_hudView.layer.masksToBounds = YES;
_hudView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin;
}
if(!_hudView.superview) {
[self addSubview:_hudView];
}
// Update styling
_hudView.layer.cornerRadius = self.cornerRadius;
return _hudView;
}
- (UILabel*)statusLabel {
if(!_statusLabel) {
_statusLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_statusLabel.backgroundColor = [UIColor clearColor];
_statusLabel.adjustsFontSizeToFitWidth = YES;
_statusLabel.textAlignment = NSTextAlignmentCenter;
_statusLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
_statusLabel.numberOfLines = 0;
}
if(!_statusLabel.superview) {
[self.hudView.contentView addSubview:_statusLabel];
}
// Update styling
_statusLabel.textColor = self.foregroundColorForStyle;
_statusLabel.font = self.font;
return _statusLabel;
}
- (UIImageView*)imageView {
if(_imageView && !CGSizeEqualToSize(_imageView.bounds.size, _imageViewSize)) {
[_imageView removeFromSuperview];
_imageView = nil;
}
if(!_imageView) {
_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, _imageViewSize.width, _imageViewSize.height)];
}
if(!_imageView.superview) {
[self.hudView.contentView addSubview:_imageView];
}
return _imageView;
}
#pragma mark - Helper
- (CGFloat)visibleKeyboardHeight {
#if !defined(SV_APP_EXTENSIONS)
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in UIApplication.sharedApplication.windows) {
if(![testWindow.class isEqual:UIWindow.class]) {
keyboardWindow = testWindow;
break;
}
}
for (__strong UIView *possibleKeyboard in keyboardWindow.subviews) {
NSString *viewName = NSStringFromClass(possibleKeyboard.class);
if([viewName hasPrefix:@"UI"]){
if([viewName hasSuffix:@"PeripheralHostView"] || [viewName hasSuffix:@"Keyboard"]){
return CGRectGetHeight(possibleKeyboard.bounds);
} else if ([viewName hasSuffix:@"InputSetContainerView"]){
for (__strong UIView *possibleKeyboardSubview in possibleKeyboard.subviews) {
viewName = NSStringFromClass(possibleKeyboardSubview.class);
if([viewName hasPrefix:@"UI"] && [viewName hasSuffix:@"InputSetHostView"]) {
CGRect convertedRect = [possibleKeyboard convertRect:possibleKeyboardSubview.frame toView:self];
CGRect intersectedRect = CGRectIntersection(convertedRect, self.bounds);
if (!CGRectIsNull(intersectedRect)) {
return CGRectGetHeight(intersectedRect);
}
}
}
}
}
}
#endif
return 0;
}
- (UIWindow *)frontWindow {
#if !defined(SV_APP_EXTENSIONS)
NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator];
for (UIWindow *window in frontToBackWindows) {
BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen;
BOOL windowIsVisible = !window.hidden && window.alpha > 0;
BOOL windowLevelSupported = (window.windowLevel >= UIWindowLevelNormal && window.windowLevel <= self.maxSupportedWindowLevel);
BOOL windowKeyWindow = window.isKeyWindow;
if(windowOnMainScreen && windowIsVisible && windowLevelSupported && windowKeyWindow) {
return window;
}
}
#endif
return nil;
}
- (void)fadeInEffects {
if(self.defaultStyle != SVProgressHUDStyleCustom) {
// Add blur effect
UIBlurEffectStyle blurEffectStyle = self.defaultStyle == SVProgressHUDStyleDark ? UIBlurEffectStyleDark : UIBlurEffectStyleLight;
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:blurEffectStyle];
self.hudView.effect = blurEffect;
// We omit UIVibrancy effect and use a suitable background color as an alternative.
// This will make everything more readable. See the following for details:
// https://www.omnigroup.com/developer/how-to-make-text-in-a-uivisualeffectview-readable-on-any-background
self.hudView.backgroundColor = [self.backgroundColorForStyle colorWithAlphaComponent:0.6f];
} else {
self.hudView.backgroundColor = self.backgroundColorForStyle;
}
// Fade in views
self.backgroundView.alpha = 1.0f;
self.imageView.alpha = 1.0f;
self.statusLabel.alpha = 1.0f;
self.indefiniteAnimatedView.alpha = 1.0f;
self.ringView.alpha = self.backgroundRingView.alpha = 1.0f;
}
- (void)fadeOutEffects
{
if(self.defaultStyle != SVProgressHUDStyleCustom) {
// Remove blur effect
self.hudView.effect = nil;
}
// Remove background color
self.hudView.backgroundColor = [UIColor clearColor];
// Fade out views
self.backgroundView.alpha = 0.0f;
self.imageView.alpha = 0.0f;
self.statusLabel.alpha = 0.0f;
self.indefiniteAnimatedView.alpha = 0.0f;
self.ringView.alpha = self.backgroundRingView.alpha = 0.0f;
}
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
- (UINotificationFeedbackGenerator *)hapticGenerator NS_AVAILABLE_IOS(10_0) {
// Only return if haptics are enabled
if(!self.hapticsEnabled) {
return nil;
}
if(!_hapticGenerator) {
_hapticGenerator = [[UINotificationFeedbackGenerator alloc] init];
}
return _hapticGenerator;
}
#endif
#pragma mark - UIAppearance Setters
- (void)setDefaultStyle:(SVProgressHUDStyle)style {
if (!_isInitializing) _defaultStyle = style;
}
- (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType {
if (!_isInitializing) _defaultMaskType = maskType;
}
- (void)setDefaultAnimationType:(SVProgressHUDAnimationType)animationType {
if (!_isInitializing) _defaultAnimationType = animationType;
}
- (void)setContainerView:(UIView *)containerView {
if (!_isInitializing) _containerView = containerView;
}
- (void)setMinimumSize:(CGSize)minimumSize {
if (!_isInitializing) _minimumSize = minimumSize;
}
- (void)setRingThickness:(CGFloat)ringThickness {
if (!_isInitializing) _ringThickness = ringThickness;
}
- (void)setRingRadius:(CGFloat)ringRadius {
if (!_isInitializing) _ringRadius = ringRadius;
}
- (void)setRingNoTextRadius:(CGFloat)ringNoTextRadius {
if (!_isInitializing) _ringNoTextRadius = ringNoTextRadius;
}
- (void)setCornerRadius:(CGFloat)cornerRadius {
if (!_isInitializing) _cornerRadius = cornerRadius;
}
- (void)setFont:(UIFont*)font {
if (!_isInitializing) _font = font;
}
- (void)setForegroundColor:(UIColor*)color {
if (!_isInitializing) _foregroundColor = color;
}
- (void)setBackgroundColor:(UIColor*)color {
if (!_isInitializing) _backgroundColor = color;
}
- (void)setBackgroundLayerColor:(UIColor*)color {
if (!_isInitializing) _backgroundLayerColor = color;
}
- (void)setShouldTintImages:(BOOL)shouldTintImages {
if (!_isInitializing) _shouldTintImages = shouldTintImages;
}
- (void)setInfoImage:(UIImage*)image {
if (!_isInitializing) _infoImage = image;
}
- (void)setSuccessImage:(UIImage*)image {
if (!_isInitializing) _successImage = image;
}
- (void)setErrorImage:(UIImage*)image {
if (!_isInitializing) _errorImage = image;
}
- (void)setViewForExtension:(UIView*)view {
if (!_isInitializing) _viewForExtension = view;
}
- (void)setOffsetFromCenter:(UIOffset)offset {
if (!_isInitializing) _offsetFromCenter = offset;
}
- (void)setMinimumDismissTimeInterval:(NSTimeInterval)minimumDismissTimeInterval {
if (!_isInitializing) _minimumDismissTimeInterval = minimumDismissTimeInterval;
}
- (void)setFadeInAnimationDuration:(NSTimeInterval)duration {
if (!_isInitializing) _fadeInAnimationDuration = duration;
}
- (void)setFadeOutAnimationDuration:(NSTimeInterval)duration {
if (!_isInitializing) _fadeOutAnimationDuration = duration;
}
- (void)setMaxSupportedWindowLevel:(UIWindowLevel)maxSupportedWindowLevel {
if (!_isInitializing) _maxSupportedWindowLevel = maxSupportedWindowLevel;
}
@end
//
// SVRadialGradientLayer.h
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2014-2018 Tobias Tiemerding. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@interface SVRadialGradientLayer : CALayer
@property (nonatomic) CGPoint gradientCenter;
@end
//
// SVRadialGradientLayer.m
// SVProgressHUD, https://github.com/SVProgressHUD/SVProgressHUD
//
// Copyright (c) 2014-2018 Tobias Tiemerding. All rights reserved.
//
#import "SVRadialGradientLayer.h"
@implementation SVRadialGradientLayer
- (void)drawInContext:(CGContextRef)context {
size_t locationsCount = 2;
CGFloat locations[2] = {0.0f, 1.0f};
CGFloat colors[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.75f};
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, colors, locations, locationsCount);
CGColorSpaceRelease(colorSpace);
float radius = MIN(self.bounds.size.width , self.bounds.size.height);
CGContextDrawRadialGradient (context, gradient, self.gradientCenter, 0, self.gradientCenter, radius, kCGGradientDrawsAfterEndLocation);
CGGradientRelease(gradient);
}
@end
<?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>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.7.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
#import <Foundation/Foundation.h>
@interface PodsDummy_BabyBluetooth : NSObject
@end
@implementation PodsDummy_BabyBluetooth
@end
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "BabyBluetooth.h"
#import "BabyCallback.h"
#import "BabyCentralManager.h"
#import "BabyDefine.h"
#import "BabyOptions.h"
#import "BabyPeripheralManager.h"
#import "BabyRhythm.h"
#import "BabySpeaker.h"
#import "BabyToy.h"
FOUNDATION_EXPORT double BabyBluetoothVersionNumber;
FOUNDATION_EXPORT const unsigned char BabyBluetoothVersionString[];
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/BabyBluetooth
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
framework module BabyBluetooth {
umbrella header "BabyBluetooth-umbrella.h"
export *
module * { export * }
}
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/BabyBluetooth
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
...@@ -24,6 +24,32 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ...@@ -24,6 +24,32 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
## BabyBluetooth
The MIT License (MIT)
Copyright (c) 2015 liuyanwei
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## CryptoSwift ## CryptoSwift
Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin.krzyzanowski@gmail.com> Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin.krzyzanowski@gmail.com>
...@@ -752,6 +778,31 @@ Prohibited Jurisdiction, or otherwise in violation of any such restrictions or ...@@ -752,6 +778,31 @@ Prohibited Jurisdiction, or otherwise in violation of any such restrictions or
regulations. regulations.
## SVProgressHUD
MIT License
Copyright (c) 2011-2018 Sam Vermette, Tobias Tiemerding and contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## SkeletonView ## SkeletonView
The MIT License (MIT) The MIT License (MIT)
......
...@@ -41,6 +41,38 @@ THE SOFTWARE. ...@@ -41,6 +41,38 @@ THE SOFTWARE.
<key>Type</key> <key>Type</key>
<string>PSGroupSpecifier</string> <string>PSGroupSpecifier</string>
</dict> </dict>
<dict>
<key>FooterText</key>
<string>The MIT License (MIT)
Copyright (c) 2015 liuyanwei
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>BabyBluetooth</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict> <dict>
<key>FooterText</key> <key>FooterText</key>
<string>Copyright (C) 2014-2017 Marcin Krzyżanowski &lt;marcin.krzyzanowski@gmail.com&gt; <string>Copyright (C) 2014-2017 Marcin Krzyżanowski &lt;marcin.krzyzanowski@gmail.com&gt;
...@@ -841,6 +873,37 @@ regulations. ...@@ -841,6 +873,37 @@ regulations.
<key>Type</key> <key>Type</key>
<string>PSGroupSpecifier</string> <string>PSGroupSpecifier</string>
</dict> </dict>
<dict>
<key>FooterText</key>
<string>MIT License
Copyright (c) 2011-2018 Sam Vermette, Tobias Tiemerding and contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>SVProgressHUD</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict> <dict>
<key>FooterText</key> <key>FooterText</key>
<string>The MIT License (MIT) <string>The MIT License (MIT)
......
${PODS_ROOT}/Target Support Files/Pods-GeliBusinessPlatform/Pods-GeliBusinessPlatform-frameworks.sh ${PODS_ROOT}/Target Support Files/Pods-GeliBusinessPlatform/Pods-GeliBusinessPlatform-frameworks.sh
${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework ${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework
${BUILT_PRODUCTS_DIR}/BabyBluetooth/BabyBluetooth.framework
${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework ${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework
${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework ${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework
${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework ${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework
...@@ -12,6 +13,7 @@ ${BUILT_PRODUCTS_DIR}/ObjectMapper/ObjectMapper.framework ...@@ -12,6 +13,7 @@ ${BUILT_PRODUCTS_DIR}/ObjectMapper/ObjectMapper.framework
${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework ${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework
${BUILT_PRODUCTS_DIR}/Realm/Realm.framework ${BUILT_PRODUCTS_DIR}/Realm/Realm.framework
${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework ${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework
${BUILT_PRODUCTS_DIR}/SVProgressHUD/SVProgressHUD.framework
${BUILT_PRODUCTS_DIR}/SkeletonView/SkeletonView.framework ${BUILT_PRODUCTS_DIR}/SkeletonView/SkeletonView.framework
${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework ${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
${BUILT_PRODUCTS_DIR}/SwiftDate/SwiftDate.framework ${BUILT_PRODUCTS_DIR}/SwiftDate/SwiftDate.framework
......
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BabyBluetooth.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Dollar.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Dollar.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ESTabBarController_swift.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ESTabBarController_swift.framework
...@@ -11,6 +12,7 @@ ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectMapper.framework ...@@ -11,6 +12,7 @@ ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectMapper.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVProgressHUD.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SkeletonView.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SkeletonView.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftDate.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftDate.framework
......
${PODS_ROOT}/Target Support Files/Pods-GeliBusinessPlatform/Pods-GeliBusinessPlatform-frameworks.sh ${PODS_ROOT}/Target Support Files/Pods-GeliBusinessPlatform/Pods-GeliBusinessPlatform-frameworks.sh
${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework ${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework
${BUILT_PRODUCTS_DIR}/BabyBluetooth/BabyBluetooth.framework
${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework ${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework
${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework ${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework
${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework ${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework
...@@ -12,6 +13,7 @@ ${BUILT_PRODUCTS_DIR}/ObjectMapper/ObjectMapper.framework ...@@ -12,6 +13,7 @@ ${BUILT_PRODUCTS_DIR}/ObjectMapper/ObjectMapper.framework
${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework ${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework
${BUILT_PRODUCTS_DIR}/Realm/Realm.framework ${BUILT_PRODUCTS_DIR}/Realm/Realm.framework
${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework ${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework
${BUILT_PRODUCTS_DIR}/SVProgressHUD/SVProgressHUD.framework
${BUILT_PRODUCTS_DIR}/SkeletonView/SkeletonView.framework ${BUILT_PRODUCTS_DIR}/SkeletonView/SkeletonView.framework
${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework ${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
${BUILT_PRODUCTS_DIR}/SwiftDate/SwiftDate.framework ${BUILT_PRODUCTS_DIR}/SwiftDate/SwiftDate.framework
......
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BabyBluetooth.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Dollar.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Dollar.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ESTabBarController_swift.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ESTabBarController_swift.framework
...@@ -11,6 +12,7 @@ ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectMapper.framework ...@@ -11,6 +12,7 @@ ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectMapper.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVProgressHUD.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SkeletonView.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SkeletonView.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftDate.framework ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftDate.framework
......
...@@ -198,6 +198,7 @@ fi ...@@ -198,6 +198,7 @@ fi
if [[ "$CONFIGURATION" == "Debug" ]]; then if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework" install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework"
install_framework "${BUILT_PRODUCTS_DIR}/BabyBluetooth/BabyBluetooth.framework"
install_framework "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework" install_framework "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework" install_framework "${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework"
install_framework "${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework" install_framework "${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework"
...@@ -210,6 +211,7 @@ if [[ "$CONFIGURATION" == "Debug" ]]; then ...@@ -210,6 +211,7 @@ if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework" install_framework "${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework" install_framework "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework"
install_framework "${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework" install_framework "${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SVProgressHUD/SVProgressHUD.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SkeletonView/SkeletonView.framework" install_framework "${BUILT_PRODUCTS_DIR}/SkeletonView/SkeletonView.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework" install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SwiftDate/SwiftDate.framework" install_framework "${BUILT_PRODUCTS_DIR}/SwiftDate/SwiftDate.framework"
...@@ -220,6 +222,7 @@ if [[ "$CONFIGURATION" == "Debug" ]]; then ...@@ -220,6 +222,7 @@ if [[ "$CONFIGURATION" == "Debug" ]]; then
fi fi
if [[ "$CONFIGURATION" == "Release" ]]; then if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework" install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework"
install_framework "${BUILT_PRODUCTS_DIR}/BabyBluetooth/BabyBluetooth.framework"
install_framework "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework" install_framework "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework" install_framework "${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework"
install_framework "${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework" install_framework "${BUILT_PRODUCTS_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework"
...@@ -232,6 +235,7 @@ if [[ "$CONFIGURATION" == "Release" ]]; then ...@@ -232,6 +235,7 @@ if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework" install_framework "${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework" install_framework "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework"
install_framework "${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework" install_framework "${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SVProgressHUD/SVProgressHUD.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SkeletonView/SkeletonView.framework" install_framework "${BUILT_PRODUCTS_DIR}/SkeletonView/SkeletonView.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework" install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework"
install_framework "${BUILT_PRODUCTS_DIR}/SwiftDate/SwiftDate.framework" install_framework "${BUILT_PRODUCTS_DIR}/SwiftDate/SwiftDate.framework"
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" "${PODS_CONFIGURATION_BUILD_DIR}/Dollar" "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift" "${PODS_CONFIGURATION_BUILD_DIR}/Hue" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" "${PODS_CONFIGURATION_BUILD_DIR}/LGButton" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper" "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift" "${PODS_CONFIGURATION_BUILD_DIR}/Realm" "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift" "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate" "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON" "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator" "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout" FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth" "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" "${PODS_CONFIGURATION_BUILD_DIR}/Dollar" "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift" "${PODS_CONFIGURATION_BUILD_DIR}/Hue" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" "${PODS_CONFIGURATION_BUILD_DIR}/LGButton" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper" "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift" "${PODS_CONFIGURATION_BUILD_DIR}/Realm" "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift" "${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD" "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate" "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON" "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator" "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Dollar/Dollar.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Hue/Hue.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/LGButton/LGButton.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper/ObjectMapper.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/Reachability.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView/SkeletonView.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift/SwifterSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator/ViewAnimator.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout/WYAutoLayout.framework/Headers" HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth/BabyBluetooth.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Dollar/Dollar.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Hue/Hue.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/LGButton/LGButton.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper/ObjectMapper.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/Reachability.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD/SVProgressHUD.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView/SkeletonView.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift/SwifterSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator/ViewAnimator.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout/WYAutoLayout.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Realm/core" LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Realm/core"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Dollar/Dollar.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Hue/Hue.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/LGButton/LGButton.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper/ObjectMapper.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/Reachability.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView/SkeletonView.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift/SwifterSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator/ViewAnimator.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout/WYAutoLayout.framework/Headers" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Dollar" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Hue" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/LGButton" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Realm" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout" OTHER_CFLAGS = $(inherited) -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth/BabyBluetooth.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Dollar/Dollar.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Hue/Hue.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/LGButton/LGButton.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper/ObjectMapper.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/Reachability.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD/SVProgressHUD.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView/SkeletonView.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift/SwifterSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator/ViewAnimator.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout/WYAutoLayout.framework/Headers" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Dollar" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Hue" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/LGButton" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Realm" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout"
OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"z" -framework "Alamofire" -framework "CFNetwork" -framework "CoreGraphics" -framework "CoreTelephony" -framework "CryptoSwift" -framework "Dollar" -framework "ESTabBarController_swift" -framework "Foundation" -framework "Hue" -framework "IQKeyboardManagerSwift" -framework "Kingfisher" -framework "LGButton" -framework "MJRefresh" -framework "ObjectMapper" -framework "QuartzCore" -framework "Reachability" -framework "Realm" -framework "RealmSwift" -framework "Security" -framework "SkeletonView" -framework "SnapKit" -framework "SwiftDate" -framework "SwifterSwift" -framework "SwiftyJSON" -framework "SystemConfiguration" -framework "UIKit" -framework "ViewAnimator" -framework "WYAutoLayout" OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"z" -framework "Alamofire" -framework "BabyBluetooth" -framework "CFNetwork" -framework "CoreGraphics" -framework "CoreTelephony" -framework "CryptoSwift" -framework "Dollar" -framework "ESTabBarController_swift" -framework "Foundation" -framework "Hue" -framework "IQKeyboardManagerSwift" -framework "Kingfisher" -framework "LGButton" -framework "MJRefresh" -framework "ObjectMapper" -framework "QuartzCore" -framework "Reachability" -framework "Realm" -framework "RealmSwift" -framework "SVProgressHUD" -framework "Security" -framework "SkeletonView" -framework "SnapKit" -framework "SwiftDate" -framework "SwifterSwift" -framework "SwiftyJSON" -framework "SystemConfiguration" -framework "UIKit" -framework "ViewAnimator" -framework "WYAutoLayout"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
PODS_BUILD_DIR = ${BUILD_DIR} PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" "${PODS_CONFIGURATION_BUILD_DIR}/Dollar" "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift" "${PODS_CONFIGURATION_BUILD_DIR}/Hue" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" "${PODS_CONFIGURATION_BUILD_DIR}/LGButton" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper" "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift" "${PODS_CONFIGURATION_BUILD_DIR}/Realm" "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift" "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate" "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON" "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator" "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout" FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth" "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" "${PODS_CONFIGURATION_BUILD_DIR}/Dollar" "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift" "${PODS_CONFIGURATION_BUILD_DIR}/Hue" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" "${PODS_CONFIGURATION_BUILD_DIR}/LGButton" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper" "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift" "${PODS_CONFIGURATION_BUILD_DIR}/Realm" "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift" "${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD" "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate" "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON" "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator" "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Dollar/Dollar.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Hue/Hue.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/LGButton/LGButton.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper/ObjectMapper.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/Reachability.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView/SkeletonView.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift/SwifterSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator/ViewAnimator.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout/WYAutoLayout.framework/Headers" HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth/BabyBluetooth.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Dollar/Dollar.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Hue/Hue.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/LGButton/LGButton.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper/ObjectMapper.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/Reachability.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD/SVProgressHUD.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView/SkeletonView.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift/SwifterSwift.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator/ViewAnimator.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout/WYAutoLayout.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Realm/core" LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Realm/core"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Dollar/Dollar.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Hue/Hue.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/LGButton/LGButton.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper/ObjectMapper.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/Reachability.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView/SkeletonView.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift/SwifterSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator/ViewAnimator.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout/WYAutoLayout.framework/Headers" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Dollar" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Hue" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/LGButton" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Realm" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout" OTHER_CFLAGS = $(inherited) -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth/BabyBluetooth.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Dollar/Dollar.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift/ESTabBarController_swift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Hue/Hue.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/LGButton/LGButton.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper/ObjectMapper.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/Reachability.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD/SVProgressHUD.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView/SkeletonView.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift/SwifterSwift.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator/ViewAnimator.framework/Headers" -isystem "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout/WYAutoLayout.framework/Headers" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/BabyBluetooth" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Dollar" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ESTabBarController-swift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Hue" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/LGButton" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ObjectMapper" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/Realm" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SkeletonView" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwifterSwift" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/ViewAnimator" -iframework "${PODS_CONFIGURATION_BUILD_DIR}/WYAutoLayout"
OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"z" -framework "Alamofire" -framework "CFNetwork" -framework "CoreGraphics" -framework "CoreTelephony" -framework "CryptoSwift" -framework "Dollar" -framework "ESTabBarController_swift" -framework "Foundation" -framework "Hue" -framework "IQKeyboardManagerSwift" -framework "Kingfisher" -framework "LGButton" -framework "MJRefresh" -framework "ObjectMapper" -framework "QuartzCore" -framework "Reachability" -framework "Realm" -framework "RealmSwift" -framework "Security" -framework "SkeletonView" -framework "SnapKit" -framework "SwiftDate" -framework "SwifterSwift" -framework "SwiftyJSON" -framework "SystemConfiguration" -framework "UIKit" -framework "ViewAnimator" -framework "WYAutoLayout" OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"z" -framework "Alamofire" -framework "BabyBluetooth" -framework "CFNetwork" -framework "CoreGraphics" -framework "CoreTelephony" -framework "CryptoSwift" -framework "Dollar" -framework "ESTabBarController_swift" -framework "Foundation" -framework "Hue" -framework "IQKeyboardManagerSwift" -framework "Kingfisher" -framework "LGButton" -framework "MJRefresh" -framework "ObjectMapper" -framework "QuartzCore" -framework "Reachability" -framework "Realm" -framework "RealmSwift" -framework "SVProgressHUD" -framework "Security" -framework "SkeletonView" -framework "SnapKit" -framework "SwiftDate" -framework "SwifterSwift" -framework "SwiftyJSON" -framework "SystemConfiguration" -framework "UIKit" -framework "ViewAnimator" -framework "WYAutoLayout"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
PODS_BUILD_DIR = ${BUILD_DIR} PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
......
<?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>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.2.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
#import <Foundation/Foundation.h>
@interface PodsDummy_SVProgressHUD : NSObject
@end
@implementation PodsDummy_SVProgressHUD
@end
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "SVIndefiniteAnimatedView.h"
#import "SVProgressAnimatedView.h"
#import "SVProgressHUD.h"
#import "SVRadialGradientLayer.h"
FOUNDATION_EXPORT double SVProgressHUDVersionNumber;
FOUNDATION_EXPORT const unsigned char SVProgressHUDVersionString[];
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "QuartzCore"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/SVProgressHUD
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
framework module SVProgressHUD {
umbrella header "SVProgressHUD-umbrella.h"
export *
module * { export * }
}
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SVProgressHUD
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "QuartzCore"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/SVProgressHUD
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment