React-native-device-info: Make it build with iOS App Extensions

Created on 5 Mar 2018  路  3Comments  路  Source: react-native-device-info/react-native-device-info

Summary

| | |
| ----------- | --- |
| Version | 17.3 |
| Affected OS | ios |
| OS Version | 11.2 |

Current behavior

When using react-native-device-info in an iOS App Extension it fails to build because sharedApplication is referenced once RNDeviceInfo.m:207:

'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

Expected behavior

Would love for it to be able to build. And since it's only one line I'm guessing it could be potentially simple. Not an Objective-C pro though - so I don't know how! :)

enhancement feedback-requested has PR help wanted ios

Most helpful comment

This may be fixed shortly - has a PR in feedback stage

All 3 comments

Thank you for logging this issue! Not an objective-c guy neither, so any help would be appreciated :)

There's no way to do this automatically that I know of. You need an #ifdef around it, something like:

#ifndef APP_EXTENSION
    // Reference sharedApplication here
#endif

and then document for users the need to add this define to their build settings, typically in XCode in "Custom Compiler Flags" for that target:

#define APP_EXTENSION YES

I'm working on an app that has an extension in it, but won't be touching the extension for another week or two. If this issue is still open when I get around to that module, I'll try to submit a PR for it.

This may be fixed shortly - has a PR in feedback stage

Was this page helpful?
0 / 5 - 0 ratings