• swift开发之--获取当前应用的配置信息


    希望能把开发做的更细一点,知其然也知其所以然。

    //        获取当前程序可执行文件所在目录
            let mainBundle = Bundle.main
    //        获取程序包的识别标识符。
    //        该标识符是应用程序的唯一标识,应用于标识符之间是一一对应关系。
    //        请注意:应用新建成功后,该标识符将不可修改
            let identifier = mainBundle.bundleIdentifier
    //        获取应用程序包的所有配置信息,并存储在字典对象中
            let info = mainBundle.infoDictionary
    //        获取当前应用程序的名称
            let bundleId = mainBundle.object(forInfoDictionaryKey: "CFBundleName")
    //        获取当前应用的版本号
            let version = mainBundle.object(forInfoDictionaryKey: "CFBundleShortVersionString")
            
    //        控制台打印
            print("[identifier]:(identifier!)")
            print("[info]:(info!)")
            print("[bundleId]:(bundleId!)")
            print("[version]:(version!)")

    控制台打印如下:

    [identifier]:com.yaosecu.DemoApp01
    [info]:["DTPlatformVersion": 14.2, "UIStatusBarStyle": UIStatusBarStyleDarkContent, "CFBundleDevelopmentRegion": en, "CFBundlePackageType": APPL, "UILaunchStoryboardName": LaunchScreen, "LSRequiresIPhoneOS": 1, "MinimumOSVersion": 13.0, "DTXcodeBuild": 12B45b, "UIApplicationSceneManifest": {
        UIApplicationSupportsMultipleScenes = 1;
        UISceneConfigurations =     {
            UIWindowSceneSessionRoleApplication =         (
                            {
                    UISceneConfigurationName = "Default Configuration";
                    UISceneDelegateClassName = "DemoApp01.SceneDelegate";
                    UISceneStoryboardFile = Main;
                }
            );
        };
    }, "DTSDKBuild": 18B79, "CFBundleInfoDictionaryVersion": 6.0, "CFBundleExecutable": DemoApp01, "UIStatusBarHidden": 1, "CFBundleVersion": 1, "CFBundleNumericVersion": 16809984, "CFBundleShortVersionString": 1.0, "CFBundleIdentifier": com.yaosecu.DemoApp01, "CFBundleName": 测试01, "UIDeviceFamily": <__NSArrayM 0x60000284a5e0>(
    1,
    2
    )
    , "UIMainStoryboardFile": Main, "UISupportedInterfaceOrientations": <__NSArrayM 0x60000284a6a0>(
    UIInterfaceOrientationPortrait,
    UIInterfaceOrientationLandscapeLeft,
    UIInterfaceOrientationLandscapeRight
    )
    , "DTCompiler": com.apple.compilers.llvm.clang.1_0, "CFBundleSupportedPlatforms": <__NSArrayM 0x60000284a370>(
    iPhoneSimulator
    )
    , "BuildMachineOSBuild": 19F101, "DTSDKName": iphonesimulator14.2, "DTPlatformBuild": 18B79, "UIRequiresFullScreen": 1, "DTXcode": 1220, "UIRequiredDeviceCapabilities": <__NSArrayM 0x60000284a610>(
    armv7
    )
    , "DTPlatformName": iphonesimulator]
    [bundleId]:测试01
    [version]:1.0

    仅做记录!

  • 相关阅读:
    2016012056+小学四则运算练习软件项目报告
    《构建之法》1,2,16章读后感
    我与软件
    散列函数的应用及其安全性
    EGener2四则运算出题器
    用jar包运行带GUI的java游戏
    关于《构建之法》第四章和第十七章的问题
    2016012070小学四则运算练习软件项目报告
    有关软件工程的一些问题
    300道随机四则运算小程序(java编写)
  • 原文地址:https://www.cnblogs.com/hero11223/p/14097428.html
Copyright © 2020-2023  润新知