iOS extensions with multiple targets

Enzo Tran picture Enzo Tran · Aug 20, 2014 · Viewed 14.8k times · Source

In iOS 8, when we create an app extension, we have to decide which target it is attached to. The extension will have the same bundle ID's prefix as the target.

  1. Is there any way to change the target afterward?
  2. If my project contains 2 (or more) targets (for example one for debug/simulator, one for production/device), what's the best way to work with extensions? Do I need to create another extension and duplicate the code (very bothersome to keep the same code for both targets)?

Answer

malex picture malex · Mar 23, 2016

To share one widget with others targets, you only need to add widget.appex target to Embedded Binaries for every parent target in General configuration tab

enter image description here

Then you'll get Embed App Extensions area at Build Phases automatically

enter image description here