iOS info.plist 獲取與解讀
最近決定捋一遍iOS基礎,先從專案的配置說起吧
// 方法一,獲取檔案的全部路徑, 解析 info.plist
NSString *filePath = [[NSBundlemainBundle]pathForResource:@"Info.plist"ofType:nil];
NSDictionary *infoDic = [NSDictionary dictionaryWithContentsOfFile:filePath];
//方法二 直接獲取
NSDictionary *infoDicNew = [NSBundlemainBundle].infoDictionary;
NSLog(@"info.plist %@"
// 綜上所述, 方法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
);
}