[NSBundle mainBundle] 详解

来源:互联网 发布:js 封装自定义组件 编辑:程序博客网 时间:2024/05/23 01:27

我们可以通过包的信息的数据字典 得到 应用的版本 CFBundleVersion = "1.3";

 let key ="CFBundleVersion"

        // 获得当前软件的版本号

        let currentVersion = NSBundle.mainBundle().infoDictionary![key]?.integerValue

        // 打印当前软件版本信息

        print(NSBundle.mainBundle().infoDictionary)

NSLog(@"ios 应用发布后 .app 应用文件 路径::%@",[NSBundle mainBundle] );

NSLog(@"ios 应用发布后 .app 应用包(文件) 的详细信息 ::%@",[[NSBundle mainBundle] infoDictionary]);

[[NSBundle mainBundle] infoDictionary] 返回的是一个数据字典内容如下:


Optional(["CFBundleExecutable": WBBaiSiDemo, "DTPlatformVersion": 9.2, "UISupportedInterfaceOrientations": (

    UIInterfaceOrientationPortrait

), "UILaunchImages": (

        {

        UILaunchImageMinimumOSVersion = "8.0";

        UILaunchImageName = "Brand Assets-800-Portrait-736h";

        UILaunchImageOrientation = Portrait;

        UILaunchImageSize = "{414, 736}";

    },

        {

        UILaunchImageMinimumOSVersion = "8.0";

        UILaunchImageName = "Brand Assets-800-667h";

        UILaunchImageOrientation = Portrait;

        UILaunchImageSize = "{375, 667}";

    },

        {

        UILaunchImageMinimumOSVersion = "7.0";

        UILaunchImageName = "Brand Assets-700";

        UILaunchImageOrientation = Portrait;

        UILaunchImageSize = "{320, 480}";

    },

        {

        UILaunchImageMinimumOSVersion = "7.0";

        UILaunchImageName = "Brand Assets-700-568h";

        UILaunchImageOrientation = Portrait;

        UILaunchImageSize = "{320, 568}";

    }

), "DTSDKName": iphonesimulator9.2, "CFBundleName": WBBaiSiDemo, "DTSDKBuild": 13C75, "CFBundleNumericVersion": 33587200, "CFBundleIdentifier": ---.WBBaiSiDemo, "CFBundleSupportedPlatforms": (

    iPhoneSimulator

), "CFBundleSignature": ????, "UIRequiredDeviceCapabilities": (

    armv7

), "DTXcode": 0721, "LSRequiresIPhoneOS": 1, "CFBundleInfoPlistURL": Info.plist -- file:///Users/rrd/Library/Developer/CoreSimulator/Devices/0A1EFEF5-85D9-4E24-B122-8E4A478E3FC3/data/Containers/Bundle/Application/3BCA746D-AD65-4152-BCC0-842DBF5393B5/WBBaiSiDemo.app/, "DTCompiler": com.apple.compilers.llvm.clang.1_0, "BuildMachineOSBuild": 14F1605, "CFBundleShortVersionString": 1.0, "CFBundleVersion": 2, "CFBundlePackageType": APPL, "CFBundleInfoDictionaryVersion": 6.0, "NSAppTransportSecurity": {

    NSAllowsArbitraryLoads = 1;

}, "DTXcodeBuild": 7C1002, "CFBundleDevelopmentRegion": en, "DTPlatformName": iphonesimulator, "CFBundleIcons": {

    CFBundlePrimaryIcon =     {

        CFBundleIconFiles =         (

            AppIcon29x29,

            AppIcon40x40,

            AppIcon57x57,

            AppIcon60x60

        );

    };

}, "DTPlatformBuild": , "MinimumOSVersion": 9.2, "UIDeviceFamily": (

    1

)])




0 0
原创粉丝点击