Commit 5e13f85e by GuoJianPeng

update

parent fdd3e041
......@@ -32,11 +32,11 @@ TODO: Add long description of the pod here.
s.source_files = 'CRMNetDetect/Classes/**/*'
# s.resource_bundles = {
# 'CRMNetDetect' => ['CRMNetDetect/Assets/*.png']
# }
s.resource_bundles = {
'CRMNetDetect' => ['CRMNetDetect/Assets/*.png']
}
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
s.dependency 'ASNetwork'
end
//
// CRMNetDetectCell.h
// CRMNetDetect
//
// Created by 坚鹏 on 2024/10/17.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger,CRMNetDetectCellState){
CRMNetDetectCellStateDetecting = 0,
CRMNetDetectCellStateNormal,
CRMNetDetectCellStateNotNormal
};
@interface CRMNetDetectCellData:NSObject
@property(nonatomic,assign)CRMNetDetectCellState state;
@property(nonatomic,copy)NSString * leftTitle;
@property(nonatomic,copy)NSString * rightText;
@property(nonatomic,copy,nullable)NSString * host;
@end
@interface CRMNetDetectCell : UITableViewCell
- (void)updateData:(CRMNetDetectCellData*)data;
@end
NS_ASSUME_NONNULL_END
//
// CRMNetDetectCell.m
// CRMNetDetect
//
// Created by 坚鹏 on 2024/10/17.
//
#import "CRMNetDetectCell.h"
@interface CRMNetDetectCell()
@property(nonatomic,strong)UIActivityIndicatorView * indicatorView;
@property(nonatomic,strong)UILabel * titleLabel;
@end
@implementation CRMNetDetectCell
-(void)updateData:(CRMNetDetectCellData *)data
{
[self setLeftTitle:data.leftTitle];
if(data.state == CRMNetDetectCellStateNormal){
[self changeToStateWithRemindMsg:data.rightText pass:true];
}else if (data.state == CRMNetDetectCellStateNotNormal){
[self changeToStateWithRemindMsg:data.rightText pass:false];
}else{
[self changeToCheckingState];
}
}
-(void)setLeftTitle:(NSString *)title
{
[self.contentView addSubview:self.titleLabel];
[[self.titleLabel.leadingAnchor constraintEqualToAnchor:self.contentView.leadingAnchor constant:20] setActive:true];
[[self.titleLabel.centerYAnchor constraintEqualToAnchor:self.contentView.centerYAnchor] setActive:true];
[self.titleLabel setText:title];
}
-(void)changeToCheckingState
{
[self.contentView addSubview:self.indicatorView];
[[self.indicatorView.trailingAnchor constraintEqualToAnchor:self.contentView.trailingAnchor constant:-20] setActive:true];
[[self.indicatorView.centerYAnchor constraintEqualToAnchor:self.contentView.centerYAnchor] setActive:true];
[_indicatorView startAnimating];
}
-(void)changeToStateWithRemindMsg:(NSString *)msg pass:(BOOL)pass
{
UILabel * rightLabel = [self createRightLabel:pass];
rightLabel.text = msg ? : (pass ?@"正常":@"异常");
[self.contentView addSubview:rightLabel];
[[rightLabel.trailingAnchor constraintEqualToAnchor:self.contentView.trailingAnchor constant:-20] setActive:true];
[[rightLabel.centerYAnchor constraintEqualToAnchor:self.contentView.centerYAnchor] setActive:true];
UIImageView * rightImageView = [[UIImageView alloc] initWithImage:[self _internalImageOfName:pass?@"net_detect_pass":@"net_detect_failed"]];
rightImageView.translatesAutoresizingMaskIntoConstraints = false;
[self.contentView addSubview:rightImageView];
[[rightImageView.trailingAnchor constraintEqualToAnchor:rightLabel.leadingAnchor constant:-3] setActive:true];
[[rightImageView.centerYAnchor constraintEqualToAnchor:self.contentView.centerYAnchor] setActive:true];
[[rightImageView.widthAnchor constraintEqualToConstant:18] setActive:true];
[[rightImageView.heightAnchor constraintEqualToConstant:18] setActive:true];
}
#pragma mark - Getters
-(UILabel *)titleLabel{
if(!_titleLabel){
_titleLabel = [[UILabel alloc] init];
_titleLabel.textColor = UIColor.blackColor;
_titleLabel.font = [UIFont systemFontOfSize:14];
_titleLabel.translatesAutoresizingMaskIntoConstraints = false;
}return _titleLabel;
}
-(UILabel *)createRightLabel:(BOOL)pass{
UILabel * label = [[UILabel alloc] init];
label.textColor = pass ? UIColor.greenColor : UIColor.redColor;
label.font = [UIFont systemFontOfSize:12];
label.translatesAutoresizingMaskIntoConstraints = false;
return label;
}
-(UIActivityIndicatorView *)indicatorView{
if(!_indicatorView){
if (@available(iOS 13.0, *)) {
_indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium];
} else {
_indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
}
_indicatorView.translatesAutoresizingMaskIntoConstraints = false;
_indicatorView.hidesWhenStopped = true;
}return _indicatorView;
}
- (UIImage*_Nullable)_internalImageOfName:(NSString*)name
{
NSString*bundlePath = [[NSBundle bundleForClass:self.class] pathForResource:@"CRMNetDetect.bundle" ofType:nil];
return [UIImage imageWithContentsOfFile:[bundlePath stringByAppendingPathComponent:name]];
}
@end
@implementation CRMNetDetectCellData
@end
......@@ -6,24 +6,32 @@
//
#import <Foundation/Foundation.h>
#import <ASNetwork/ASReachability.h>
#import <ASNetwork/ASCellularNet.h>
#import <ASNetwork/ASPingService.h>
#import <ASNetwork/ASInterfaceService.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger,CRMNetSignalLevel){
CRMNetSignalLevelUnknown = 0,
CRMNetSignalLevelStrong,
CRMNetSignalLevelWeak
typedef NS_ENUM(NSInteger,CRMNetSignalStrength)
{
CRMNetSignalStrengthUnknown = 0,
CRMNetSignalStrengthNone,
CRMNetSignalStrengthStrong,
CRMNetSignalStrengthWeak
};
@class CRMNetDetectService;
@protocol CRMNetDetectServiceDelegate <NSObject>
- (void)netDetect:(CRMNetDetectService*)service signalLevelChanged:(CRMNetSignalLevel)level;
- (void)didGotNetworkStatus:(ASReachabilityStatus)status signalStrength:(CRMNetSignalStrength)strength;
- (void)didGotIPState:(BOOL)isNormal ;//Wifi下非自有IP则正常,蜂窝下有IP则正常
- (void)didGotBusinessServiceState:(BOOL)isNormal host:(NSString*)host millionSeconds:(NSTimeInterval)millionSeconds;
- (void)didFinishedBusinessService:(BOOL)isNormal;//正常数小于总数,则显示异常
@end
@interface CRMNetDetectService : NSObject
/**
* @return 是否检测中的标识,在调用[startsDetecting]后为true,初始状态或[stopDetecting]后为false
**/
- (BOOL)isDetectStarted;
-(instancetype)initWithDelegate:(id<CRMNetDetectServiceDelegate>)delegate;
/**
* @brief 启动网络探测,探测结果通过delegate通知.
**/
......@@ -32,6 +40,11 @@ typedef NS_ENUM(NSInteger,CRMNetSignalLevel){
* @brief 停止网络探测.
**/
- (void)stopDetecting;
@property(nonatomic,strong,nullable)NSArray<NSString*>*businessHostList;
@property(nonatomic,assign,readonly)BOOL isDetecting;
@property(nonatomic,weak,readonly)id<CRMNetDetectServiceDelegate>delegate;
@property(nonatomic,assign,readonly)BOOL isAllFinished;
@end
NS_ASSUME_NONNULL_END
......@@ -7,6 +7,163 @@
#import "CRMNetDetectService.h"
@implementation CRMNetDetectService
@interface CRMNetDetectService()<ASPingServiceDelegate,ASReachabilityDelegate>
{
NSInteger _successPingHostCount;
}
@end
@implementation CRMNetDetectService
{
ASReachability *_reachability;
ASInterfaceService *_interfaceService;
ASPingService *_pingService;
NSMutableArray <NSString*>*_pingingHostList;
BOOL _isReachabilityFinished;
}
-(void)dealloc
{
[self stopDetecting];
}
-(instancetype)initWithDelegate:(id<CRMNetDetectServiceDelegate>)delegate
{
if(self = [super init]){
_delegate = delegate;
}return self;
}
-(void)startsDetecting
{
if(_isDetecting){return;}
_isDetecting = true;
if([_businessHostList count]){
_pingingHostList = _businessHostList.mutableCopy;
_pingService = [[ASPingService alloc] initWithDelegate:self];
[self _readHostAndPing];
}
[self _startReachabilityService];
}
-(void)stopDetecting
{
_isDetecting = false;
[self _stopPingService];
[self _stopReachabilityService];
_isAllFinished = false;
_interfaceService = nil;
_isReachabilityFinished = false;
}
#pragma mark - ASPingServiceDelegate
- (void)pingService:(ASPingService*)service pingingWithDuration:(NSTimeInterval)millionSeconds seq:(uint16_t)seq
{
[self.delegate didGotBusinessServiceState:true host:_pingingHostList.firstObject millionSeconds:millionSeconds];
}
- (void)pingService:(ASPingService*)service pingTimeout:(uint16_t)seq
{
}
- (void)pingService:(ASPingService*)service tmporaryErrorHappens:(NSError*)error seq:(uint16_t)seq
{
}
- (void)pingService:(ASPingService*)service failedToStartWithError:(NSError*)error
{
[_pingingHostList removeObjectAtIndex:0];
[self _readHostAndPing];
}
- (void)pingService:(ASPingService*)service stopWithError:(NSError*_Nullable)error successPingCount:(NSInteger)successPingCount
{
if(!error){
_successPingHostCount++;
}else{
[self.delegate didGotBusinessServiceState:false host:_pingingHostList.firstObject millionSeconds:0];
}
}
#pragma mark - ASReachabilityDelegate
- (void)reachabilityBecomesNotReachable:(ASReachability*)ability
{
_isReachabilityFinished = true;
[self.delegate didGotNetworkStatus:ability.status signalStrength:CRMNetSignalStrengthNone];
[self.delegate didGotIPState:false];
}
- (void)reachabilityChangedToWiFi:(ASReachability*)ability
{
_isReachabilityFinished = true;
[self.delegate didGotNetworkStatus:ability.status signalStrength:CRMNetSignalStrengthStrong];
[self _startIPService];
[self.delegate didGotIPState:[self _isWifiIPNormal]];
}
- (void)reachabilityChangedToWWAN:(ASReachability*)ability
type:(ASCellularNetType)type signalStrength:(ASCelluarSignalStrength)strength
{
_isReachabilityFinished = true;
[self.delegate didGotNetworkStatus:ability.status signalStrength:strength == ASCelluarSignalStrengthStrong?CRMNetSignalStrengthStrong:CRMNetSignalStrengthWeak];
[self _startIPService];
[self.delegate didGotIPState:[self _isCelluarIPNormal]];
}
#pragma mark - Ping
- (void)_readHostAndPing
{
if(!_pingService){return;}
else if (!_pingingHostList.count){
[self.delegate didFinishedBusinessService:_successPingHostCount == _businessHostList.count];
return;
}
_pingService.targetHost = _pingingHostList.firstObject;
_pingService.pingCount = 1;
_pingService.timeoutSeconds = 2;
[_pingService starts];
}
- (void)_stopPingService
{
_successPingHostCount = 0;
[_pingingHostList removeAllObjects];
if(_pingService){
[_pingService stops];_pingService = nil;
}
}
- (void)_startReachabilityService
{
_reachability = [[ASReachability alloc] initWithDelegate:self];
[_reachability startsObserving];
}
- (void)_stopReachabilityService
{
if(_reachability){
[_reachability stopObserving];
}
}
- (void)_startIPService
{
if(!_interfaceService){
_interfaceService = [[ASInterfaceService alloc] init];
}
[_interfaceService refreshAvailableInterfaces];
}
- (void)stopIPService
{
_interfaceService = nil;
}
- (BOOL)_isWifiIPNormal
{
NSArray<NSString *> *wifiIPs = _interfaceService.getWiFiIP;
if(!wifiIPs.count){
return false;
}
for (ASIPEntity*ipEntity in wifiIPs) {
if(ipEntity.isLinkLocalIP){return false;}
}
return true;
}
- (BOOL)_isCelluarIPNormal
{
NSArray<NSString *> *cellularIps = _interfaceService.getCelluarIP;
if(!cellularIps.count){
return false;
}
for (ASIPEntity*ipEntity in cellularIps) {
if(ipEntity.isPrivateIP){return false;}
}
return true;
}
@end
//
// CRMNetDetectView.h
// CRMNetDetect
//
// Created by 坚鹏 on 2024/10/17.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface CRMNetDetectView : UIView
- (void)startsChecking;
//key为name、host
- (void)setBusinessHosts:(NSArray<NSDictionary*>*)hosts;
@end
NS_ASSUME_NONNULL_END
//
// CRMNetDetectView.m
// CRMNetDetect
//
// Created by 坚鹏 on 2024/10/17.
//
#import "CRMNetDetectView.h"
#import <CRMNetDetect/CRMNetDetectService.h>
#import <CRMNetDetect/CRMNetDetectCell.h>
@interface CRMNetDetectView()<CRMNetDetectServiceDelegate,UITableViewDataSource>
{
CRMNetDetectCellData *_signalStrengthData,*_reachabilityData,*_ipData,*_serverConnectData;
int _staticCellDataCount;
}
@property(nonatomic,strong)UITableView * tableView;
@property(nonatomic,strong)UIButton * checkButton;
@property(nonatomic,strong)UIImageView * signalImageView;
@property(nonatomic,strong)NSMutableArray<CRMNetDetectCellData*>*cellDatas;
@end
@implementation CRMNetDetectView
{
CRMNetDetectService * _service;
}
-(instancetype)initWithFrame:(CGRect)frame{
if(self = [super initWithFrame:frame]){
[self _initBaseCellData];
_service = [[CRMNetDetectService alloc] initWithDelegate:self];
_tableView = [[UITableView alloc] initWithFrame:frame];
_tableView.dataSource = self;
_tableView.rowHeight = 44;
[self addSubview:_tableView];
}return self;
}
- (void)_initBaseCellData
{
_cellDatas = @[].mutableCopy;
_staticCellDataCount = 0;
_signalStrengthData = [[CRMNetDetectCellData alloc] init];
_signalStrengthData.leftTitle = @"网络连接信号强度";
_staticCellDataCount++;
_reachabilityData = [[CRMNetDetectCellData alloc] init];
_reachabilityData.leftTitle = @"网络连接情况";
_staticCellDataCount++;
_ipData = [[CRMNetDetectCellData alloc] init];
_ipData.leftTitle = @"IP状态";
_staticCellDataCount++;
_serverConnectData = [[CRMNetDetectCellData alloc] init];
_serverConnectData.leftTitle = @"服务器连接情况(Link-GL-kong-grev)";
_staticCellDataCount++;
[_cellDatas addObjectsFromArray:@[_signalStrengthData,_reachabilityData,
_ipData,_serverConnectData]];
}
#pragma mark - UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _cellDatas.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CRMNetDetectCell * cell = [[CRMNetDetectCell alloc] initWithFrame:CGRectZero];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell updateData:_cellDatas[indexPath.row]];
return cell;
}
#pragma mark - Interface
-(void)startsChecking
{
[_service startsDetecting];
}
-(void)setBusinessHosts:(NSArray<NSDictionary *> *)hosts
{
if(_cellDatas.count){
[self _initBaseCellData];
}
NSMutableArray * hostList = @[].mutableCopy;
for (int i =0; i<hosts.count; i++) {
NSDictionary * info = hosts[i];
NSString * name = info[@"name"];
NSString * host = info[@"host"];
if(![host isKindOfClass:NSString.class] || !host.length){
continue;
}
[hostList addObject:host];
CRMNetDetectCellData*data = [[CRMNetDetectCellData alloc] init];
data.leftTitle = name;
[_cellDatas addObject:data];
}
[self.tableView reloadData];
}
#pragma mark -CRMNetDetectServiceDelegate
- (void)didGotNetworkStatus:(ASReachabilityStatus)status signalStrength:(CRMNetSignalStrength)strength
{
}
- (void)didGotIPState:(BOOL)isNormal
{
}
- (void)didGotBusinessServiceState:(BOOL)isNormal host:(NSString*)host millionSeconds:(NSTimeInterval)millionSeconds
{
}
- (void)didFinishedBusinessService:(BOOL)isNormal
{
}
#pragma mark - Getters
-(UIButton *)checkButton
{
if(!_checkButton){
_checkButton = [[UIButton alloc] initWithFrame:CGRectMake(20, 40, self.bounds.size.width-40, 40)];
_checkButton.layer.cornerRadius = 3;
_checkButton.backgroundColor = UIColor.orangeColor;
[_checkButton setTitle:@"重新检测" forState:UIControlStateNormal];
[_checkButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
[_checkButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
[_checkButton addTarget:self action:@selector(startsChecking) forControlEvents:UIControlEventTouchUpInside];
}return _checkButton;
}
@end
......@@ -37,7 +37,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
183BCBA36E115FC7FBC8C831 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
183BCBA36E115FC7FBC8C831 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
3682D450BBBE1D725255A5E3 /* Pods_CRMNetDetect_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CRMNetDetect_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6003F58A195388D20070C39A /* CRMNetDetect_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CRMNetDetect_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
......@@ -61,8 +61,8 @@
71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
85537DA189C03887B9306A8B /* Pods_CRMNetDetect_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CRMNetDetect_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
94975018CE5B831906579A70 /* CRMNetDetect.podspec */ = {isa = PBXFileReference; includeInIndex = 1; name = CRMNetDetect.podspec; path = ../CRMNetDetect.podspec; sourceTree = "<group>"; };
AE437FC33DD2388ED92FA000 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; name = README.md; path = ../README.md; sourceTree = "<group>"; };
94975018CE5B831906579A70 /* CRMNetDetect.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CRMNetDetect.podspec; path = ../CRMNetDetect.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
AE437FC33DD2388ED92FA000 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
AE4DD64BB9CF7AE6439903F0 /* Pods-CRMNetDetect_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CRMNetDetect_Example.release.xcconfig"; path = "Target Support Files/Pods-CRMNetDetect_Example/Pods-CRMNetDetect_Example.release.xcconfig"; sourceTree = "<group>"; };
AFE35742F2FDF18C538B81CE /* Pods-CRMNetDetect_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CRMNetDetect_Example.debug.xcconfig"; path = "Target Support Files/Pods-CRMNetDetect_Example/Pods-CRMNetDetect_Example.debug.xcconfig"; sourceTree = "<group>"; };
C7C80BA54285835120E746F8 /* Pods-CRMNetDetect_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CRMNetDetect_Tests.release.xcconfig"; path = "Target Support Files/Pods-CRMNetDetect_Tests/Pods-CRMNetDetect_Tests.release.xcconfig"; sourceTree = "<group>"; };
......@@ -103,7 +103,6 @@
D9F33AF7B42C8F80107074A1 /* Pods-CRMNetDetect_Tests.debug.xcconfig */,
C7C80BA54285835120E746F8 /* Pods-CRMNetDetect_Tests.release.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
......@@ -258,6 +257,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
......@@ -302,10 +302,12 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-CRMNetDetect_Example/Pods-CRMNetDetect_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/ASNetwork/ASNetwork.framework",
"${BUILT_PRODUCTS_DIR}/CRMNetDetect/CRMNetDetect.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ASNetwork.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CRMNetDetect.framework",
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -7,10 +7,8 @@
//
@import UIKit;
#import <CRMNetDetect/ASReachability.h>
#import <CRMNetDetect/ASPingService.h>
@interface ASAppDelegate : UIResponder <UIApplicationDelegate,ASReachabilityDelegate,ASPingServiceDelegate>
@interface ASAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
......
......@@ -7,28 +7,16 @@
//
#import "ASAppDelegate.h"
#import "ASIPService.h"
@implementation ASAppDelegate
{
ASReachability * _reachability;
ASPingService *_pingService;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
ASIPService*service = [ASIPService new];
[service updateAvailableIPList];
NSLog(@"当前网络下\n%@",service.availableIPList);
_reachability = [[ASReachability alloc] initWithDelegate:self];
[_reachability startsObserving];
_pingService = [[ASPingService alloc] initWithDelegate:self];
_pingService.pingCount = 10;
_pingService.timeoutSeconds = 2;
_pingService.targetHost = @"ebank.sdb.com.cn";
[_pingService starts];
return YES;
}
......@@ -58,40 +46,4 @@
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
- (void)reachabilityBecomesNotReachable:(nonnull ASReachability *)ability {
}
- (void)reachabilityChangedToWWAN:(nonnull ASReachability *)ability type:(ASCellularType)type signalStrength:(ASCelluarSignalStrength)strength {
ASIPService*service = [ASIPService new];
[service updateAvailableIPList];
NSLog(@"celluar ip:%@",service.getCelluarIP);
}
- (void)reachabilityChangedToWiFi:(nonnull ASReachability *)ability {
ASIPService*service = [ASIPService new];
[service updateAvailableIPList];
NSLog(@"wifi ip:%@",service.getWiFiIP);
}
- (void)pingService:(nonnull ASPingService *)service pingTimeout:(uint16_t)seq {
}
- (void)pingService:(nonnull ASPingService *)service pingingWithDuration:(NSTimeInterval)millionSeconds seq:(uint16_t)seq {
}
- (void)pingService:(nonnull ASPingService *)service tmporaryErrorHappens:(nonnull NSError *)error seq:(uint16_t)seq {
}
-(void)pingService:(ASPingService *)service stopWithError:(NSError *)error
{
if(![service.targetHost isEqualToString:@"svinvy.com"]){
_pingService.targetHost = @"svinvy.com";
[_pingService starts];
}
}
@end
......@@ -7,19 +7,32 @@
//
#import "ASViewController.h"
struct IPV4Header{
uint8_t na;
};
typedef struct IPV4Header ASIPV4Header;
@interface ASViewController ()
@end
#import <CRMNetDetect/CRMNetDetectView.h>
@implementation ASViewController
{
CRMNetDetectView * _detectView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = UIColor.whiteColor;
_detectView = [[CRMNetDetectView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:_detectView];
[_detectView setBusinessHosts:@[
@{
@"name":@"· 赢家服务",
@"host":@"ebank.com.cn"
},
@{
@"name":@"· 老后管服务",
@"host":@"appmanager.orangebank.com.cn"
},
@{
@"name":@"· 新后管服务",
@"host":@"pc.orangebank.com.cn"
}
]];
// Do any additional setup after loading the view, typically from a nib.
}
......
source 'https://gitlab.svinvy.com/oc/specs.git'
use_frameworks!
platform :ios, '10.0'
......
PODS:
- CRMNetDetect (0.1.0)
- ASNetwork (1.0.0)
- CRMNetDetect (0.1.0):
- ASNetwork
DEPENDENCIES:
- CRMNetDetect (from `../`)
SPEC REPOS:
https://gitlab.svinvy.com/oc/specs.git:
- ASNetwork
EXTERNAL SOURCES:
CRMNetDetect:
:path: "../"
SPEC CHECKSUMS:
CRMNetDetect: bfcefd1bdbfe5c6882b53814a550a8a8f840e082
ASNetwork: a1bdef0d07fc5c4c78cb01a380baaa812ee9944e
CRMNetDetect: 30b81d339ea6293c8cd2cee10d31197a4da7b16c
PODFILE CHECKSUM: ab41865aadda21067563b5d42c8b495684c3026e
PODFILE CHECKSUM: f5247f2e9f0505f8db1736cd0e5716b42c1a2390
COCOAPODS: 1.12.1
//
// ASCellularSignalMonitor.h
// CRMNetDetect
// ASNetwork
//
// Created by 坚鹏 on 2024/10/14.
//
......@@ -11,7 +11,7 @@
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger,ASCellularType)
typedef NS_ENUM(NSInteger,ASCellularNetType)
{
ASCellularTypeUnknown = 0,
ASCellularType2G,
......@@ -24,15 +24,24 @@ typedef NS_ENUM(NSInteger,ASCelluarSignalStrength){
ASCelluarSignalStrengthStrong,
ASCelluarSignalStrengthWeak
};
@interface ASCellularService : NSObject
- (NSString*)accessTypeValue;
- (ASCellularType)accessType;
- (ASCelluarSignalStrength)signalStrength;
- (ASCelluarSignalStrength)signalStrengthEvaluatedForType:(ASCellularType)type;
@interface ASCellularNet : NSObject
/**
* @brief 更新当前蜂窝流量接入情况,包括接入类型,信号强度等;网络变化等情形时,需主动查询刷新状态.
**/
- (void)updateNetworkInfo;
/**
* @brief 接入网络类型系统描述,包括CTRadioAccessTechnologyEdge等;若用户不启用蜂窝流量,会返回nil
**/
@property(nonatomic,copy,nullable,readonly)NSString * accessNetValue;
/**
* @brief accessNetValue的枚举映射.
**/
@property(nonatomic,assign,readonly)ASCellularNetType accessNet;
/**
* @brief 信号强度。基于accessNet的一个估算,默认4G/5G为strong,其余为weak;
* 若想检测相应域名连接是否稳定、快速(强弱网),你应当使用icmp/http进行检测RTT等耗时
**/
@property(nonatomic,assign,readonly)ASCelluarSignalStrength signalStrength;
@end
NS_ASSUME_NONNULL_END
//
// ASCellularSignalMonitor.m
// CRMNetDetect
// ASNetwork
//
// Created by 坚鹏 on 2024/10/14.
//
#import "ASCellularService.h"
#import "ASCellularNet.h"
@implementation ASCellularService
-(NSString *)accessTypeValue
@implementation ASCellularNet
{
NSString * _accessTypeValue;
ASCellularNetType _accessType;
ASCelluarSignalStrength _signalStrength;
}
-(void)updateNetworkInfo
{
CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
NSString *radioAccessTechnology = nil;
......@@ -21,13 +25,27 @@
// iOS 12 以下,直接获取当前网络类型
radioAccessTechnology = networkInfo.currentRadioAccessTechnology;
}
return radioAccessTechnology;
_accessTypeValue = radioAccessTechnology;
_accessType = [self _parsedAccessType];
_signalStrength = [self _mapSignalStrengthEvaluatedForType:_accessType];
}
-(ASCellularType)accessType
-(NSString *)accessNetValue
{
ASCellularType type = ASCellularTypeUnknown;
NSString * value = [self accessTypeValue];
return _accessTypeValue;
}
-(ASCellularNetType)accessNet
{
return _accessType;
}
-(ASCelluarSignalStrength)signalStrength
{
return _signalStrength;
}
#pragma mark - Utils
-(ASCellularNetType)_parsedAccessType
{
ASCellularNetType type = ASCellularTypeUnknown;
NSString * value = [self accessNetValue];
NSArray * secondGValues = @[
CTRadioAccessTechnologyEdge,CTRadioAccessTechnologyGPRS
];
......@@ -49,12 +67,8 @@
}
return type;
}
-(ASCelluarSignalStrength)signalStrength
{
ASCellularType type = [self accessType];
return [self signalStrengthEvaluatedForType:type];
}
-(ASCelluarSignalStrength)signalStrengthEvaluatedForType:(ASCellularType)type
-(ASCelluarSignalStrength)_mapSignalStrengthEvaluatedForType:(ASCellularNetType)type
{
if (@available(iOS 14.1, *)) {
if(type == ASCellularType5G){
......
//
// ASIPService.h
// CRMNetDetect
// ASNetwork
//
// Created by 坚鹏 on 2024/10/15.
//
......@@ -17,6 +17,7 @@ typedef NS_ENUM(NSInteger,ASIPType)
ASIPTypeEthernet,//以太
ASIPTypeLo0,//本地环回
ASIPTypeBridge0,//热点
//...Preserved:其余暂时不作映射,统一按Unknown处理.
};
@interface ASIPEntity : NSObject
......@@ -27,19 +28,34 @@ typedef NS_ENUM(NSInteger,ASIPType)
@property(nonatomic,assign,readonly)BOOL isPrivateIP;//是否局域网私有IP
@property(nonatomic,assign,readonly)BOOL isLinkLocalIP;//是否自分配IP,169.254开头
@end
@interface ASIPService : NSObject
- (void)updateAvailableIPList;
/**
* @class 静态查询当前已连接的接口,包括wifi或蜂窝ip等.
**/
@interface ASInterfaceService : NSObject
/**
* @brief 刷新可用接口,需主动调用.
**/
- (void)refreshAvailableInterfaces;
/**
* @return 是否启用了VPN,若接口中包含了虚拟vpn接口则视为true.
**/
- (BOOL)usingVPN;
//ipv4+ipv6可能同时启用
/**
* @return 获取WIFI对应ip列表,当ipv4+ipv6同时启用时会返回多个.
**/
- (NSArray<NSString*>* _Nullable)getWiFiIP;
//ipv4+ipv6可能同时启用或多sim卡
/**
* @return 查询蜂窝IP,当多种sim卡启用或ipv6启用时也可能返回多个
**/
- (NSArray<NSString*>*_Nullable)getCelluarIP;
/**
* @property 可用的接口IP列表
**/
@property(nonatomic,strong,readonly,nullable)NSArray<ASIPEntity*>*availableIPList;
@end
......
//
// ASIPService.m
// CRMNetDetect
// ASNetwork
//
// Created by 坚鹏 on 2024/10/15.
//
#import "ASIPService.h"
#import "ASInterfaceService.h"
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <net/if.h>
@interface ASIPEntity()
- (instancetype)initWithInterfaceName:(NSString*)name ip:(NSString*)ip isIpv6:(BOOL)isIpv6;
@end
@implementation ASIPService
@implementation ASInterfaceService
-(void)updateAvailableIPList
-(void)refreshAvailableInterfaces
{
struct ifaddrs *interfaces = NULL;
struct ifaddrs *temp_addr = NULL;
......
......@@ -12,13 +12,13 @@ NS_ASSUME_NONNULL_BEGIN
@protocol ASPingServiceDelegate <NSObject>
- (void)pingService:(ASPingService*)service pingingWithDuration:(NSTimeInterval)millionSeconds seq:(uint16_t)seq;//正常收到回调
- (void)pingService:(ASPingService*)service pingTimeout:(uint16_t)seq;//ping超时,可能来自自身控制,也可能来自icmp通知.
- (void)pingService:(ASPingService*)service pingTimeout:(uint16_t)seq;//ping超时,可能来自自身控制,也可能来自icmp通知,这里不做区分
- (void)pingService:(ASPingService*)service tmporaryErrorHappens:(NSError*)error seq:(uint16_t)seq;//可恢复的错误,后续会继续ping
@optional
- (void)pingingServiceDidStart:(ASPingService*)service;//[调用starts]成功
- (void)pingService:(ASPingService*)service failedToStartWithError:(NSError*)error;//调用[starts]失败
- (void)pingService:(ASPingService*)service stopWithError:(NSError*_Nullable)error;//ping终止,error为空时则为正常终止.
- (void)pingService:(ASPingService*)service stopWithError:(NSError*_Nullable)error successPingCount:(NSInteger)successPingCount;//ping终止,error为空时则为正常终止,若successPingCount为0,你可以考虑使用http替代进行网络检测
@end
@interface ASPingService : NSObject
......@@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic,assign,readonly)BOOL isPinging;
@property(nonatomic,copy)NSString * targetHost;
@property(nonatomic,assign)NSInteger pingCount;//默认为1即只ping一次。
@property(nonatomic,assign)NSTimeInterval timeoutSeconds;//默认为3s,超出3s收不到当次ping回调,则取消当次ping,就算后续收到回调也ignore;不建议设置过低.
@property(nonatomic,assign)NSTimeInterval timeoutSeconds;//默认为2s,超出2s收不到当次ping回调,则取消当次ping,就算后续收到回调也ignore;不建议设置过低.
@end
NS_ASSUME_NONNULL_END
......@@ -6,7 +6,7 @@
//
#import "ASPingService.h"
#import <CRMNetDetect/ASSimplePing.h>
#import <ASNetwork/ASSimplePing.h>
#import <sys/time.h>
static uint16_t KASPingNotStartedSeq = -1;
......@@ -18,12 +18,14 @@ static uint16_t KASPingNotStartedSeq = -1;
ASSimplePing *_samplePing;
NSTimeInterval _startPingTime;
uint16_t _pingingSeq;
NSInteger _successPingCount;
}
-(instancetype)initWithDelegate:(id<ASPingServiceDelegate>)delegate{
if (self = [super init]) {
_successPingCount =0;
_delegate = delegate;
_pingCount = 1;
_timeoutSeconds = 3;
_timeoutSeconds = 2;
_pingingSeq = KASPingNotStartedSeq;
}return self;
}
......@@ -54,6 +56,7 @@ static uint16_t KASPingNotStartedSeq = -1;
return;
}
NSLog(@"stops ping service");
_successPingCount =0;
[_samplePing stop];
_samplePing = nil;
_pingingSeq = KASPingNotStartedSeq;
......@@ -70,15 +73,14 @@ static uint16_t KASPingNotStartedSeq = -1;
_pingingSeq ++;
if(_pingingSeq >= _pingCount){
[self stops];
if([self.delegate respondsToSelector:@selector(pingService:stopWithError:)]){
[self.delegate pingService:self stopWithError:nil];
if([self.delegate respondsToSelector:@selector(pingService:stopWithError: successPingCount:)]){
[self.delegate pingService:self stopWithError:nil successPingCount:_successPingCount];
}
return;
}
[self performSelector:@selector(_gotManulyTimeoutNotification) withObject:nil afterDelay:self.timeoutSeconds];
_startPingTime = [self _getCurrentMicroSeconds];
[_samplePing sendPingWithData:nil];
NSLog(@"did send next ping and current count is %hu",_pingingSeq);
}
- (void)_gotManulyTimeoutNotification
{
......@@ -116,8 +118,8 @@ static uint16_t KASPingNotStartedSeq = -1;
[self _gotManulyTimeoutNotification];//按照手动超时的方式处理.
}else{
[self stops];
if([self.delegate respondsToSelector:@selector(pingService:stopWithError:)]){
[self.delegate pingService:self stopWithError:nil];
if([self.delegate respondsToSelector:@selector(pingService:stopWithError:successPingCount:)]){
[self.delegate pingService:self stopWithError:nil successPingCount:_successPingCount];
}
}
}
......@@ -139,6 +141,7 @@ static uint16_t KASPingNotStartedSeq = -1;
NSTimeInterval duration = [self _getPingTimePastMicroSeconds];
NSLog(@"%ld bytes from %@: icmp_seq=%hu time=%.3f ms",packet.length,_targetHost,sequenceNumber,duration);
[self.delegate pingService:self pingingWithDuration:duration seq:sequenceNumber];
_successPingCount++;
[self _sendPingOnce];
}else{
NSLog(@"got outdate sequenceNumber:%hu",sequenceNumber);
......
//
// ASReachability.h
// CRMNetDetect
// ASNetwork
//
// Created by 坚鹏 on 2024/10/14.
//
#import <Foundation/Foundation.h>
#import <CRMNetDetect/ASCellularService.h>
#import <ASNetwork/ASCellularNet.h>
NS_ASSUME_NONNULL_BEGIN
......@@ -20,20 +20,40 @@ typedef NS_ENUM(NSInteger,ASReachabilityStatus){
@protocol ASReachabilityDelegate <NSObject>
- (void)reachabilityBecomesNotReachable:(ASReachability*)ability;
/**
* @brief 使用Wifi时回调;可考虑使用ASInterfaceService.getWiFiIP进一步获取对应IP
**/
- (void)reachabilityChangedToWiFi:(ASReachability*)ability;
/**
* @brief 使用蜂窝时回调;可考虑使用ASInterfaceService.getCelluarIP进一步获取对应IP
**/
- (void)reachabilityChangedToWWAN:(ASReachability*)ability
type:(ASCellularType)type signalStrength:(ASCelluarSignalStrength)strength;
type:(ASCellularNetType)type signalStrength:(ASCelluarSignalStrength)strength;
@end
/**
* @class 当前activate network探测.
**/
@interface ASReachability : NSObject
/**
* @param delegate network变动的观察者,会持续收到变动通知,若只想收到一次通知则需在收到通知后主动stopObserving
**/
- (instancetype)initWithDelegate:(id<ASReachabilityDelegate>)delegate;
/**
* 开始监测activate network的变动。涉及Wifi接入、流量切换等场景.
**/
- (void)startsObserving;
/**
* 停止检测activate network的变动.
**/
- (void)stopObserving;
/**
* @property host 探测目标地址的连通性,对于处于网络策略较为复杂的网段时,会更加有效;可选项.
**/
@property(nonatomic,copy,nullable)NSString * host;
/**
* @property status 当前activate network的状态.
**/
@property(nonatomic,assign,readonly)ASReachabilityStatus status;
@property(nonatomic,weak,readonly)id<ASReachabilityDelegate>delegate;
@end
......
//
// ASReachability.m
// CRMNetDetect
// ASNetwork
//
// Created by 坚鹏 on 2024/10/14.
//
......@@ -10,16 +10,28 @@
#import <netinet/in.h>
@interface ASReachability()
@property(nonatomic,strong,nullable)ASCellularService * celluarService;
{
SCNetworkReachabilityFlags _reachabilityFlags;
}
@property(nonatomic,strong,nullable)ASCellularNet * celluarService;
@property (nonatomic) SCNetworkReachabilityRef reachabilityRef;
@end
@implementation ASReachability
// 网络状态变化回调函数
static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) {
ASReachability *monitor = (__bridge ASReachability *)info;
[monitor handleNetworkChangeWithFlags:flags];
}
-(void)dealloc
{
[self stopObserving];
}
-(instancetype)initWithDelegate:(id<ASReachabilityDelegate>)delegate
{
if(self = [super init]){
_delegate = delegate;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkCurrentNetworkStatus) name:UIApplicationDidBecomeActiveNotification object:nil];
}return self;
}
......@@ -48,11 +60,7 @@
_reachabilityRef = NULL;
}
}
// 网络状态变化回调函数
static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) {
ASReachability *monitor = (__bridge ASReachability *)info;
[monitor handleNetworkChangeWithFlags:flags];
}
- (void)checkCurrentNetworkStatus {
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags)) {
......@@ -63,6 +71,9 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
}
// 处理网络状态变化
- (void)handleNetworkChangeWithFlags:(SCNetworkReachabilityFlags)flags {
if(_reachabilityFlags == flags){
return;
}
BOOL isReachable = (flags & kSCNetworkReachabilityFlagsReachable);
BOOL needsConnection = (flags & kSCNetworkReachabilityFlagsConnectionRequired);
if (isReachable && !needsConnection) {
......@@ -89,12 +100,12 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
- (void)detectConnectionTypeWithFlags:(SCNetworkReachabilityFlags)flags {
if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
// 通过蜂窝网络连接
if(!_celluarService){_celluarService = [ASCellularService new];}
ASCellularType type = _celluarService.accessType;
if(!_celluarService){_celluarService = [ASCellularNet new];}
[_celluarService updateNetworkInfo];
ASCellularNetType type = _celluarService.accessNet;
NSLog(@"Connected via Cellular of %ld",type);
_status = ASReachabilityStatusWifi;
[self.delegate reachabilityChangedToWWAN:self type:type signalStrength:[_celluarService signalStrengthEvaluatedForType:type]];
[self.delegate reachabilityChangedToWWAN:self type:type signalStrength:_celluarService.signalStrength];
} else {
// 通过Wi-Fi或其他网络连接
NSLog(@"Connected via Wi-Fi");
......@@ -103,10 +114,6 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
}
}
-(void)dealloc
{
[self stopObserving];
}
#pragma mark - Privates
- (SCNetworkReachabilityRef _Nullable)_createHostReachabilityRef
{
......
Copyright (c) 2024 guojianpeng@svinvy.com <svinvy@gmail.com>
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.
# ASNetwork
[![CI Status](https://img.shields.io/travis/guojianpeng@svinvy.com/ASNetwork.svg?style=flat)](https://travis-ci.org/guojianpeng@svinvy.com/ASNetwork)
[![Version](https://img.shields.io/cocoapods/v/ASNetwork.svg?style=flat)](https://cocoapods.org/pods/ASNetwork)
[![License](https://img.shields.io/cocoapods/l/ASNetwork.svg?style=flat)](https://cocoapods.org/pods/ASNetwork)
[![Platform](https://img.shields.io/cocoapods/p/ASNetwork.svg?style=flat)](https://cocoapods.org/pods/ASNetwork)
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
## Installation
ASNetwork is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'ASNetwork'
```
## Author
guojianpeng@svinvy.com, svinvy@gmail.com
## License
ASNetwork is available under the MIT license. See the LICENSE file for more info.
......@@ -18,5 +18,15 @@
"platforms": {
"ios": "10.0"
},
"source_files": "CRMNetDetect/Classes/**/*"
"source_files": "CRMNetDetect/Classes/**/*",
"resource_bundles": {
"CRMNetDetect": [
"CRMNetDetect/Assets/*.png"
]
},
"dependencies": {
"ASNetwork": [
]
}
}
PODS:
- CRMNetDetect (0.1.0)
- ASNetwork (1.0.0)
- CRMNetDetect (0.1.0):
- ASNetwork
DEPENDENCIES:
- CRMNetDetect (from `../`)
SPEC REPOS:
https://gitlab.svinvy.com/oc/specs.git:
- ASNetwork
EXTERNAL SOURCES:
CRMNetDetect:
:path: "../"
SPEC CHECKSUMS:
CRMNetDetect: bfcefd1bdbfe5c6882b53814a550a8a8f840e082
ASNetwork: a1bdef0d07fc5c4c78cb01a380baaa812ee9944e
CRMNetDetect: 30b81d339ea6293c8cd2cee10d31197a4da7b16c
PODFILE CHECKSUM: ab41865aadda21067563b5d42c8b495684c3026e
PODFILE CHECKSUM: f5247f2e9f0505f8db1736cd0e5716b42c1a2390
COCOAPODS: 1.12.1
<?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>${PODS_DEVELOPMENT_LANGUAGE}</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>1.0.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_ASNetwork : NSObject
@end
@implementation PodsDummy_ASNetwork
@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 "ASCellularNet.h"
#import "ASInterfaceService.h"
#import "ASPingService.h"
#import "ASReachability.h"
#import "ASSimplePing.h"
FOUNDATION_EXPORT double ASNetworkVersionNumber;
FOUNDATION_EXPORT const unsigned char ASNetworkVersionString[];
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE}
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/ASNetwork
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
framework module ASNetwork {
umbrella header "ASNetwork-umbrella.h"
export *
module * { export * }
}
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE}
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/ASNetwork
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
......@@ -10,12 +10,9 @@
#endif
#endif
#import "ASCellularService.h"
#import "ASIPService.h"
#import "ASPingService.h"
#import "ASReachability.h"
#import "ASSimplePing.h"
#import "CRMNetDetectCell.h"
#import "CRMNetDetectService.h"
#import "CRMNetDetectView.h"
FOUNDATION_EXPORT double CRMNetDetectVersionNumber;
FOUNDATION_EXPORT const unsigned char CRMNetDetectVersionString[];
......
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "ASNetwork"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE}
......
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "ASNetwork"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE}
......
<?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>${PODS_DEVELOPMENT_LANGUAGE}</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>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
# Acknowledgements
This application makes use of the following third party libraries:
## ASNetwork
Copyright (c) 2024 guojianpeng@svinvy.com <svinvy@gmail.com>
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.
## CRMNetDetect
Copyright (c) 2024 guojianpeng@svinvy.com <svinvy@gmail.com>
......
......@@ -37,6 +37,35 @@ THE SOFTWARE.
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>ASNetwork</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2024 guojianpeng@svinvy.com &lt;svinvy@gmail.com&gt;
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>CRMNetDetect</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
......
......@@ -176,9 +176,11 @@ code_sign_if_enabled() {
}
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/ASNetwork/ASNetwork.framework"
install_framework "${BUILT_PRODUCTS_DIR}/CRMNetDetect/CRMNetDetect.framework"
fi
if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework "${BUILT_PRODUCTS_DIR}/ASNetwork/ASNetwork.framework"
install_framework "${BUILT_PRODUCTS_DIR}/CRMNetDetect/CRMNetDetect.framework"
fi
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
......
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect"
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork" "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect/CRMNetDetect.framework/Headers"
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork/ASNetwork.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect/CRMNetDetect.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
OTHER_LDFLAGS = $(inherited) -framework "CRMNetDetect"
OTHER_LDFLAGS = $(inherited) -framework "ASNetwork" -framework "CRMNetDetect"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
......
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect"
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork" "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect/CRMNetDetect.framework/Headers"
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork/ASNetwork.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect/CRMNetDetect.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
OTHER_LDFLAGS = $(inherited) -framework "CRMNetDetect"
OTHER_LDFLAGS = $(inherited) -framework "ASNetwork" -framework "CRMNetDetect"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
......
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect"
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork" "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect/CRMNetDetect.framework/Headers"
OTHER_LDFLAGS = $(inherited) -framework "CRMNetDetect"
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork/ASNetwork.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect/CRMNetDetect.framework/Headers"
OTHER_LDFLAGS = $(inherited) -framework "ASNetwork" -framework "CRMNetDetect"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
......
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect"
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork" "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect/CRMNetDetect.framework/Headers"
OTHER_LDFLAGS = $(inherited) -framework "CRMNetDetect"
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ASNetwork/ASNetwork.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/CRMNetDetect/CRMNetDetect.framework/Headers"
OTHER_LDFLAGS = $(inherited) -framework "ASNetwork" -framework "CRMNetDetect"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
......
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