2

To begin: I read the other questions here, but they are stating that e.g. Swift cannot be used in a Framework or/and Library or are outdated (5 years old).

What are the advantages and downsides of a Cocoa Touch Framework vs. a Cocoa Touch Static Library for achieving this?

I´m trying to share code between two iOS targets, e.g. an iPhone target and an iPad target (Universal target is not wanted here).

If I understand it correctly, the Static Library and the app code will be merged together into one Binary, while the combination of Framework and app code will be two binaries. I guess this means more signing and more DSYM files to upload to crash reporting tools?

Also, a Framework should/could also work standalone while a Static Library always needs other code.

What about Tests, Distribution to the App Store, Debugging (Breakpoints) and compile time? Which option performs better for what task?

stk
  • 6,311
  • 11
  • 42
  • 58

1 Answers1

4

Some clarifications of Static vs Dynamic Frameworks: iOS Static vs Dynamic frameworks clarifications

Language: As for the use of Swift, before you couldn't create a Static Library with it, but from Xcode 9 onwards you can. So I guess Swift vs. ObjC wouldn't be a problem. Haven't found any tutorials on creating Static Libraries with Swift, just for creating Frameworks (for example: https://www.raywenderlich.com/5109-creating-a-framework-for-ios). So maybe a Framework would be easier in terms of finding resources/references.

dSYM: Citing an answer from an Apple Staff: "If you are building the framework as a dependency of your app target, the dSYMs for the framework will be present in the archive you create when archiving the app for distribution. If you are using a framework provided by a vendor that is already compiled, you will need to contact the framework vendor about the dSYMs." (https://forums.developer.apple.com/thread/70716). As for Static Libraries, they would be less work in terms of the dSYMs you handle. (Why does not Xcode generate dSYM for static library)

Codesigning for Frameworks: "Developer is free to distribute iOS framework without codesigning it as Consumer will re-codesign it anyway, but Developer is forced by Xcode to codesign their framework when they build for iOS device" (Creating iOS/OSX Frameworks: is it necessary to codesign them before distributing to other developers?)

As for Tests, adding the Framework or the Static Library on your Unit Testing target's build phases should do the job.

Breakpoints: Static Libraries: Debugging a static library in Xcode Frameworks: Xcode 9 - Framework breakpoints

For what I've read in the links, although Static Libraries might be a little more efficient, Frameworks are a lot less work to set up.

Victor Sanchez
  • 960
  • 2
  • 12
  • 26