Is Binary XCFramework ready to use with old swift versions?

We're building a new binary framework for iOS (and macOS later). However, we're thinking of building it in Swift, and after some research, and WWDC19 talk, I still missing some details:

  1. Will we be able to ship .xcframework to apps:
    • using old Swift versions? (e.g. Swift 2)
    • using Objective-C?
    • We know that cocoapods 1.9 supports XCFramework, but it's still in beta, how do you think we should distribute the framwork? And SPM support for .xcframework is still in beta..
  2. If .xcframework is not mature enough yet, is the only option now to use the old .framework using Objective-C or can we use write in Swift?
  3. If we use .framework with Swift, what is the minimum Swift version that client should use? Can they use Objective-C?

Thank you and looking for your suggestions..


I'm not at Apple anymore, but I'll chime in some answers:

  • XCFrameworks require Xcode 11, which establishes a baseline on how old a Swift version clients can use.
  • You can definitely use them with Objective-C.
  • One advantage of XCFrameworks over bare frameworks is that they allow bundling together multiple versions of your built framework (usually simulator and device for one platform, but could include more). You don't have to use them, though.
  • The more important thing about distributing a Swift framework is to use the "Build Libraries for Distribution" build setting, which also requires Xcode 11. Slava wrote more about this in a recent blog post.
  • Note that you can still mix language modes in a project in Xcode 11: your framework can be written using "Swift 5 mode" and clients still on "Swift 4 mode" can use it.
1 Like

Thanks @jrose

To clarify, I understand:

  • We and our clients should use Xcode 11.0+ only.
  • We can write the entire binary framework in Swift, without any mapping in Objective-C.
  • The framework client can use Objective-C or Swift 4.0+.
  • We don't have to use lipo anymore, XCFrameworks will bundle a simulator and device build together.

What I think I'm still missing:

  • What tool should we use to distribute the framework?
  • Without lipo, how will we get the dSYM files? Will they be seperate for simulator and device?

Thanks again..

If you use the Archive action to produce your per-product frameworks, as recommended in the talk, the dSYMs will be included in the archive (before making an xcframework from the products). They're not something you usually ship to customers, though…if you were going to give them that much info about your source, you could just ship the framework as source.

Gotcha! I just wanted to know which phase we will get the dSYMs file (for us and not to ship it to the client).

After this discussion, I think we will use the bare frameworks because we will be able to distribute easily to the clients.

Thanks @jrose for all your contributions