carekit-apple / CareKit

CareKit is an open source software framework for creating apps that help people better understand and manage their health.
https://www.researchandcare.org
Other
2.41k stars 444 forks source link

Weak-linking CareKit Still Crashes Simulator Running iOS 8.X #113

Closed abc123s closed 7 years ago

abc123s commented 8 years ago

I know that CareKit requires a base SDK version of 9.0; however, I'd like to make my app compatible with 8.X and use some CareKit features only if the user has a suitable OS.

I've tried weak-linking to CareKit as described in the Apple Developer documentation here by:

(1) Removing CareKit.framework from the list of embedded binar (2) Adding a -weak_framework CareKit tag to my Other Linker Flags under build settings.

However, in an iPhone 6 simulator running iOS 8.1, I still get the below error:

dyld: Library not loaded: /System/Library/Frameworks/Contacts.framework/Contacts
  Referenced from: /Users/[user_name]/Library/Developer/Xcode/DerivedData/[app_name]-cecnsonzjscqnegcruvepczrvlvo/Build/Products/Debug-iphonesimulator/CareKit.framework/CareKit
  Reason: no suitable image found.  Did find:
    /System/Library/Frameworks/Contacts.framework/Contacts: mach-o, but not built for iOS simulator
(lldb) 

Is this an issue with the simulator specifically? Is there another way to use CareKit while otherwise making my app compatible with 8.X?

umerkhan-apple commented 7 years ago

Unfortunately, CareKit is only supported with iOS 9.0 and onwards. However, weak-linking should work if set up properly. It seems that since CareKit references the Contacts.framework, it might be worth trying to add the Contacts.framework to your project and see if that resolves the issue.

I would also recommend debugging on a device and see if the issues reproduces.

abc123s commented 7 years ago

Thanks for the advice - that did it!

For anyone else who stumbles upon this in the future, in addition to adding (weak-linking) Contacts.framework, it seems that you also need to add CoreFoundation.framework too.

hatjs880328s commented 5 years ago

666