Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 4 tasks
caiorg opened this issue Mar 14, 2024 · 20 comments
Open
1 of 4 tasks
Assignees
Labels
scope: react-native Issues relating to React Native type: bug

Comments

@caiorg
Copy link

caiorg commented Mar 14, 2024

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

@FrozenPandaz FrozenPandaz added the scope: react-native Issues relating to React Native label Mar 15, 2024
@caiorg
Copy link
Author

caiorg commented Mar 19, 2024

Nothing yet? I know you guys are very busy, but if you can shine a light would be great!
I'm also trying to find a solution on my own, with no success so far.

@helloiambguedes
Copy link

I'm facing a similar error but I'm not using NX
Not sure if this is related with it or not but will update as soon as I get more info

@helloiambguedes
Copy link

helloiambguedes commented Mar 19, 2024

@caiorg have you seen this?
facebook/react-native#43335

@caiorg
Copy link
Author

caiorg commented Mar 19, 2024

@helloiambguedes

@caiorg have you seen this? facebook/react-native#43335

Just looked at it and still no success.

The weird thing is I can it to work OUTSIDE a monorepo/workspaces folder with:

  • npx react-native@latest init appName in a non-monorepo project (let's as plain as it can get),
  • then install npm packages (with npm or yarn),
  • then cd ios folder,
  • then bundle exec pod install,
  • finally npm run ios or yarn ios

With all those steps, the app is created, packages and pods are installed, the app is built and run successfully on my iOS simulator.

@helloiambguedes
Copy link

@caiorg in my case I had to disable Flipper for it to work
But if you can run it outside the monorepo maybe it has something to do with NX's magic

I'm not using NX, just did a small POC in the early stages
I'm sorry I can't give much help here 😞

@caiorg
Copy link
Author

caiorg commented Mar 20, 2024

@caiorg in my case I had to disable Flipper for it to work
But if you can run it outside the monorepo maybe it has something to do with NX's magic

I'm not using NX, just did a small POC in the early stages
I'm sorry I can't give much help here 😞

Yeah... I've also disabled it with no success, unfortunately.

Outside a monorepo structure, it seams to work fine after running a few more commands. RNs documentation is not thorough.

The only thing I'm suspicious is RN does not quite like monorepos, but I can't confirm right now.

@pabmac
Copy link

pabmac commented Mar 21, 2024

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 after #include 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

@caiorg
Copy link
Author

caiorg commented Mar 21, 2024

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 after #include 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

Already looked into it. In newer versions of React Native, that line is already added.

Also tried disabling Flipper, which was a solution for some. Not for me, unfortunately.

@airowe
Copy link

airowe commented Mar 22, 2024

@caiorg - The patch in Flipper pod worked for me. Is it possible you need to cd into ios, pod deintegrate && pod install? I wonder if you have some lingering caches hanging around. Might want to delete your metro and .nx caches as well.

@caiorg
Copy link
Author

caiorg commented Mar 25, 2024

@caiorg - The patch in Flipper pod worked for me. Is it possible you need to cd into ios, pod deintegrate && pod install? I wonder if you have some lingering caches hanging around. Might want to delete your metro and .nx caches as well.

Sorry for the delay...

Tested it without success.

Tried everything I could find on the web about, found a few "solutions", none of them worked. Also for every test, I start from scratch.

@nikkahel
Copy link

nikkahel commented Apr 4, 2024

Are any updates?
I have same problem

@caiorg
Copy link
Author

caiorg commented Apr 4, 2024

Are any updates? I have same problem

Unfortunately not from me and I'm kinda giving up. I feel like tested everything I could imagine or find on the internet.

What makes me sad is that I haven't heard from any maintainer since I've open this issue.

The only thing that kinda worked was:

  1. starting a fresh workspace with RN template (as instructed by the docs)
  2. npm install
  3. cding into ios folder
  4. bundle install
  5. NO_FLIPPER=1 pod install or NO_FLIPPER=1 bundle exec pod install
  6. back to root folder
  7. finally npx nx run-ios <rn app name>

But even that it is not working anymore, not sure why.

A few things were CRUCIAL to make it work (when it was working... 😞) and they where steps 4 and 5, specially step 5 with the flag NO_FLIPPER=1.

I really liked NX solution and hoped it would be a huge help on developing apps React Native, ReactJS and shared libraries (was looking forward to use React Native Web). I got so mentally tired trying every bit of solution I managed to find, that I'm not sure if this is worth pursuing anymore.

@oleksolv
Copy link

oleksolv commented Apr 5, 2024

Hi all!

@caiorg found the solution that worked for me:

  1. Clear the project: git clean -fdx.
  2. Clear all caches: pod, watchman, react-native, etc.
  3. Update react-native to the latest version: 0.73.6 (After nx generate it was 0.73.2). React Native Upgrade Helper.
  4. Please note that CocoaPods version should be less than 0.15 😀. I use version 0.14.3. In the rn update guide, you will see the bug note.
  5. Then common steps: npm i, pod install.
  6. Try running iOS again.

Hope it will help!

@caiorg
Copy link
Author

caiorg commented Apr 5, 2024

Hi all!

@caiorg found the soilution that worked for me:

  1. Clear the project: git clean -fdx.
  2. Clear all caches: pod, watchman, react-native, etc.
  3. Update react-native to the latest version: 0.73.6 (After nx generate it was 0.73.2). React Native Upgrade Helper.
  4. Please note that CocoaPods version should be less than 0.15 😀. I use version 0.14.3. In the rn update guide, you will see the bug note.
  5. Then common steps: npm i, pod install.
  6. Try running iOS again.

Hope it will help!

I'll try that as soon as I can.
Will come back with the results.

Thx!

@caiorg
Copy link
Author

caiorg commented Apr 8, 2024

Hi all!

@caiorg found the solution that worked for me:

  1. Clear the project: git clean -fdx.
  2. Clear all caches: pod, watchman, react-native, etc.
  3. Update react-native to the latest version: 0.73.6 (After nx generate it was 0.73.2). React Native Upgrade Helper.
  4. Please note that CocoaPods version should be less than 0.15 😀. I use version 0.14.3. In the rn update guide, you will see the bug note.
  5. Then common steps: npm i, pod install.
  6. Try running iOS again.

Hope it will help!

Hey @oleksolv, sorry for the delay.

I've tried your suggestion without success. Also tried on another MacBook Pro (exact same model as mine) and got the EXACT same error!

@Gaurav-MobDev
Copy link

Screenshot 2024-04-09 at 11 02 56 PM

The solution is already mentioned in the comments in podfile

@caiorg
Copy link
Author

caiorg commented Apr 10, 2024

Screenshot 2024-04-09 at 11 02 56 PM The solution is already mentioned in the comments in podfile

That would be the solution IF react-native-flipper was being used, as the comment states. Since the only 4 times react-native-flipper appears in the whole codebase (considering a freshly created project) is exactly in those comment lines, that solution is not applicable, also that reinforces the need to use NO_FLIPPER=1.

In my screenshot, the line 20 is not commented out and I did not touch at all this file.
Screenshot 2024-04-10 at 15 16 52

Anyways, I really appreciate you taking your time and trying to help!

@Afeezagbaje
Copy link

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

@caiorg
Copy link
Author

caiorg commented Apr 21, 2024

Being honest? I just gave up the idea for now, as it was on a proof of concept stage and doesn't make sense spending more time right now.
Also the fact that no NX contributor has ever commented something here, shows this matter is of a low criticality for them (if they even took time to read) and is discouraging.

@LawrenceMoore
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: react-native Issues relating to React Native type: bug
Projects
None yet
Development

No branches or pull requests