天天看點

iOS 擷取程式~項目app名稱、版本号、build版本

//聯系人:石虎 QQ:1224614774 昵稱:嗡嘛呢叭咪哄

一、圖形展示

圖1:

iOS 擷取程式~項目app名稱、版本号、build版本

圖2:

iOS 擷取程式~項目app名稱、版本号、build版本

二、代碼實作

//

//  ViewController.m

//  自動增減算法

//

//  Created by 石虎 on 2017/9/29.

//  Copyright © 2017年 石虎. All rights reserved.

//

#import "ViewController.h"

@interface ViewController ()

@end

#define APP_NAME ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"])

#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

#define APP_BUILD ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"])

#define APP_USER_AGENT [NSString stringWithFormat:@"石虎/%@ (%@;U;%@ %@;%@/%@)", \

APP_VERSION, DeviceModel, DeviceSystemName, DeviceVersion, DeviceLocal, DeviceLang]

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    NSLog(@"擷取APP名稱 === %@,程式版本号===,%@,擷取APP build版本==,%@",APP_NAME,APP_VERSION,APP_BUILD);

}

@end

三、列印結果

列印: 2017-10-0915:05:03.296 自動增減算法[44032:2027891] 擷取APP名稱 === shihu ,程式版本号===,1.0.2,擷取APP build版本==,12345

四、下載下傳 demo 連結

  請聯系本人,代碼會釋出在 GitHub 或者是碼雲上;

謝謝!!!