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 !

5 Answers 5

7

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)
Sign up to request clarification or add additional context in comments.

Comments

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

3 Comments

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
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 ?
in my case the path to binary was slightly different: otool -l /path/to/your/FrameworkName.framework/FrameworkName
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.

1 Comment

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.
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)

Comments

0

Personally, I go with something like:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.