1

Recently started work on an iOS project, written in swift and objective-c. As of now, we have a monolithic repo. Now we are focusing on creating few frameworks so that we can reuse same framework across multiple apps. I would like to know your opinion on below points.

  1. If I add framework.xcodeproj in my client app project, I'm able to access the framework's public entities after writing the import statement. My concern is every time I build by client app project, this framework.xcodeproj is also compiling though its has not changed since last build nor it is dependent on any other framework.

  2. If I add framework by adding it as framework.framework and make its entry into embed framework, I can access the public entities of the framework. What's alarming in this case is that whenever I change the code of framework I need to update the framework in the client app project too.

Is there any way to include framework in client app project where I can access the public entities and it does not get build every time I build client app project ?

It's absolutely fine if framework get's build when its code is updated.

I have used Visual studio in past which let me build my client project without building dependent projects if there is not code change in dependent projects.

Honey
  • 24,125
  • 14
  • 123
  • 212
107
  • 532
  • 3
  • 26

1 Answers1

2

If the framework is build every time you build your app, depends on the type of the framework:

There are Cocoa Touch Static Libraries and Cocoa Touch Frameworks.

Cocoa Touch Frameworks

They are always open-source and will be built just like your app. (So Xcode will sometimes compile it, when you run your app and always after you cleaned the project.) Frameworks only support iOS 8 and newer, but you can use Swift and Objective-C in the framework.

Cocoa Touch Static Libraries

As the name says, they are static. So they are already compiled, when you import them to your project. You can share them with others without showing them your code. Note that Static Libraries currently don't support Swift. You will have to use Objective-C within the library. The app itself can still be written in Swift.

Conclusion

If you don't mind using Objective-C, Static Libraries seem to fit your requirement, that the framework should only be built once.

But since I love Swift, I would personally recommend you to use frameworks (if you don't mind that others that use the framework can see your code). My experience showed, that it's not a big problem, that the framework is built sometimes.


AddThis wrote a good blog post about deciding whether to use Static Libraries or Frameworks.

Cocoa Touch Static Library vs. Cocoa Touch Framework

FelixSFD
  • 5,456
  • 10
  • 40
  • 106