Search code examples
iosxcodeios-frameworksios8-extensionios-extensions

Using embedded framework in extension's containing app with deployment target iOS 7.0 and earlier


I'm developing Today Widget Extension for an app with deployment target earlier than iOS 8.0. In apple Extension Programming Guide they recommended to use embedded framework to share code between app extension and its containing app.

You can create an embedded framework to share code between your app extension and its containing app.

In the end of this guide they explain how to deploy a containing app to older versions of iOS 8.0 by using dlopen command.

After I have added the framework target the project doesn't build successfully. It's always failed with the following errors :

  1. Lipo Error : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't open input file: PATH_TO_BUILD/armv7/APP_NAME (No such file or directory)
  2. Apple Mach-O Linker Error : ld: embedded dylibs/frameworks are only supported on iOS 8.0 and later (@rpath/FRAMEWORK_NAME) for architecture armv7

(Error 2 repeats with arm64 architecture)

What I'm doing wrong ?

Is there another way to share code between app extension and its containing app ?

If someone know about the dlopen solution, please input with a "How to" tutorial (examples are welcome).


Solution

  • You can't use embedded frameworks on iOS 7, even with dlopen.

    What they're explaining on that page (and not very clearly) is that if your app uses an embedded framework on iOS 8 and you want to deploy the app on iOS 7, you can't have the framework load automatically on iOS 8. Instead you copy the framework into the app bundle as part of the build process and then, on iOS 8 only use dlopen to load the framework from code.

    On iOS 7, the framework will exist in the app bundle, but iOS 7 does not support loading it into the app by any means, including dlopen

    If you want to share code between an app and an extension and deploy on iOS 7, you cannot use a framework to share the code. You need to include all of the shared code in both the app target and the extension target.