Sharing code between original iOS App and App Extension Sharing code between original iOS App and App Extension ios ios

Sharing code between original iOS App and App Extension


Nothing should be copied. Just add required files to compile sources for your extension:

enter image description here


Just make sure that the files you want to share gets a tick in the section Target Membership.

Select your file, open the utility panel on the right and tick the appropriate target under Target Membership.

enter image description here


Embedded frameworks are a great way to reuse code between your application and your extension. Having moved some of the code to embedded frameworks will provide us with a great opportunity to write some unit tests around it.

See section Using an Embedded Framework to Share Codehttps://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1