9

A third part company has provide me a Framework. I would like to check the swift version embedded in the framework (2.2, 2.3 or 3.x) The framework directory include libswift dylib files.

How to check the swift version used in the framework ?

Thanks !

lafalex
  • 126
  • 1
  • 7

5 Answers5

5

You can use otool to print all versions of included binaries in the framework:

otool -l /path/to/your/FrameworkName.framework/Versions/A/FrameworkName
Oskar
  • 3,064
  • 2
  • 21
  • 33
  • `Load command 48 cmd LC_LOAD_DYLIB cmdsize 60 name @rpath/libswiftCoreLocation.dylib (offset 24) time stamp 2 Thu Jan 1 01:00:02 1970 current version 703.0.18 compatibility version 1.0.0` – lafalex Apr 21 '17 at 10:09
  • 1
    Thanks for your reply. This is the output for otool for 1 dylib library. How to know if swift version used is swift 2.2, swift 2.3 or swift 3 ? – lafalex Apr 21 '17 at 10:12
  • in my case the path to binary was slightly different: `otool -l /path/to/your/FrameworkName.framework/FrameworkName` – Alexey Strakh Nov 18 '19 at 23:43
5

You can use Oskars answer to get the swiftlang version (in your case: 703.0.18).

Now you just have to lookup for the Swift version in the following table:

Swiftlang version            Swift version
-                            -
swiftlang-602.0.49.3         1.2
swiftlang-602.0.49.6         1.2
swiftlang-602.0.53.1         1.2
swiftlang-700.0.59           2.0
swiftlang-700.1.101.6        2.1
swiftlang-700.1.101.15       2.1.1
swiftlang-703.0.18.1         2.2
swiftlang-703.0.18.8         2.2
swiftlang-800.0.46.2         3.0
swiftlang-800.0.58.6         3.0.1
swiftlang-800.0.63           3.0.2
swiftlang-802.0.48           3.1
swiftlang-802.0.51           3.1
swiftlang-802.0.53           3.1

Source: Wikipedia

So 703.0.18 means Swift version 2.2.

illaz
  • 51
  • 4
  • Note that otool -l did not work for me, as the framework did not have a Versions folder. I used otool -L on the binary within instead. – Roy Falk Apr 03 '18 at 07:22
5

I used the -Swift.h Header file.

$ cat FrameworkName.framework/Headers/FrameworkName-Swift.h

First line is the information you need:

// Generated by Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
btype
  • 1,510
  • 18
  • 30
0

If framework supports ABI[About] Module Stability and Library Evolution you also can find it. From Swift v5.1

<framework.name>.framework -> Modules -> <framework.name>.swiftmodeule -> <arch>. swiftinterface

For example x86_64.swiftinterface

// swift-compiler-version: Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)
yoAlex5
  • 13,571
  • 5
  • 105
  • 98
0

Personally, I go with something like:

grep "Generated by" Carthage/Build/iOS/Alamofire.framework/Headers/Alamofire-Swift.h

mc7h
  • 192
  • 7