Skip to content

iOS builds using XCode fail because of chaining operator syntaxΒ #96

@Jack-Gill-TH

Description

@Jack-Gill-TH

Current behavior

After implementing react-native-keys with Expo, I find that I can no longer build using XCode. Builds from the command line work fine, but in XCode the build process throws an error and points at specifically the chaining operator syntax. Once I remove all the chaining operator syntax, xcode runs fine.

Excerpt from my patch file:

diff --git a/node_modules/react-native-keys/src/util/common.js b/node_modules/react-native-keys/src/util/common.js
index fd066f3..11ad0e9 100644
--- a/node_modules/react-native-keys/src/util/common.js
+++ b/node_modules/react-native-keys/src/util/common.js
@@ -1,19 +1,11 @@
 const fs = require('fs-extra');
 const path = require('path');
 const CryptoJS = require('crypto-js');
-const isExample = process.env.IS_EXAMPLE === 'TRUE';
 const DEFAULT_FILE_NAME = 'keys.development.json';
 
-const expoExampleDirName = 'exampleExpo';
-const exampleDirName =
-  process.cwd().includes(expoExampleDirName) ||
-  process.env?.SRCROOT?.includes(expoExampleDirName)
-    ? expoExampleDirName
-    : 'example';
-
 const PROJECT_ROOT_DIR_PATH = path.join(
   __dirname,
-  isExample ? `../../${exampleDirName}/` : '../../../../'
+  '../../../../'
 );
 const PACKAGE_ROOT_DIR_PATH = path.join(__dirname, '../../');
 const RN_KEYS_PATH = path.join('node_modules', 'react-native-keys');
@@ -26,24 +18,24 @@ const KEYS_ANDROID_EXAMPLE_PATH = path.join('../', 'android');
 
 const IOS_DIR_PATH = path.join(
   PROJECT_ROOT_DIR_PATH,
-  isExample ? KEYS_IOS_EXAMPLE_PATH : KEYS_IOS_PATH
+  KEYS_IOS_PATH
 );
 
 const CPP_DIRECTORY_PATH = path.join(
   PROJECT_ROOT_DIR_PATH,
-  isExample ? '../' : RN_KEYS_PATH,
+  RN_KEYS_PATH,
   'cpp'
 );
 
 const ANDROID_DIR_PATH = path.join(
   PROJECT_ROOT_DIR_PATH,
-  isExample ? KEYS_ANDROID_EXAMPLE_PATH : KEYS_ANDROID_PATH,
+  KEYS_ANDROID_PATH,
   'cpp'
 );
 
 const SRC_PATH = path.join(
   PROJECT_ROOT_DIR_PATH,
-  isExample ? KEYS_SRC_EXAMPLE_PATH : KEYS_SRC_PATH
+  KEYS_SRC_PATH
 );
 const ANDROID_KEYS_DIR_PATH = path.join(
   PACKAGE_ROOT_DIR_PATH,
@@ -67,19 +59,19 @@ module.exports.getKeys = (KEYS_FILE_NAME) => {
 module.exports.genTSType = (allKeys) => {
   let result =
     '// this file is auto generate, please do not modify\nexport type KeyTurboType = {';
-  Object.keys(allKeys?.public ?? {}).forEach((key) => {
+    Object.keys((allKeys && allKeys.public) || {}).forEach((key) => {
     result += `\n  ${key}: string;`;
   });
-  if(!allKeys?.public) {
+  if(!(allKeys && allKeys.public)) {
     result += '\n [key: string]: string;\n};\n\n';
   } else {
     result += '\n};\n\n';
   }
   result += 'export type KeyTurboSecuredType = {';
-  Object.keys(allKeys?.secure ?? {}).forEach((key) => {
+  Object.keys((allKeys && allKeys.secure) || {}).forEach((key) => {
     result += `\n  ${key}: string;`;
   });
-  if(!allKeys?.secure) {
+  if(!(allKeys && allKeys.secure)) {
     result += '\n [key: string]: string;\n};\n\n';
   } else {
     result += '\n};\n\n';

I assume there is some configuration step I need to do to make XCode happy with this more modern syntax, but I'm afraid I don't know what it is. Any support would be greatly appreciated!

Platform

  • iOS

React Native Version

0.76.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions