V V
V V

Reputation: 822

Can I use swift programming language to develop framework?

I was wondering whether it is good to use swift programming language to create a framework for iOS application. I doubted how do we expose public interfaces in framework If I use swift. Usually ObjC framework has .h files in header folder inside the framework but swift can't.

See below post from apple https://developer.apple.com/swift/blog/?id=2

enter image description here

Appreciate any response on this post.

Upvotes: 0

Views: 94

Answers (1)

John Difool
John Difool

Reputation: 5732

There are a few limitations regarding distributing Swift libraries, bundles, frameworks, etc...

  1. You will need to document your API as relying on a header files only for developers to peruse won't cut it.

  2. Mixing Swift and Objective-C is easy because of bridge technology but the technology doesn't extend to incompatible types across the bridge (struct is one of them.)

  3. You need to package your Swift libraries in dynamic libraries. There is no way around static libraries in Swift.

  4. Most of the early issues with naming have been ironed out, but there are still some gaps in what's available in foundation.

  5. The C invocation is getting better with and even Swift2 deals with C function pointers in a less obscure way but Swift 2 is not out yet.

  6. Some esoteric things you are used to with Objective-C are harder to implement with Swift. If you are going to lose the safety mode of Swift to be able to bit cast your objects, that defeats the purpose.

For most of these reasons, although I love the new language syntax, I chose to continue development of frameworks used in my app with the proven Objective-C and decided to move all the UI stuff in the application side to Swift. When Swift 2 is released, I will then reconsider this choice.

Upvotes: 1

Related Questions