Commit 43e05694 authored by 叶凤鸣's avatar 叶凤鸣

Merge branch 'master' into yefengming/isPush

# Conflicts:
#	GMPhobos/Classes/Phobos.m
parents 9c9a2d85 136f130d
...@@ -32,4 +32,4 @@ Carthage ...@@ -32,4 +32,4 @@ Carthage
# `pod install` in .travis.yml # `pod install` in .travis.yml
# #
Pods/ Pods/
fastlane/* #fastlane/*
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "GMPhobos" s.name = "GMPhobos"
s.version = "0.5.7" s.version = "1.0.2"
s.summary = "GM statistic data sdk" s.summary = "GM statistic data sdk"
s.description = <<-DESC s.description = <<-DESC
......
...@@ -28,6 +28,10 @@ static NSString *sdkVersion = @"110"; ...@@ -28,6 +28,10 @@ static NSString *sdkVersion = @"110";
@property (strong, nonatomic) NSString *sessionId; @property (strong, nonatomic) NSString *sessionId;
/* 每一条埋点数据的物理ID,自增,生命周期和sessionId相同。特别注意:在sessionOver的时候,要把他置为0 */ /* 每一条埋点数据的物理ID,自增,生命周期和sessionId相同。特别注意:在sessionOver的时候,要把他置为0 */
@property (assign, nonatomic) NSInteger serialId; @property (assign, nonatomic) NSInteger serialId;
// 用来记录除serverAPI以外的API
@property (strong, nonatomic) NSMutableArray *APIArray;
@end @end
@implementation Phobos @implementation Phobos
...@@ -56,6 +60,7 @@ static NSString *sdkVersion = @"110"; ...@@ -56,6 +60,7 @@ static NSString *sdkVersion = @"110";
_serverAPI = @""; _serverAPI = @"";
_userType = [[NSMutableDictionary alloc] initWithCapacity:0]; _userType = [[NSMutableDictionary alloc] initWithCapacity:0];
_appVersion = [PhobosUtil getAppVersion]; _appVersion = [PhobosUtil getAppVersion];
_APIArray = [NSMutableArray array];
[self setupNotification]; [self setupNotification];
[self handleSessionStart]; [self handleSessionStart];
[self synchronizePhobosKey]; [self synchronizePhobosKey];
...@@ -276,7 +281,7 @@ static NSString *sdkVersion = @"110"; ...@@ -276,7 +281,7 @@ static NSString *sdkVersion = @"110";
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI { + (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI {
[self track:eventId attributes:attributes sendNow:NO currentAPI:currentAPI]; [self track:eventId attributes:attributes sendNow:NO currentAPI:currentAPI];
NSArray *array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey]; NSArray *array = [GMCache fetchObjectAtDocumentPathWithkey:[PhobosUtil MD5String:currentAPI]];
//超过一定数量的话,统一发送一次 //超过一定数量的话,统一发送一次
if (array.count > PhobosShardCount) { if (array.count > PhobosShardCount) {
[sharedClient sendArray:array currentAPI:currentAPI cleanCacheRightNow:YES]; [sharedClient sendArray:array currentAPI:currentAPI cleanCacheRightNow:YES];
...@@ -284,13 +289,14 @@ static NSString *sdkVersion = @"110"; ...@@ -284,13 +289,14 @@ static NSString *sdkVersion = @"110";
} }
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI { + (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI {
[sharedClient addNewApi:currentAPI]; // 记录新的API
NSDictionary *dict = [sharedClient prepareDictionaryForEvent:eventId attributes:attributes]; NSDictionary *dict = [sharedClient prepareDictionaryForEvent:eventId attributes:attributes];
if (sendNow) { if (sendNow) {
NSArray *array = @[dict]; NSArray *array = @[dict];
// 实时发送的埋点,不能立即清楚缓存 // 实时发送的埋点,不能立即清楚缓存
[sharedClient sendArray:array currentAPI:currentAPI cleanCacheRightNow:NO]; [sharedClient sendArray:array currentAPI:currentAPI cleanCacheRightNow:NO];
}else{ }else{
[sharedClient save:dict]; [sharedClient save:dict currentAPI:currentAPI];
} }
} }
...@@ -326,7 +332,7 @@ static NSString *sdkVersion = @"110"; ...@@ -326,7 +332,7 @@ static NSString *sdkVersion = @"110";
// 必须在此处调用一下referer,因为onControllerStart // 必须在此处调用一下referer,因为onControllerStart
[page initReferer]; [page initReferer];
[page initReferrerIdIfNil]; [page initReferrerIdIfNil];
[page initHomeTabName]; [page initReferrerTabName];
page.inTime = [PhobosUtil currentTime]; page.inTime = [PhobosUtil currentTime];
} }
...@@ -345,11 +351,8 @@ static NSString *sdkVersion = @"110"; ...@@ -345,11 +351,8 @@ static NSString *sdkVersion = @"110";
[dict setObject:@(0) forKey:@"fake"]; [dict setObject:@(0) forKey:@"fake"];
[dict setObject:page.referrerId ? : @"" forKey:@"referrer_id"]; [dict setObject:page.referrerId ? : @"" forKey:@"referrer_id"];
[dict setObject:page.extraParam ? : @"" forKey:@"extra_param"]; [dict setObject:page.extraParam ? : @"" forKey:@"extra_param"];
[dict setObject:page.homeTabName ? : @"" forKey:@"tab_name"]; [dict setObject:page.referrerTabName ? : @"" forKey:@"referrer_tab_name"];
[dict setObject:page.currentTabName ? : @"" forKey:@"referrer_tab_name"];
[dict setObject:@(page.isPush) forKey:@"is_push"]; [dict setObject:@(page.isPush) forKey:@"is_push"];
NSAssert(page.inTime.length > 0, @"页面显示时间不能为空!");
[Phobos track:@"page_view" attributes:dict];
if (page.inTime.length > 0) { if (page.inTime.length > 0) {
// 页面显示时间为空时不记录页面pv事件 // 页面显示时间为空时不记录页面pv事件
[Phobos track:@"page_view" attributes:dict]; [Phobos track:@"page_view" attributes:dict];
...@@ -445,6 +448,26 @@ static NSString *sdkVersion = @"110"; ...@@ -445,6 +448,26 @@ static NSString *sdkVersion = @"110";
[GMCache storeObjectAtDocumentPathWithkey:PhobosCacheKey object:dataArray]; [GMCache storeObjectAtDocumentPathWithkey:PhobosCacheKey object:dataArray];
} }
/**
* @brief 保存数据到缓存层
*
* @param data 数据
*
*/
- (void)save:(NSDictionary *)data currentAPI:(NSString *)currentAPI
{
if (_logEnabled) {
phobosLog([NSString stringWithFormat:@"save dictionary: %@",data]);
}
NSMutableArray *dataArray = [GMCache fetchObjectAtDocumentPathWithkey:[PhobosUtil MD5String:currentAPI]];
if (dataArray) {
[dataArray addObject:data];
}else{
dataArray = [NSMutableArray arrayWithObject:data];
}
[GMCache storeObjectAtDocumentPathWithkey:[PhobosUtil MD5String:currentAPI] object:dataArray];
}
/** /**
* @brief 从缓存中获取数据,并发送 * @brief 从缓存中获取数据,并发送
* *
...@@ -455,6 +478,13 @@ static NSString *sdkVersion = @"110"; ...@@ -455,6 +478,13 @@ static NSString *sdkVersion = @"110";
if (paramsArray.count>0) { if (paramsArray.count>0) {
[self sendArray:paramsArray cleanCacheRightNow:YES]; [self sendArray:paramsArray cleanCacheRightNow:YES];
} }
// 其他接口的埋点
for (NSString *newApi in self.APIArray) {
NSArray *paramsArray = [GMCache fetchObjectAtDocumentPathWithkey:[PhobosUtil MD5String:newApi]];
if (paramsArray.count>0) {
[self sendArray:paramsArray currentAPI:newApi cleanCacheRightNow:YES];
}
}
} }
/* /*
...@@ -486,7 +516,8 @@ static NSString *sdkVersion = @"110"; ...@@ -486,7 +516,8 @@ static NSString *sdkVersion = @"110";
从缓存区获取数据,发给服务器,请求成功的时候,把缓存区的数据删除掉 从缓存区获取数据,发给服务器,请求成功的时候,把缓存区的数据删除掉
*/ */
- (void)sendArrayWithCurrentAPI:(NSString *)currentAPI { - (void)sendArrayWithCurrentAPI:(NSString *)currentAPI {
NSMutableArray *dataArray = [GMCache fetchObjectAtDocumentPathWithkey:PhobosTempCacheKey]; NSString *PhobosTempCacheKeyStr = [PhobosUtil MD5String:[PhobosUtil MD5String:currentAPI]]; // 两次加密作为key值,和缓存的key值作区分
NSMutableArray *dataArray = [GMCache fetchObjectAtDocumentPathWithkey:PhobosTempCacheKeyStr];
if (_logEnabled) { if (_logEnabled) {
NSData *data = [NSJSONSerialization dataWithJSONObject:dataArray options:NSJSONWritingPrettyPrinted error:nil]; NSData *data = [NSJSONSerialization dataWithJSONObject:dataArray options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
...@@ -498,7 +529,7 @@ static NSString *sdkVersion = @"110"; ...@@ -498,7 +529,7 @@ static NSString *sdkVersion = @"110";
if (compressedData) { if (compressedData) {
[PhobosUtil sendData:compressedData currentAPI:currentAPI success:^(NSInteger code) { [PhobosUtil sendData:compressedData currentAPI:currentAPI success:^(NSInteger code) {
phobosLog(@"✈ ---------- ✈ data arrived Mars"); phobosLog(@"✈ ---------- ✈ data arrived Mars");
[GMCache removeObjectAtDocumentPathWithkey:PhobosTempCacheKey]; [GMCache removeObjectAtDocumentPathWithkey:PhobosTempCacheKeyStr];
}]; }];
} }
} }
...@@ -540,18 +571,18 @@ static NSString *sdkVersion = @"110"; ...@@ -540,18 +571,18 @@ static NSString *sdkVersion = @"110";
- (void)sendArray:(NSArray *)array currentAPI:(NSString *)currentAPI cleanCacheRightNow:(BOOL)clean { - (void)sendArray:(NSArray *)array currentAPI:(NSString *)currentAPI cleanCacheRightNow:(BOOL)clean {
@try { @try {
//1.获取缓存区的数据,把新数据追加进去 //1.获取缓存区的数据,把新数据追加进去
NSString *PhobosTempCacheKeyStr = [PhobosUtil MD5String:[PhobosUtil MD5String:currentAPI]]; // 两次加密作为key值,和缓存的key值作区分
NSMutableArray *dataArray = [GMCache fetchObjectAtDocumentPathWithkey:PhobosTempCacheKey]; NSMutableArray *dataArray = [GMCache fetchObjectAtDocumentPathWithkey:PhobosTempCacheKeyStr];
if (dataArray) { if (dataArray) {
[dataArray addObjectsFromArray:array]; [dataArray addObjectsFromArray:array];
}else{ }else{
dataArray = [NSMutableArray arrayWithArray:array]; dataArray = [NSMutableArray arrayWithArray:array];
} }
[GMCache storeObjectAtDocumentPathWithkey:PhobosTempCacheKey object:dataArray]; [GMCache storeObjectAtDocumentPathWithkey:PhobosTempCacheKeyStr object:dataArray];
//2.把缓存区的数据发送给服务器 //2.把缓存区的数据发送给服务器
[self sendArrayWithCurrentAPI:currentAPI]; [self sendArrayWithCurrentAPI:currentAPI];
//3.把原有的数据删除 //3.把原有的数据删除
[GMCache removeObjectAtDocumentPathWithkey:PhobosCacheKey]; [GMCache removeObjectAtDocumentPathWithkey:[PhobosUtil MD5String:currentAPI]];
} }
@catch (NSException *exception) { @catch (NSException *exception) {
phobosLog(exception); phobosLog(exception);
...@@ -575,4 +606,13 @@ static NSString *sdkVersion = @"110"; ...@@ -575,4 +606,13 @@ static NSString *sdkVersion = @"110";
}); });
} }
- (void)addNewApi:(NSString *)api {
for (NSString *item in self.APIArray) {
if ([api isEqualToString:item]) {
break;
}
[self.APIArray addObject:api];
}
}
@end @end
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define PhobosEndTime @"PhobosEndTime" //记录APP退出|退到后台时的时间戳 #define PhobosEndTime @"PhobosEndTime" //记录APP退出|退到后台时的时间戳
#define PhobosCacheKey @"PhobosCacheKey" //存放持久化埋点数据的key #define PhobosCacheKey @"PhobosCacheKey" //存放持久化埋点数据的key
#define PhobosTempCacheKey @"PhobosTempCacheKey" //临时存放待发送埋点数据的key #define PhobosTempCacheKey @"PhobosTempCacheKey" //临时存放待发送埋点数据的key
#define PhobosShardCount 50 //收集数据分段发送的个数 #define PhobosShardCount 50 //收集数据分段发送的个数
#endif /* PhobosConfig_h */ #endif /* PhobosConfig_h */
...@@ -61,12 +61,12 @@ ...@@ -61,12 +61,12 @@
/** /**
首页tab名称 首页tab名称
*/ */
@property (nonatomic, copy) NSString *homeTabName; @property (nonatomic, copy) NSString *tabName;
/** /**
获取上一个页面的tab名称 获取上一个页面的tab名称
*/ */
@property (nonatomic, copy) NSString *currentTabName; @property (nonatomic, copy) NSString *referrerTabName;
/** /**
is_push:判断是否是推送标识 is_push:判断是否是推送标识
......
...@@ -80,7 +80,10 @@ typedef void (^SendDataSuccessBlock)(NSInteger code); ...@@ -80,7 +80,10 @@ typedef void (^SendDataSuccessBlock)(NSInteger code);
+ (NSString *)deviceRunTime; + (NSString *)deviceRunTime;
/**
* MD5加密
*/
+ (NSString *)MD5String:(NSString *)str;
@end @end
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#import <mach/machine.h> #import <mach/machine.h>
#import "sys/utsname.h" #import "sys/utsname.h"
#import "Phobos.h" #import "Phobos.h"
#import <CommonCrypto/CommonCryptor.h>
#import <CommonCrypto/CommonDigest.h>
#define IOS_CELLULAR @"pdp_ip0" #define IOS_CELLULAR @"pdp_ip0"
#define IOS_WIFI @"en0" #define IOS_WIFI @"en0"
...@@ -427,4 +429,21 @@ ...@@ -427,4 +429,21 @@
return [NSString stringWithFormat:@"%ld", uptime]; return [NSString stringWithFormat:@"%ld", uptime];
} }
+ (NSString *)MD5String:(NSString *)str
{
if(str == nil || [str length] == 0)
return nil;
const char *value = [str UTF8String];
unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH];
CC_MD5(value, (uint32_t)strlen(value), outputBuffer);
NSMutableString *outputString = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++){
[outputString appendFormat:@"%02x",outputBuffer[count]];
}
return outputString;
}
@end @end
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- (void)initReferrerIdIfNil; - (void)initReferrerIdIfNil;
/** /**
此方法在onPvStart时调用,给currentTabName赋值 此方法在onPvStart时调用,给referrerTabName赋值
*/ */
- (void)initHomeTabName; - (void)initReferrerTabName;
@end @end
...@@ -46,11 +46,11 @@ ...@@ -46,11 +46,11 @@
} }
/** /**
此方法在onPvStart时调用,给currentTabName赋值,来源为首页时,才给currentTabName赋值,因为首页的pageName为home或者zone_v3,聚合页的pageName也是zone_v3,所以根据referer判断来源可能为首页或者聚合页,但是只有首页有tab名称,所以currentTabName为首页tab名称 此方法在onPvStart时调用,给referrerTabName赋值
*/ */
- (void)initHomeTabName { - (void)initReferrerTabName {
// 只有不为空,且是controller的情况下才自动获取 // 只有是controller的情况下才自动获取
if (([self.referer isEqualToString:@"home"] || [self.referer isEqualToString:@"zone_v3"]) && [self isKindOfClass:[UIViewController class]]) { if ([self isKindOfClass:[UIViewController class]]) {
// 分present与navigation两种情况 // 分present与navigation两种情况
UIViewController *me = (UIViewController *)self; UIViewController *me = (UIViewController *)self;
if (me.presentingViewController != nil) { if (me.presentingViewController != nil) {
...@@ -58,13 +58,9 @@ ...@@ -58,13 +58,9 @@
// 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController // 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController
if ([me.presentingViewController isKindOfClass:[UINavigationController class]]) { if ([me.presentingViewController isKindOfClass:[UINavigationController class]]) {
UIViewController *top = ((UINavigationController *)me.presentingViewController).topViewController; UIViewController *top = ((UINavigationController *)me.presentingViewController).topViewController;
if (![top.homeTabName isEqualToString:@""]) { objc_setAssociatedObject(self, @selector(referrerTabName), top.tabName, OBJC_ASSOCIATION_COPY);
objc_setAssociatedObject(self, @selector(currentTabName), top.homeTabName, OBJC_ASSOCIATION_COPY);
}
} else { } else {
if (![me.presentingViewController.homeTabName isEqualToString:@""]) { objc_setAssociatedObject(self, @selector(referrerTabName), me.presentingViewController.tabName, OBJC_ASSOCIATION_COPY);
objc_setAssociatedObject(self, @selector(currentTabName), me.presentingViewController.homeTabName, OBJC_ASSOCIATION_COPY);
}
} }
} else { } else {
NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers; NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers;
...@@ -73,9 +69,7 @@ ...@@ -73,9 +69,7 @@
return ; return ;
} }
UIViewController *controller = navigationPool[refererIndex]; UIViewController *controller = navigationPool[refererIndex];
if (![controller.homeTabName isEqualToString:@""]) { objc_setAssociatedObject(self, @selector(referrerTabName), controller.tabName, OBJC_ASSOCIATION_COPY);
objc_setAssociatedObject(self, @selector(currentTabName), controller.homeTabName, OBJC_ASSOCIATION_COPY);
}
} }
} }
} }
...@@ -169,22 +163,22 @@ ...@@ -169,22 +163,22 @@
return extraParam == nil ? @"" : extraParam; return extraParam == nil ? @"" : extraParam;
} }
- (void)setHomeTabName:(NSString *)homeTabName { - (void)setTabName:(NSString *)tabName {
objc_setAssociatedObject(self, @selector(homeTabName), homeTabName, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(tabName), tabName, OBJC_ASSOCIATION_COPY);
} }
- (NSString *)homeTabName { - (NSString *)tabName {
NSString *homeTabName = objc_getAssociatedObject(self, @selector(homeTabName)); NSString *tabName = objc_getAssociatedObject(self, @selector(tabName));
return homeTabName == nil ? @"" : homeTabName; return tabName == nil ? @"" : tabName;
} }
- (void)setCurrentTabName:(NSString *)currentTabName { - (void)setReferrerTabName:(NSString *)referrerTabName {
objc_setAssociatedObject(self, @selector(currentTabName), currentTabName, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(referrerTabName), referrerTabName, OBJC_ASSOCIATION_COPY);
} }
- (NSString *)currentTabName { - (NSString *)referrerTabName {
NSString *currentTabName = objc_getAssociatedObject(self, @selector(currentTabName)); NSString *referrerTabName = objc_getAssociatedObject(self, @selector(referrerTabName));
return currentTabName == nil ? @"" : currentTabName; return referrerTabName == nil ? @"" : referrerTabName;
} }
- (BOOL)isPush { - (BOOL)isPush {
......
app_identifier "org.cocoapods.demo.GMPhobos-Example" # The bundle identifier of your app app_identifier "" # The bundle identifier of your app
apple_id "wanmeizhensuo@gmail.com" # Your Apple email address apple_id "wanmeizhensuo@gmail.com" # Your Apple email address
team_id "86R4V3XFLU" # Developer Portal Team ID team_id "86R4V3XFLU" # Developer Portal Team ID
# you can even provide different app identifiers, Apple IDs and team names per lane: # you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://github.com/fastlane/fastlane/blob/master/docs/Appfile.md # More information: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Appfile.md
import_from_git(url: 'git@git.gengmei.cc:mobile/JaguarTemplate.git', fastlane_version "2.85.0"
path: 'fastlane/ios_fastfile')
\ No newline at end of file default_platform :ios
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "30"
ENV["FASTLANE_XCODEBUILD_SETTINGS_RETRIES"] = "20"
platform :ios do
MASTER_PATH = "https://github.com/CocoaPods/Specs"
PRIVATE_PATH = "git@git.wanmeizhensuo.com:gengmeiios/GMSpecs.git"
PRIVATE_SPEC = "wanmeizhensuo-gmspecs"
SOURCES = [MASTER_PATH, PRIVATE_PATH]
desc 'Deploy a new version to the App Store'
lane :do_publish_prod do |options|
app_identifier = options[:ios_app_identifier]
scheme = options[:ios_scheme]
version = options[:version]
build = options[:build_number] || Time.now.strftime('%Y%m%d%H%M')
output_directory = options[:ios_output_directory]
output_name = options[:ios_output_name]
plist = options[:ios_plist_file]
branch = options[:git_branch]
git_pull_and_pod
update_build_number(version: build, plist: plist)
gym(scheme: scheme, configuration:'AppStore', clean: true, output_directory: output_directory, output_name: output_name, export_method: 'app-store', silent: true, suppress_xcode_output:true,
export_options: {
provisioningProfiles: {
"com.wanmeizhensuo.ZhengXing" => "user-appstore"
}
})
deliver(force: false, skip_screenshots: true, skip_metadata: true)
git_add(path: '.')
git_commit(path: '.', message: "Update build number to #{build} and upload to itunesconnect")
git_pull
git_push(branch: branch)
end
desc "Release new private pod version"
lane :do_publish_lib do |options|
target_version = options[:version]
podspec_path = options[:ios_podspec_path]
git_pull
pod_repo_update(repo: PRIVATE_SPEC)
#pod_install(repo: PRIVATE_SPEC)
pod_lib_lint(verbose: false, allow_warnings: true, sources: SOURCES, use_bundle_exec: true, fail_fast: true)
version_bump_podspec(path: podspec_path, version_number: target_version) # 更新 podspec
git_commit_all(message: "Bump version to #{target_version}") # 提交版本号修改
add_git_tag(tag: target_version) # 设置 tag
push_to_git_remote # 推送到 git 仓库
pod_push(path: podspec_path, repo: PRIVATE_SPEC, allow_warnings: true, sources: SOURCES) # 提交到 CocoaPods
pod_repo_update(repo: PRIVATE_SPEC)
end
desc 'Publish a beta version'
lane :do_publish_beta do |options|
scheme = options[:ios_scheme]
output_directory = options[:ios_output_directory]
output_name = options[:ios_output_name]
sh('USE_APPSTORE_PODS=true pod install')
gym(scheme: scheme, configuration:'Release', output_directory: output_directory, output_name: output_name, export_method: 'ad-hoc', silent: true, suppress_xcode_output:true, clean: true)
end
desc 'Publish a test version'
lane :do_publish_test do |options|
scheme = options[:ios_scheme]
bundle_identifier = options[:ios_bundle_identifier]
output_directory = options[:ios_output_directory]
output_name = options[:ios_output_name]
version = options[:version]
#git_pull_and_pod
sh('pwd')
sh('git fetch')
sh('git status')
sh('git merge origin/test')
pod_repo_update(repo: PRIVATE_SPEC)
pod_repo_update(repo: "gengmei-gmspecs")
pod_repo_update(repo: "gengmei-gengmeiios-gmspecs")
sh('USE_APPSTORE_PODS=true pod install')
sigh(adhoc: true, username: ENV['FASTLANE_USER'], app_identifier: bundle_identifier)
gym(scheme: scheme, configuration:'Release', output_directory: output_directory, output_name: output_name, export_method: 'ad-hoc', silent: true, suppress_xcode_output:true)
end
private_lane :git_pull_and_pod do |options|
sh('git pull')
pod_repo_update(repo: PRIVATE_SPEC)
pod_repo_update(repo: "gengmei-gmspecs")
pod_repo_update(repo: "gengmei-gengmeiios-gmspecs")
#cocoapods
sh('USE_APPSTORE_PODS=true pod install')
end
error do |lane, exception|
UI.message(exception.message)
end
end
...@@ -8,36 +8,22 @@ Make sure you have the latest version of the Xcode command line tools installed: ...@@ -8,36 +8,22 @@ Make sure you have the latest version of the Xcode command line tools installed:
xcode-select --install xcode-select --install
``` ```
## Choose your installation method: Install _fastlane_ using
```
<table width="100%" > [sudo] gem install fastlane -NV
<tr> ```
<th width="33%"><a href="http://brew.sh">Homebrew</a></td> or alternatively using `brew cask install fastlane`
<th width="33%">Installer Script</td>
<th width="33%">Rubygems</td>
</tr>
<tr>
<td width="33%" align="center">macOS</td>
<td width="33%" align="center">macOS</td>
<td width="33%" align="center">macOS or Linux with Ruby 2.0.0 or above</td>
</tr>
<tr>
<td width="33%"><code>brew cask install fastlane</code></td>
<td width="33%"><a href="https://download.fastlane.tools">Download the zip file</a>. Then double click on the <code>install</code> script (or run it in a terminal window).</td>
<td width="33%"><code>sudo gem install fastlane -NV</code></td>
</tr>
</table>
# Available Actions # Available Actions
## iOS ## iOS
### ios do_deliver_app ### ios do_publish_prod
``` ```
fastlane ios do_deliver_app fastlane ios do_publish_prod
``` ```
Deploy a new version to the App Store Deploy a new version to the App Store
### ios do_release_lib ### ios do_publish_lib
``` ```
fastlane ios do_release_lib fastlane ios do_publish_lib
``` ```
Release new private pod version Release new private pod version
### ios do_publish_beta ### ios do_publish_beta
...@@ -50,11 +36,6 @@ Publish a beta version ...@@ -50,11 +36,6 @@ Publish a beta version
fastlane ios do_publish_test fastlane ios do_publish_test
``` ```
Publish a test version Publish a test version
### ios do_automation_test
```
fastlane ios do_automation_test
```
UI automation test
---- ----
......
module Fastlane
module Actions
class GitCommitAllAction < Action
def self.run(params)
Actions.sh "git commit -am \"#{params[:message]}\""
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Commit all unsaved changes to git."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :message,
env_name: "FL_GIT_COMMIT_ALL",
description: "The git message for the commit",
is_string: true)
]
end
def self.authors
# So no one will ever forget your contribution to fastlane :) You are awesome btw!
["thierry"]
end
def self.is_supported?(platform)
true
end
end
end
end
module Fastlane
module Actions
class PodInstallAction < Action
def self.run(params)
Actions.sh "cd Example && pod install"
Helper.log.info "Successfully pod install ⬆️ ".green
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Update all pods"
end
def self.details
"Update all pods"
end
def self.authors
["thierry"]
end
def self.is_supported?(platform)
true
end
end
end
end
module Fastlane
module Actions
# Updates the local clone of the spec-repo
class PodRepoUpdateAction < Action
def self.run(params)
cmd = []
repo = params[:repo]
result = Actions.sh("pod repo update #{repo}")
UI.success("Successfully pod repo update 💾.")
return result
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Updates the local clone of the spec-repo `NAME`. If `NAME` is omitted this will update all spec-repos in `~/.cocoapods/repos`."
end
def self.details
# Optional:
# this is your chance to provide a more detailed description of this action
"You can use this action to do cool things..."
end
def self.available_options
# Define all options your action supports.
[
FastlaneCore::ConfigItem.new(key: :repo,
description: "Repo",
is_string: false,
verify_block: proc do |value|
end),
]
end
def self.output
# Define the shared values you are going to provide
# Example
[
['POD_REPO_UPDATE_CUSTOM_VALUE', 'A description of what this value contains']
]
end
def self.return_value
# If you method provides a return value, you can describe here what it does
end
def self.authors
# So no one will ever forget your contribution to fastlane :) You are awesome btw!
["thierryxing"]
end
def self.is_supported?(platform)
platform == :ios
end
end
end
end
...@@ -5,67 +5,47 @@ ...@@ -5,67 +5,47 @@
<testcase classname="fastlane.lanes" name="00: Verifying required fastlane version" time="0.001944"> <testcase classname="fastlane.lanes" name="0: Verifying fastlane version" time="0.006597">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="01: default_platform" time="0.001685"> <testcase classname="fastlane.lanes" name="1: default_platform" time="0.001027">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="02: import_from_git" time="0.612755"> <testcase classname="fastlane.lanes" name="2: git_pull" time="1.029505">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="03: git_pull" time="5.061954"> <testcase classname="fastlane.lanes" name="3: pod_repo_update" time="1.344667">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="04: ensure_git_branch" time="0.010085"> <testcase classname="fastlane.lanes" name="4: pod_lib_lint" time="13.854831">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="05: pod_install" time="25.047369"> <testcase classname="fastlane.lanes" name="5: version_bump_podspec" time="0.002562">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="06: pod_lib_lint" time="29.081155"> <testcase classname="fastlane.lanes" name="6: git_commit_all" time="0.038758">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="07: version_bump_podspec" time="0.00294"> <testcase classname="fastlane.lanes" name="7: add_git_tag" time="0.014356">
</testcase> </testcase>
<testcase classname="fastlane.lanes" name="08: git_commit_all" time="0.119181"> <testcase classname="fastlane.lanes" name="8: push_to_git_remote" time="0.080848">
</testcase>
<testcase classname="fastlane.lanes" name="09: add_git_tag" time="0.03676">
</testcase>
<testcase classname="fastlane.lanes" name="10: push_to_git_remote" time="1.677659">
</testcase>
<testcase classname="fastlane.lanes" name="11: pod_push" time="15.992076">
</testcase>
<testcase classname="fastlane.lanes" name="12: pod_repo_update" time="11.590591">
</testcase> </testcase>
......
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