ioscocoapodscarthagexcframeworkios-universal-framework

Do we need to create iOS Universal Frameworks for CocoaPods and Carthage?


  1. Is my understanding correct, that we need to manually create Universal Frameworks/Libraries only if we distribute our libs by providing binaries (let's say directly download .framework)? So if we distribute using CocoaPods or Carthage, these tools will create Universal Frameworks/Libraries from our source code by themselves, right?

  2. As I understand, CocoaPods & Carthage allow to hide source code by distributing only binaries. Does that mean that in this case we need to create Universal Frameworks/Libraries by ourselves before using these services?

  3. What's the best way to create Universal Frameworks/Libraries in 2020, XCFramework?

Thanks.


Solution

    1. If you distribute your source code with CocoaPods or Carthage, these systems will make your source code compiling either into .framework or into static library on the consumer side while the consumer’s project builds. Consumers will have access to your source code.

    2. Yes.

    3. If your framework is intended to be used in Mac Catalyst apps - then XCFramework is the only choice. Otherwise, you can still ship fat framework - old, but gold.

    UPDATE:

    With AppleSilicon, XCFramework becomes the only format in which you should ship your prebuilt framework, because even iOS simulator now should support both x86_64 and arm64 architectures.