|
6 | 6 |
|
7 | 7 | #import <Foundation/Foundation.h>
|
8 | 8 | #import <React/RCTLog.h>
|
9 |
| -#import <onnxruntime/onnxruntime_cxx_api.h> |
10 | 9 |
|
| 10 | +// Note: Using below syntax for including ort c api and ort extensions headers to resolve a compiling error happened |
| 11 | +// in an expo react native ios app when ort extensions enabled (a redefinition error of multiple object types defined |
| 12 | +// within ORT C API header). It's an edge case that compiler allows both ort c api headers to be included when #include |
| 13 | +// syntax doesn't match. For the case when extensions not enabled, it still requires a onnxruntime prefix directory for |
| 14 | +// searching paths. Also in general, it's a convention to use #include for C/C++ headers rather then #import. See: |
| 15 | +// https://google.github.io/styleguide/objcguide.html#import-and-include |
| 16 | +// https://microsoft.github.io/objc-guide/Headers/ImportAndInclude.html |
11 | 17 | #ifdef ORT_ENABLE_EXTENSIONS
|
12 |
| -extern "C" { |
13 |
| -// Note: Declared in onnxruntime_extensions.h but forward declared here to resolve a build issue: |
14 |
| -// (A compilation error happened while building an expo react native ios app, onnxruntime_c_api.h header |
15 |
| -// included in the onnxruntime_extensions.h leads to a redefinition conflicts with multiple object defined in the ORT C |
16 |
| -// API.) So doing a forward declaration here instead of #include "onnxruntime_extensions.h" as a workaround for now |
17 |
| -// before we have a fix. |
18 |
| -// TODO: Investigate if we can include onnxruntime_extensions.h here |
19 |
| -OrtStatus *RegisterCustomOps(OrtSessionOptions *options, const OrtApiBase *api); |
20 |
| -} // Extern C |
| 18 | +#include "onnxruntime_cxx_api.h" |
| 19 | +#include "onnxruntime_extensions.h" |
| 20 | +#else |
| 21 | +#include "onnxruntime/onnxruntime_cxx_api.h" |
21 | 22 | #endif
|
22 | 23 |
|
23 | 24 | @implementation OnnxruntimeModule
|
|
0 commit comments