react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Build on IOS failed

Open criss02-cs opened this issue 2 years ago • 11 comments

Description

I'm trying to build my app on Mac for iOS, when I try to build the app he gives me an error The following build commands failed: CompileC /Users/gbdev/Library/Developer/Xcode/DerivedData/GBWebApp-dgxghrfnprondmbkxeptlzyzcmeu/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-logger.build/Objects-normal/arm64/react_native_log.o /Users/gbdev/Desktop/ProgettiCA/rn-GBAppWeb/node_modules/react-native/ReactCommon/logger/react_native_log.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-logger' from project 'Pods') (1 failure) I have tried to clean cache and everything I can do and find on internet, but nothing of these works.

Version

0.69.3

Output of npx react-native info

System: OS: macOS 12.6 CPU: (8) arm64 Apple M1 Memory: 129.89 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.9.0 - /opt/homebrew/bin/node Yarn: Not Found npm: 8.19.1 - /opt/homebrew/bin/npm Watchman: 2022.09.19.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 14.0/14A309 - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.0.0 react-native: ^0.69.3 => 0.69.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

npm run iOS to run iOS app, on building phase he stops and gave me the error I wrote before.

Snack, code example, screenshot, or link to a repository

I don't have any code to show, it's not a my code problem

criss02-cs avatar Sep 21 '22 10:09 criss02-cs

same for me!

lilitsimonyan98 avatar Sep 21 '22 22:09 lilitsimonyan98

same for me too

FrenkyBojler avatar Sep 22 '22 05:09 FrenkyBojler

Could you try the following commands, from your app root:

  1. cd ios
  2. rm -rf Pods Podfile.lock <your_app_name>.xcworkspace build
  3. bundle install (if you haven't already run this)
  4. bundle exec pod install
  5. cd ..
  6. npx react-native run-ios

The first 2 commands will clean up the dependencies for the iOS project The second 2 will reainstall them (notice that bundle will require you to use Ruby 2.7.5, so you may have to install a ruby version manager and update Ruby... You can read more here) The last two will try to build your app again.

cipolleschi avatar Sep 22 '22 13:09 cipolleschi

Already tried, but It's not working

criss02-cs avatar Sep 22 '22 14:09 criss02-cs

same problem for me

sharifme04 avatar Sep 26 '22 18:09 sharifme04

Hi there, the same issue for me.

I faced same problem. It appeared after installing Firebase SDK and running pod install (faced error message that I need to use use_modular_headers! in Podfile).

After that I can't build app.

olegtech avatar Sep 27 '22 08:09 olegtech

Hi there, I'm looking into the issue. In order to investigate this properly, could you tell me what's the proper setup?

  • Are you using the New or the Legacy Architecture?
  • Are you using Hermes or JSC as default engine?

I just downloaded the template npx react-native init --version 0.69.3 and then npx react-native run-ios

And it worked fine.

Could you prepare a repro (a github repo would work) with your setup?

Hi there, the same issue for me.

I faced same problem. It appeared after installing Firebase SDK and running pod install (faced error message that I need to use use_modular_headers! in Podfile).

After that I can't build app.

@olegtech We know that there are some incompatibilities between RN and Firebase and we are working on trying to solve them. Could you prepare a repro (a github repo would work) with your setup so I can test it out?

cipolleschi avatar Sep 27 '22 10:09 cipolleschi

Hi there, I'm looking into the issue. In order to investigate this properly, could you tell me what's the proper setup?

  • Are you using the New or the Legacy Architecture?
  • Are you using Hermes or JSC as default engine?

I just downloaded the template npx react-native init --version 0.69.3 and then npx react-native run-ios

And it worked fine.

Could you prepare a repro (a github repo would work) with your setup?

Hi there, the same issue for me. I faced same problem. It appeared after installing Firebase SDK and running pod install (faced error message that I need to use use_modular_headers! in Podfile). After that I can't build app.

@olegtech We know that there are some incompatibilities between RN and Firebase and we are working on trying to solve them. Could you prepare a repro (a github repo would work) with your setup so I can test it out?

@cipolleschi Created a repo: https://github.com/olegtech/pod-issue-repo/tree/main/TestRepo

First of all I'm using version of RN: 0.70.1

What I did:

  • npx react-native init TestRepo
  • cd ./TestRepo/ios && pod install
  • in ios folder - bundle install
  • pod install
  • return to root folder and run yarn add @react-native-firebase/app
  • return to ios folder and run pod install (got an error about use_modular_headers! in Podfile)
  • return to root folder and run yarn ios (as npx react-native run-ios)

olegtech avatar Sep 27 '22 11:09 olegtech

@cipolleschi I've resolved it:

According to Firebase docs:

image

What I did:

  • cd ios and added to the top in Podfile: use_frameworks! :linkage => :static
  • in Podfile - commented :flipper_configuration => FlipperConfiguration.enabled
  • pod install --repo-update

And it is working for me ;)

olegtech avatar Oct 03 '22 16:10 olegtech

Hello, I am having the same issue with my app. It was running before, but now I want to work on a V2 and it just won't build. It's the same error. Tried all of the above-mentioned solutions and none of them worked.

Can anyone please help me find a solution?

michaelkozah avatar Nov 05 '22 09:11 michaelkozah

@michaelkozah Hi there! Please share your Podfile

olegtech avatar Nov 07 '22 10:11 olegtech

require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'SmartLand' do config = use_native_modules!

use_frameworks! :linkage => :static

use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change false to true and then install pods :hermes_enabled => false )

pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'

pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'

pod 'react-native-slider', :path => '../node_modules/@react-native-community/slider'

target 'SmartLandTests' do inherit! :complete # Pods for testing end

Enables Flipper.

Note that if you have use_frameworks! enabled, Flipper will not work and

you should disable the next line.

use_flipper!()

post_install do |installer| react_native_post_install(installer) end end

michaelkozah avatar Nov 28 '22 13:11 michaelkozah

I even got the code where it was running (V1) and I tried running it once again and it still didn't work

michaelkozah avatar Nov 28 '22 13:11 michaelkozah

  1. can you show your exact error?
  2. how are you installing the cocoapods?
  3. make sure to disable flipper (comment out use_flipper!())

cipolleschi avatar Nov 30 '22 11:11 cipolleschi

Thanks for your support but it turns out to be an error caused RNFirebase. I found out by opening the project.xcworkspace on Xcode and going through what seems to be failing my build. I noticed that the RNFirebase was failing my build so I tried uninstalling it and it worked. My project was up and running again. Anyway, thank you guys for the help and support ❤️

michaelkozah avatar Nov 30 '22 20:11 michaelkozah

any solution?? same error react-native: v0.70.6

bumjin1013 avatar Jan 11 '23 05:01 bumjin1013

facing the same issue with react-native 0.70.5

naseerahmedaziz avatar Jan 26 '23 16:01 naseerahmedaziz

0.71.1 same issue

//fix which works for me: in AppDelegate.mm i've changed #import "ReactNativeConfig.h" into #import "RNCConfig.h"

mefik1337 avatar Jan 27 '23 07:01 mefik1337

Any solution for this? I've done everything, still nothing. I am getting exact same issue for some packages such as like react-native-nfc-manager,react-native-video.ie (in target 'react-native-nfc-manager' from project 'Pods'),(in target 'react-native-video' from project 'Pods') for almost every packages in my project. I have tried a lot of things such as reinstalling pod file, deleting derived data, updating Xcode. Still no change. Any help?

CompileC /Users/donamstechlabs/Library/Developer/Xcode/DerivedData/vidhyadhan-fzcswpsqsxtnykavdwzfwdqxtcoc/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-pager-view.build/Objects-normal/arm64/ReactNativePageView.o /Users/donamstechlabs/Development/vidhyadhan-mobile-app/node_modules/react-native-pager-view/ios/ReactNativePageView.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-pager-view' from project 'Pods')

CompileC /Users/donamstechlabs/Library/Developer/Xcode/DerivedData/vidhyadhan-fzcswpsqsxtnykavdwzfwdqxtcoc/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-nfc-manager.build/Objects-normal/arm64/NfcManager+Felica.o /Users/donamstechlabs/Development/vidhyadhan-mobile-app/node_modules/react-native-nfc-manager/ios/NfcManager+Felica.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-nfc-manager' from project 'Pods')

CompileC /Users/donamstechlabs/Library/Developer/Xcode/DerivedData/vidhyadhan-fzcswpsqsxtnykavdwzfwdqxtcoc/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-video.build/Objects-normal/arm64/RCTVideo.o /Users/donamstechlabs/Development/vidhyadhan-mobile-app/node_modules/react-native-video/ios/Video/RCTVideo.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-video' from project 'Pods')

npx react-native info

System: OS: macOS 13.2.1 CPU: (8) arm64 Apple M1 Memory: 68.19 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 19.6.0 - /opt/homebrew/bin/node Yarn: Not Found npm: 9.4.1 - /opt/homebrew/bin/npm Watchman: Not Found Managers: CocoaPods: 1.11.3 - /Users/donamstechlabs/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: 2022.1 AI-221.6008.13.2211.9619390 Xcode: 14.3/14E222b - /usr/bin/xcodebuild Languages: Java: 17.0.6 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.8 => 0.70.8 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Melwin2317 avatar May 04 '23 09:05 Melwin2317

@Melwin2317 what is the error that you are facing?

The snippet you pasted are just compile instructions with no errors. For example:

CompileC /Users/donamstechlabs/Library/Developer/Xcode/DerivedData/vidhyadhan-fzcswpsqsxtnykavdwzfwdqxtcoc/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-pager-view.build/Objects-normal/arm64/ReactNativePageView.o /Users/donamstechlabs/Development/vidhyadhan-mobile-app/node_modules/react-native-pager-view/ios/ReactNativePageView.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-pager-view' from project 'Pods')
  • CompileC => is the command
  • /Users/donamstechlabs/Library/Developer/Xcode/DerivedData/vidhyadhan-fzcswpsqsxtnykavdwzfwdqxtcoc/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-pager-view.build/Objects-normal/arm64/ReactNativePageView.o => is the path to the object that needs to be generated by the compiler
  • /Users/donamstechlabs/Development/vidhyadhan-mobile-app/node_modules/react-native-pager-view/ios/ReactNativePageView.m => it's the file that needs to be build
  • normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler are compiler flags
  • (in target 'react-native-pager-view' from project 'Pods') => the target that contains the file.

So, I can't see any error here... :(

cipolleschi avatar May 04 '23 13:05 cipolleschi

@cipolleschi

** BUILD FAILED **

The following build commands failed:

CompileC /Users/donamstechlabs/Library/Developer/Xcode/DerivedData/vidhyadhan-fzcswpsqsxtnykavdwzfwdqxtcoc/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-video.build/Objects-normal/arm64/RCTVideo.o /Users/donamstechlabs/Development/vidhyadhan-mobile-app/node_modules/react-native-video/ios/Video/RCTVideo.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-video' from project 'Pods')

(1 failure)

This is the error. The following build command failed.

I am getting the below error in Xcode for the same project Screenshot 2023-05-05 at 10 15 00 AM

Melwin2317 avatar May 05 '23 04:05 Melwin2317

This is the error. The following build command failed.

That's what happened, but not why! 😉 The error is why it has happened.

In your case, the error is that react-native-video is importing non-modular headers inside some framework modules.

Could you copy and paste your Podfile, please? Also, which command do you run to install your pods?

cipolleschi avatar May 05 '23 09:05 cipolleschi

@cipolleschi

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

pod 'RNFS', :path => '../node_modules/react-native-fs'  # added by developer

$RNFirebaseAsStaticFramework = true

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

target 'vidhyadhan' do
  config = use_native_modules!

  use_frameworks!    # added by developer

  use_frameworks! :linkage => :static # added by developer

  $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
     'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion',
     'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
     'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']
  
   pre_install do |installer|
     Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
     installer.pod_targets.each do |pod|
         if $static_framework.include?(pod.name)
           def pod.build_type;
             Pod::BuildType.static_library
           end
         end
       end
  end

  flags = get_default_flags() # Flags change depending on the env values.

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => true,
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    # :flipper_configuration => FlipperConfiguration.enabled, needed commented by developer
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'vidhyadhanTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
 end

command to install pod:

cd ios && pod install

Melwin2317 avatar May 05 '23 09:05 Melwin2317

So... as far as I can see, you are using a Cocoapods plugin that allow you to mix Static Frameworks and static libraries.

This is not required anymore. To simplify the setup, please remove the lines:

- use_frameworks!    # added by developer

# ...

- $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
-     'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion',
-     'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
-     'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']

- pre_install do |installer|
-     Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
-     installer.pod_targets.each do |pod|
-         if $static_framework.include?(pod.name)
-           def pod.build_type;
-             Pod::BuildType.static_library
-           end
-         end
-       end
-  end

Now, there is the react-native-video framework that is causing problems. Let's try to add the following line:

+ pod 'react-native-video', :path => '../node_modules/react-native-video', :modular_headers => true
target 'vidhyadhanTests' do

I'm not 100% confident that it will work, but it should.

Also, if you can prepare a small repro (new app with just the dependencies that creates this problem) I can investigate better.

Thank you so much.

cipolleschi avatar May 05 '23 13:05 cipolleschi

@cipolleschi oh man, you are a life saver. it worked well. I am really happy today.I had been working on this problem for over a week and was starting to lose hope.I had considered starting a new project from scratch by copying and pasting code from the current project. Anyway,now I don't need to do that. Thank you so much for helping me. You just made my day.

Melwin2317 avatar May 06 '23 05:05 Melwin2317

So... as far as I can see, you are using a Cocoapods plugin that allow you to mix Static Frameworks and static libraries.

This is not required anymore. To simplify the setup, please remove the lines:

- use_frameworks!    # added by developer

# ...

- $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
-     'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion',
-     'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
-     'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']

- pre_install do |installer|
-     Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
-     installer.pod_targets.each do |pod|
-         if $static_framework.include?(pod.name)
-           def pod.build_type;
-             Pod::BuildType.static_library
-           end
-         end
-       end
-  end

Now, there is the react-native-video framework that is causing problems. Let's try to add the following line:

+ pod 'react-native-video', :path => '../node_modules/react-native-video', :modular_headers => true
target 'vidhyadhanTests' do

I'm not 100% confident that it will work, but it should.

Also, if you can prepare a small repro (new app with just the dependencies that creates this problem) I can investigate better.

Thank you so much.

@cipolleschi Hi! I also try this for my packages like

pod 'react-native-nfc-manager', :path => '../node_modules/react-native-nfc-manager' pod 'react-native-camera', :path => '../node_modules/react-native-camera'

but its giving this kind of error in target 'react-native-nfc-manager-framework' from project 'Pods in target 'react-native-camera-framework' from project 'Pods

adilijaz avatar Sep 23 '23 10:09 adilijaz

Hi @adilijaz! On which version of react native are you?

For some time now, we have autolinking. This means that you should remove those lines

-pod 'react-native-nfc-manager', :path => '../node_modules/react-native-nfc-manager'
-pod 'react-native-camera', :path => '../node_modules/react-native-camera'

and install these dependencies using

yarn add react-native-nfc-manager react-native-camera

CLI autolinking will take care of adding the pod xxx instruction with the right path for you.

Also, you should give a little bit more information about the error... can you add a screenshot or a more detailed description of your errors?

cipolleschi avatar Sep 26 '23 14:09 cipolleschi

@cipolleschi I've resolved it:

According to Firebase docs:

image

What I did:

  • cd ios and added to the top in Podfile: use_frameworks! :linkage => :static
  • in Podfile - commented :flipper_configuration => FlipperConfiguration.enabled
  • pod install --repo-update

And it is working for me ;)

Thanks you save my days it working fine

nileshgalaxy avatar Mar 14 '24 06:03 nileshgalaxy