From b527ed417b435071089bf3c807d208db800949c4 Mon Sep 17 00:00:00 2001 From: Nicola Del Gobbo Date: Wed, 20 Mar 2019 23:47:00 +0100 Subject: [PATCH 1/2] -fvisibility=hidden flag for macOS user Added section to remember the macOS user to add the `-fvisibility=hidden` flag. --- doc/setup.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/setup.md b/doc/setup.md index 36e6fc956..e80d80b83 100644 --- a/doc/setup.md +++ b/doc/setup.md @@ -55,8 +55,19 @@ To use **N-API** in a native module: ```gyp 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ], ``` - - 4. Include `napi.h` in the native module code. + 4. **Only** for **macOS** user please don't forget to insert these additional + settings in the `binding.gyp` file: + + ```gyp + ['OS=="mac"', { + 'cflags+': ['-fvisibility=hidden'], + 'xcode_settings': { + 'OTHER_CFLAGS': ['-fvisibility=hidden'] + } + }] + ``` + + 5. Include `napi.h` in the native module code. To ensure only ABI-stable APIs are used, DO NOT include `node.h`, `nan.h`, or `v8.h`. From 7340204fc835fc9a3aaab2f80d20172fde446ab7 Mon Sep 17 00:00:00 2001 From: NickNaso Date: Mon, 25 Mar 2019 23:50:53 +0100 Subject: [PATCH 2/2] Fixed as requested in review --- doc/setup.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/setup.md b/doc/setup.md index e80d80b83..3135bf1d3 100644 --- a/doc/setup.md +++ b/doc/setup.md @@ -55,14 +55,14 @@ To use **N-API** in a native module: ```gyp 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ], ``` - 4. **Only** for **macOS** user please don't forget to insert these additional - settings in the `binding.gyp` file: - + 4. If you would like your native addon to support OSX, please also add the + following settings in the `binding.gyp` file: + ```gyp ['OS=="mac"', { 'cflags+': ['-fvisibility=hidden'], 'xcode_settings': { - 'OTHER_CFLAGS': ['-fvisibility=hidden'] + 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden } }] ```