iOS info.plist 获取与解读

最近决定捋一遍iOS基础,先从项目的配置说起吧


    // 方法一,获取文件的全部路径, 解析 info.plist

    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"Info.plist" ofType:nil];

    NSDictionary *infoDic = [NSDictionary dictionaryWithContentsOfFile:filePath];

    

    //方法二  直接获取

    NSDictionary *infoDicNew = [NSBundle mainBundle].infoDictionary;

    NSLog(@"info.plist %@",infoDicNew);



    

    // 综上所述, 方法2是系统对方法一的一个封装

    

 info.plist 实则是一个字典,可在Xcode中可视化。 获取 系统版本、BundleID 等都需要用到


2018-03-26 17:39:49.874458+0800 test[5712:549958] info.plist {

    BuildMachineOSBuild = 17D47;

    CFBundleDevelopmentRegion = en;

    CFBundleExecutable = test;

    CFBundleIdentifier = "com.sht.test";

    CFBundleInfoDictionaryVersion = "6.0";

    CFBundleName = test;

    CFBundleNumericVersion = 16809984;

    CFBundlePackageType = APPL;

    CFBundleShortVersionString = "1.0";

    CFBundleSupportedPlatforms =     (

        iPhoneSimulator

    );

    CFBundleVersion = 1;

    DTCompiler = "com.apple.compilers.llvm.clang.1_0";

    DTPlatformBuild = "";

    DTPlatformName = iphonesimulator;

    DTPlatformVersion = "11.2";

    DTSDKBuild = 15C107;

    DTSDKName = "iphonesimulator11.2";

    DTXcode = 0920;

    DTXcodeBuild = 9C40b;

    LSRequiresIPhoneOS = 1;

    MinimumOSVersion = "11.2";

    UIDeviceFamily =     (

        1,

        2

    );

    UILaunchStoryboardName = LaunchScreen;

    UIMainStoryboardFile = Main;

    UIRequiredDeviceCapabilities =     (

        armv7

    );

    UISupportedInterfaceOrientations =     (

        UIInterfaceOrientationPortrait,

        UIInterfaceOrientationLandscapeLeft,

        UIInterfaceOrientationLandscapeRight

    );

}


你可能感兴趣的:(iOS,OC)