Find a deployment target during runtime framework that I cannot recompile

It is quite difficult to determine the deployment target for the application at compile time with the __IPHONE_OS_VERSION_MIN_REQUIRED macro. He is also directly looking for the current version of iOS that the application is working on at runtime. I am trying to figure out the purpose of deploying an application at runtime. I need to use this in a structure that is already compiled. Is there a public API method to define this? I can not find him.

Just to be clear. I want to get the deployment target for an iOS application at runtime from my system. DO NOT compile time. In my framework, I need to warn the user about the structure that some functions will not work if their deployment goal is too far back.

I get that this is easy to do at compile time, but my framework is already compiled, and I don't want the framework user to add macros to their code for their infrastructure to determine their deployment purpose.

+5
source share
2 answers

I do not understand why this code will not work for you!

NSLog(@"Deployment target: %i", __IPHONE_OS_VERSION_MIN_REQUIRED); 
0
source

This is an old question, but I just checked the answer like this:

On iOS, you must use the MinimumOSVersion key in Info.plist to find the minimum supported version at runtime.

The source is actually related to the documentation published by Josh Caswell , near LSMinimumSystemVersion .

Please note that in the documentation he explains that you, as a developer, should not set the MinimumOSVersion value yourself, and that this will be automatically populated by you Xcode during the build. This explains the rather cryptic "Do Not Use" in another part of this documentation.

Carrying out a description of this key here, for posterity (December 2016), in case of a change in documentation:

MinimumOSVersion (String - iOS). When you create an iOS application, Xcode uses the iOS Deployment Destination option for the project to set the MinimumOSVersion key. Do not specify this key yourself in the Info.plist file; This is a system key. When you publish your application on the App Store, the repository indicates the versions of iOS on which your application can run based on this key. This is equivalent to the LSMinimumSystemVersion key on macOS.

I checked this by printing the value in a test application (and changing the deployment target of the Xcode project to different values:

 if let infoPlist = Bundle.main.infoDictionary { let minimumVersion = infoPlist["MinimumOSVersion"] if let minimumVersion = minimumVersion { print("Minimum version is \(minimumVersion)") } } 
0
source

Source: https://habr.com/ru/post/1200347/