The Battle for Wesnoth  1.17.0-dev
apple_version.mm
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018 - 2021
3  by Martin HrubĂ˝ <hrubymar10@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #ifdef __APPLE__
17 
18 #include "apple_version.hpp"
19 
20 #import "game_version.hpp"
21 
22 #if defined(__APPLE__) && defined(__MACH__) && defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
23 #define __IPHONEOS__ (__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__*1000)
24 #endif
25 
26 #import <Foundation/Foundation.h>
27 
28 #if defined(__IPHONEOS__)
29 #import <UIKit/UIKit.h>
30 #endif
31 
32 namespace desktop {
33 namespace apple {
34  std::string os_version() {
35 
36  //
37  // Standard Apple version
38  //
39 
40  std::string version_string = "";
41 
42  NSArray *version_array = [[[NSProcessInfo processInfo] operatingSystemVersionString] componentsSeparatedByString:@" "];
43 
44 #if defined(__IPHONEOS__)
45  std::string version_string = "iOS ";
46 #else
47  const version_info version_info([[version_array objectAtIndex:1] UTF8String]);
48 
49  if (version_info.major_version() == 10 && version_info.minor_version() < 12) {
50  version_string = "Apple OS X ";
51  } else {
52  version_string = "Apple macOS ";
53  }
54 #endif
55 
56  version_string += [[version_array objectAtIndex:1] UTF8String];
57  version_string += " (";
58  version_string += [[version_array objectAtIndex:3] UTF8String];
59 
60  return version_string;
61  }
62 
63 } // end namespace apple
64 } // end namespace desktop
65 
66 #endif //end __APPLE__
Interfaces for manipulating version numbers of engine, add-ons, etc.
unsigned int major_version() const
Retrieves the major version number (x1 in "x1.x2.x3").
unsigned int minor_version() const
Retrieves the minor version number (x2 in "x1.x2.x3").
std::string os_version()
Returns a string with the running OS name and version information.
Definition: version.cpp:217
Represents version numbers.