nx: Nx run-ios does not compile on Apple M1 with freshly installed tools and fresh workspace

Current Behavior

iOS app not building even with freshly installed tools (node 20 via nvm or latest yarn via corepack).

When running npx nx mobile:run-ios (my project’s name is ‘mobile’), Metro starts and waits for app building process to complete.

That’s when the error happens. The app does not build and I get the error: CompileC <REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/Mobile-dmgohxydoupmpaczzqhhcrpocyod/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/FlipperPlatformWebSocket.o <REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'FlipperKit' from project 'Pods')

Expected Behavior

Have the app built without errors, installed and executed in iOS simulator

GitHub Repo

No response

Steps to Reproduce

  1. Run npx create-nx-workspace@latest <workspace-name> 1.1. Stack: React 1.2. Framework: React Native 1.3. Application Name: mobile 1.4. Nx Cloud: Skip for now
  2. cd <workspace-name>
  3. Run npx nx run mobile:pod-install
  4. Run npx nx run mobile:run-ios

NOTES:

  • Using Node 20.11.0 (LTS)
  • MacBook Pro M1 (2021)
  • macOS Sonoma 14.3.1
  • Xcode 15.3
  • Also doesn’t work with Yarn 4.1.1 enabled via Corepack (swap npx for yarn dlx)

Nx Report

Node   : 20.11.0
OS     : darwin-arm64
npm    : 10.2.4

nx                 : 18.0.8
@nx/js             : 18.0.8
@nx/jest           : 18.0.8
@nx/linter         : 18.0.8
@nx/eslint         : 18.0.8
@nx/workspace      : 18.0.8
@nx/detox          : 18.0.8
@nx/devkit         : 18.0.8
@nx/eslint-plugin  : 18.0.8
@nx/react          : 18.0.8
@nx/react-native   : 18.0.8
@nrwl/tao          : 18.0.8
@nx/web            : 18.0.8
@nx/webpack        : 18.0.8
typescript         : 5.3.3

Failure Logs

<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/Headers/Private/Flipper/FlipperTransportTypes.h:29:14: error: no template named 'function' in namespace 'std'
typedef std::function<void(const std::string& message)> SocketMessageHandler;
        ~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/Headers/Private/Flipper/FlipperTransportTypes.h:38:14: error: no template named 'function' in namespace 'std'
typedef std::function<std::string(char* password, size_t length)>
        ~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/Headers/Private/Flipper/FlipperTransportTypes.h:45:14: error: no template named 'function' in namespace 'std'
typedef std::function<void()> SocketSendHandler;
        ~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/Headers/Private/Flipper/FlipperTransportTypes.h:54:14: error: no template named 'function' in namespace 'std'
typedef std::function<void(std::string response, bool isError)>
        ~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm:58:46: error: called object type 'facebook::flipper::SocketCertificateProvider' (aka 'int') is not a function or function pointer
  auto certificatePath = _certificateProvider(&PASSWORD[0], 512);
                         ~~~~~~~~~~~~~~~~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm:157:32: error: called object type 'facebook::flipper::SocketEventHandler' (aka 'int') is not a function or function pointer
      strongSelf->_eventHandler(facebook::flipper::SocketEvent::ERROR);
      ~~~~~~~~~~~~~~~~~~~~~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm:188:16: error: called object type 'facebook::flipper::SocketEventHandler' (aka 'int') is not a function or function pointer
  _eventHandler(facebook::flipper::SocketEvent::CLOSE);
  ~~~~~~~~~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm:224:16: error: called object type 'facebook::flipper::SocketEventHandler' (aka 'int') is not a function or function pointer
  _eventHandler(facebook::flipper::SocketEvent::OPEN);
  ~~~~~~~~~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm:245:18: error: called object type 'facebook::flipper::SocketEventHandler' (aka 'int') is not a function or function pointer
    _eventHandler(facebook::flipper::SocketEvent::SSL_ERROR);
    ~~~~~~~~~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm:247:18: error: called object type 'facebook::flipper::SocketEventHandler' (aka 'int') is not a function or function pointer
    _eventHandler(facebook::flipper::SocketEvent::ERROR);
    ~~~~~~~~~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm:258:16: error: called object type 'facebook::flipper::SocketEventHandler' (aka 'int') is not a function or function pointer
  _eventHandler(facebook::flipper::SocketEvent::CLOSE);
  ~~~~~~~~~~~~~^
<REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm:264:20: error: called object type 'facebook::flipper::SocketMessageHandler' (aka 'int') is not a function or function pointer
    _messageHandler([response UTF8String]);
    ~~~~~~~~~~~~~~~^

[...]

warning: Run script build phase 'Bundle React Native code and images' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Mobile' from project 'Mobile')
warning: Run script build phase '[CP-User] [Hermes] Replace Hermes for the right configuration, if needed' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'hermes-engine' from project 'Pods')

[...]

xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:36AC42FF-53C2-4611-93E4-DD58B54C23BB, OS:17.4, name:iPhone SE (3rd generation) }
{ platform:iOS Simulator, id:36AC42FF-53C2-4611-93E4-DD58B54C23BB, OS:17.4, name:iPhone SE (3rd generation) }
** BUILD FAILED **

CompileC <REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/Mobile-dmgohxydoupmpaczzqhhcrpocyod/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/FKUserDefaultsPlugin.o <REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/Plugins/FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'FlipperKit' from project 'Pods')
    cd <REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -ivfsstatcache <REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator17.4-21E210-aa93b11c43e2d16681ac3fa171344f4f.sdkstatcache -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fno-color-diagnostics -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=<REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -Wno-implicit-fallthrough -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path <REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/Mobile-dmgohxydoupmpaczzqhhcrpocyod/Index.noindex/DataStore @<REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/Mobile-dmgohxydoupmpaczzqhhcrpocyod/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/e6072d4f65d7061329687fe24e3d63a7-common-args.resp -DDEBUG\=1 -DFLIPPER_OSS\=1 -DFB_SONARKIT_ENABLED\=1 -DFOLLY_HAVE_BACKTRACE\=1 -DFOLLY_HAVE_CLOCK_GETTIME\=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE\=1 -DFOLLY_USE_LIBCPP\=1 -DFOLLY_HAVE_LIBGFLAGS\=0 -DFOLLY_HAVE_LIBJEMALLOC\=0 -DFOLLY_HAVE_PREADV\=0 -DFOLLY_HAVE_PWRITEV\=0 -DFOLLY_HAVE_TFO\=0 -DFOLLY_USE_SYMBOLIZER\=0 -include <REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/Target\ Support\ Files/FlipperKit/FlipperKit-prefix.pch -MMD -MT dependencies -MF <REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/Mobile-dmgohxydoupmpaczzqhhcrpocyod/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/FKUserDefaultsPlugin.d --serialize-diagnostics <REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/Mobile-dmgohxydoupmpaczzqhhcrpocyod/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/FKUserDefaultsPlugin.dia -c <REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/Plugins/FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.m -o <REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/Mobile-dmgohxydoupmpaczzqhhcrpocyod/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/FKUserDefaultsPlugin.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/FKUserDefaultsPlugin.o
clang: error: unable to execute command: Interrupt: 2

---

The following build commands failed:
        CompileC <REDACTED for privacy - HOME folder>/Library/Developer/Xcode/DerivedData/Mobile-dmgohxydoupmpaczzqhhcrpocyod/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/FlipperPlatformWebSocket.o <REDACTED for privacy - HOME folder>/Development/Labs/shared-components-nx-monorepo/apps/mobile/ios/Pods/FlipperKit/iOS/FlipperKit/FlipperPlatformWebSocket.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'FlipperKit' from project 'Pods')
(1 failure)

Package Manager Version

npm 10.2.4 / yarn 4.1.1

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Found out about NX through the article One codebase for React and React-native with Nx monorepos. Also tried following Getting started / Intro with React Native platform BTW… there’s another very similiar issue about this problem, issue #16910

About this issue

  • Original URL
  • State: open
  • Created 4 months ago
  • Reactions: 3
  • Comments: 19

Most upvoted comments

you can try the following (it’s working for me):

We had similar issue when updating xCode to 15.3 version. The issue was associated with Flipper as well.

The issue was with FlipperTransportTypes.h file. the issue throws No template named ‘function’ in namespace ‘std’

The Fix was adding #include <functional> after #include <string> statement.

If you still have issues after that than you might need to add it to some other files.

This will solve your problem.

https://stackoverflow.com/questions/78120545/failed-to-build-ios-project-we-ran-xcodebuild-command-but-it-exited-with-erro

I’m also facing the same thing… I hope there is a solution soon.