1

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).

Tsahi Deri
  • 571
  • 1
  • 3
  • 14

1 Answers1

2

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.

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170
  • As for now, I have included all of the shared code in both the app target and the extension target, works fine. But, won't the application be rejected while submitting to App Store ? – Tsahi Deri Mar 15 '15 at 20:00
  • Why would you think that? – Tom Harrington Mar 15 '15 at 23:09
  • Probably Apple has a reason why they recommended to use embedded framework to share code between app extension and its containing app. – Tsahi Deri Mar 15 '15 at 23:21
  • It's good software design practice, when it works. Here it doesn't work. There's no other way to use the code in both places, and I've never heard of Apple caring about this. – Tom Harrington Mar 15 '15 at 23:53
  • What is the Xcode mechanism by which we include a framework in a target for this? – QED Apr 26 '16 at 16:34
  • @TomHarrington i have creates share extension but not able to add embedded library with dlopen.Please help me out. I want my application to be part of ios 7 as well. I am able to run app with ios 8 with embedded library. – Devangi Desai Jun 22 '16 at 07:34