1

I want to retrieve the minimum deployment target in the xcode project. IPHONEOS_DEPLOYMENT_TARGET = 13.2; I wanted to check whether the version is 13.2 or lesser. Is there any way or any command which returns the deployment target. I want to read it from the ruby code.

Honnappa
  • 17
  • 1
  • 6

1 Answers1

0

you can check the target version by below code and perform your desired action

In Swift:

    if #available(iOS 13.2, *) {
        // your code for iOS 13.2 or above versions
    } else {
        // Fallback on earlier versions or your code for earlier versions
    }

In Objective C:

    if (@available(iOS 13.2, *)) {
        // your code for iOS 13.2 or above versions
     } else {
        // Fallback on earlier versions or your code for earlier versions
     }

In Ruby:

Using the plist gem, like this:

require 'plist'
info = Plist.parse_xml('path/to/Info.plist')
puts info["CFBundleShortVersionString"]
puts info["CFBundleVersion"]

Use this reference: How to get target's version by Ruby (or Xcodeproj)

also, https://www.rubydoc.info/gems/xcodeproj/Xcodeproj/Project/Object/XCConfigurationList

Satish Thakur
  • 184
  • 1
  • 14
  • I am trying to read ios applications from the ruby code for some tasks. So i want to get the deployment version from the ruby code. Thanks – Honnappa Jun 02 '20 at 08:29
  • xcodeproj_file = File.read(location + '/*.xcodeproj' + XCODE_PROJECT_FILE_NAME) I am trying to read the ios application project file like this and trying to get the deployment version from this file. Earlier i was thinking to read line by line and try to match IPHONEOS_DEPLOYMENT_TARGET and get the version but now i want to get that version without reading line by line. – Honnappa Jun 02 '20 at 08:49
  • I don't know about Ruby but Why you need to find the deployment target. And the above concept you said also work. You can simply set the minimum target version in code. – Satish Thakur Jun 02 '20 at 08:58
  • I am building an app in my organisation which is in ruby which checks the ios applications deployment versions and if it is less than 13.2 i am failing the scenario. Something for other type of applications too. So i wanted it to be in ruby. Thanks – Honnappa Jun 02 '20 at 09:40
  • @Mahant Please check. Might be it helps you. – Satish Thakur Jun 02 '20 at 10:17