ignite icon indicating copy to clipboard operation
ignite copied to clipboard

Unable to build new app, errors on running npx react-native run-ios, on Apple M1

Open giuseppeTrovato20 opened this issue 4 years ago • 13 comments

What's going on?

I've started a new project with the ignite-cli, but I'm unable to make it run on IOS, (I've not tried on Android). Although a new React project without boilerplate runs normally. I'm totally lost.

These errors appear after

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening AudioGuidaApp.xcworkspace. Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace AudioGuidaApp.xcworkspace -configuration Debug -scheme AudioGuidaApp -destination id=9EAD6E26-E4FC-43C5-B85F-0E93EFC30908 User defaults from command line: IDEPackageSupportUseBuiltinSCM = YES

Then at the bottom it says also this:

ld: warning: directory not found for option '-L-L/Users/giuseppetrovato/Library/Developer/Xcode/DerivedData/AudioGuidaApp-fsgjgfxaptmvopggqjhkgiulzzac/Build/Products/Debug-iphonesimulator/CocoaAsyncSocket' ld: library not found for -lCocoaAsyncSocket clang: error: linker command failed with exit code 1 (use -v to see invocation)

objc[41218]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1ff380188) and ?? (0x115f302b8). One of the two will be used. Which one is undefined.

objc[41218]: Class AMSupportURLSession is implemented in both ?? (0x1ff3801d8) and ?? (0x115f30308). One of the two will be used. Which one is undefined.

BUILD FAILED **

The following build commands failed: Ld /Users/giuseppetrovato/Library/Developer/Xcode/DerivedData/AudioGuidaApp-fsgjgfxaptmvopggqjhkgiulzzac/Build/Products/Debug-iphonesimulator/AudioGuidaApp.app/AudioGuidaApp normal arm64 (1 failure)


Steps to reproduce

  1. npx ignite-cli new foo
  2. npx react-native run-ios
  3. Build error

npx ignite-cli doctor results:

System platform darwin
arch arm64
cpu 8 cores Apple M1
directory AudioGuidaApp /Users/giuseppetrovato/Desktop/Workspace/AudioGuidaApp

JavaScript (and globally-installed packages) node 16.10.0 /usr/local/bin/node npm 7.24.0 /usr/local/bin/npm
corepack 0.9.0
direflow-cli 3.5.5
ignite-cli 7.6.0
nodemon 2.0.13
npm 7.24.0
parcel 2.0.0
yarn 1.22.11
yarn 1.22.11 /usr/local/bin/yarn

Ignite ignite-cli 7.6.0 /usr/local/bin/ignite
ignite src build /usr/local/lib/node_modules/ignite-cli/build

Android java 1.8.0_292 /usr/bin/java android home - undefined

iOS xcode 12.5.1
cocoapods 1.11.2

giuseppeTrovato20 avatar Nov 11 '21 16:11 giuseppeTrovato20

@giuseppeTrovato20 What happens when you try to run the app from Xcode?

derekgreenberg avatar Nov 11 '21 17:11 derekgreenberg

The build fails with some errors. I'll post the screenshots

Screenshot 2021-11-12 at 17 11 47

Screenshot 2021-11-12 at 17 12 02

giuseppeTrovato20 avatar Nov 12 '21 16:11 giuseppeTrovato20

What's going on?

I've started a new project with the ignite-cli, but I'm unable to make it run on IOS, (I've not tried on Android). Although a new React project without boilerplate runs normally. I'm totally lost.

These errors appear after

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening AudioGuidaApp.xcworkspace. Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace AudioGuidaApp.xcworkspace -configuration Debug -scheme AudioGuidaApp -destination id=9EAD6E26-E4FC-43C5-B85F-0E93EFC30908 User defaults from command line: IDEPackageSupportUseBuiltinSCM = YES

Then at the bottom it says also this:

ld: warning: directory not found for option '-L-L/Users/giuseppetrovato/Library/Developer/Xcode/DerivedData/AudioGuidaApp-fsgjgfxaptmvopggqjhkgiulzzac/Build/Products/Debug-iphonesimulator/CocoaAsyncSocket' ld: library not found for -lCocoaAsyncSocket clang: error: linker command failed with exit code 1 (use -v to see invocation)

objc[41218]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1ff380188) and ?? (0x115f302b8). One of the two will be used. Which one is undefined.

objc[41218]: Class AMSupportURLSession is implemented in both ?? (0x1ff3801d8) and ?? (0x115f30308). One of the two will be used. Which one is undefined.

BUILD FAILED **

The following build commands failed: Ld /Users/giuseppetrovato/Library/Developer/Xcode/DerivedData/AudioGuidaApp-fsgjgfxaptmvopggqjhkgiulzzac/Build/Products/Debug-iphonesimulator/AudioGuidaApp.app/AudioGuidaApp normal arm64 (1 failure)

Steps to reproduce

  1. npx ignite-cli new foo
  2. npx react-native run-ios
  3. Build error

npx ignite-cli doctor results:

System platform darwin arch arm64 cpu 8 cores Apple M1 directory AudioGuidaApp /Users/giuseppetrovato/Desktop/Workspace/AudioGuidaApp

JavaScript (and globally-installed packages) node 16.10.0 /usr/local/bin/node npm 7.24.0 /usr/local/bin/npm corepack 0.9.0 direflow-cli 3.5.5 ignite-cli 7.6.0 nodemon 2.0.13 npm 7.24.0 parcel 2.0.0 yarn 1.22.11 yarn 1.22.11 /usr/local/bin/yarn

Ignite ignite-cli 7.6.0 /usr/local/bin/ignite ignite src build /usr/local/lib/node_modules/ignite-cli/build

Android java 1.8.0_292 /usr/bin/java android home - undefined

iOS xcode 12.5.1 cocoapods 1.11.2

Hi @giuseppeTrovato20 , Faced same issue with Macbook with M1 while generating new project. But you can try installing v3.5.3 or any v3.X.X with LTS node(If still not worked with LTS then install node with version 14.X.X and gove it try) selected. I can generate new ignite project with it.

Use command : npx [email protected] new ProjectName

App will run successfully with xcode. Don't forgot to add arm64 to Excluded Architecture in project target and pod.

@jamonholmgren Can you please help us to run latest ignite on M1 macs?

MadhavNasit avatar Nov 12 '21 18:11 MadhavNasit

Hi @MadhavNasit, It does not run, can you explain to me better what you mean by:

"Don't forget to add arm64 to Excluded Architecture in project target and pod"?

I'm also concerned that this version 3.5.3 may be too old, the current version on npm is 7.6.0

I come from 2019 development on Windows with the old version of Ignite, I'm not very skilled in IOS development. Back then I worked only on Android.

giuseppeTrovato20 avatar Nov 16 '21 10:11 giuseppeTrovato20

Hi @MadhavNasit, It does not run, can you explain to me better what you mean by:

"Don't forget to add arm64 to Excluded Architecture in project target and pod"?

I'm also concerned that this version 3.5.3 may be too old, the current version on npm is 7.6.0

I come from 2019 development on Windows with the old version of Ignite, I'm not very skilled in IOS development. Back then I worked only on Android.

Yes 3.5.3 is too old but that version works perfectly, You can give try to 6.0.0 also.

Please refer below accepted answer, As for Macbook with M1 chip we need to exclude arm64 to build app. https://stackoverflow.com/questions/63607158/xcode-12-building-for-ios-simulator-but-linking-in-an-object-file-built-for-io

MadhavNasit avatar Nov 16 '21 10:11 MadhavNasit

@MadhavNasit Thank you for the answer.

I'll try what says on the link on StackOverflow.

I'm wondering if you know something on when M1 support will be added to the latest version of Ignite. Because I'm a little reluctant to set up a project that should go into production, with such an old version.

Thank you again for your time

giuseppeTrovato20 avatar Nov 16 '21 10:11 giuseppeTrovato20

@MadhavNasit Thank you for the answer.

I'll try what says on the link on StackOverflow.

I'm wondering if you know something on when M1 support will be added to the latest version of Ignite. Because I'm a little reluctant to set up a project that should go into production, with such an old version.

Thank you again for your time

Until fix on latest version, You can generate project using old one and upgrade react native and react navigation etc by following migration guild docs for that packages to latest versions manually.

MadhavNasit avatar Nov 16 '21 10:11 MadhavNasit

@giuseppeTrovato20 can you check if adding this to your podfile will work? I recently came across this because I blindly copied the patch diff from 0.64 to 0.66 and it broke my intel mac build.

https://github.com/facebook/react-native/blob/26e30a5ee9ed06cc77508b421075ac3270c716a2/scripts/react_native_pods.rb#L545

Here's a sample of what my podfile looks like right now for reference:

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

platform :ios, '11.0'

target 'mobile' do
  use_unimodules!
  config = use_native_modules!

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

  target 'mobileTests' 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 these next few lines.
  use_flipper!({ 'Flipper' => '0.93.0', 'Flipper-Folly' => '2.6.7', 'Flipper-DoubleConversion' => '3.1.7' })
  post_install do |installer|
    flipper_post_install(installer)
    react_native_post_install(installer)
#     __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

1mike12 avatar Nov 21 '21 16:11 1mike12

Find your ignite-cli directory in root and change the below code in postinstall file to run the project on Mac with M1, For me ignite-cli path: /Users/madhav/.npm/_npx/e31027f3785124a8/node_modules/ignite-cli/boilerplate/bin/postInstall

In postInstall, Replace line: { command: "pod install", cwd: "ios", onlyPlatforms: ["darwin"] }, with: { command: "arch -x86_64 pod install", cwd: "ios", onlyPlatforms: ["darwin"] },

MadhavNasit avatar Nov 25 '21 10:11 MadhavNasit

This article resolve this issue for me. https://handi.dev/blog/how-run-react-native-on-macbook-m1-apple-silicon

M1chaelTran avatar Nov 27 '21 00:11 M1chaelTran

This article resolve this issue for me. https://handi.dev/blog/how-run-react-native-on-macbook-m1-apple-silicon

I don't know how you have done it, but when I try to build it throws the same error

giuseppeTrovato20 avatar Nov 30 '21 07:11 giuseppeTrovato20

This article resolve this issue for me. https://handi.dev/blog/how-run-react-native-on-macbook-m1-apple-silicon

I don't know how you have done it, but when I try to build it throws the same error

Follow the instruction from step 3 to 7. I found that step 1 and 2 isn't needed.

If that still doesn't work, make sure that you're using Node version 14.x instead of the latest. Also you're using the npx react-native run-ios instead of something else... Hoped that helped you and other as it works for me.

M1chaelTran avatar Nov 30 '21 10:11 M1chaelTran

Follow the instruction from step 3 to 7.

Thank you @M1chaelTran, I followed the instructions as you suggested and the build step worked.

Side note:

This solution is useful to anyone following the tutorial Create trivia app and struggling to get the "run-ios" step to work.

cresencio avatar Jan 11 '22 03:01 cresencio

Hello @giuseppeTrovato20! Do you still receive this issue on the latest Ignite CLI, version 7.14.2?

frankcalise avatar Aug 16 '22 01:08 frankcalise

I'm going to close this issue due to inactivity. However, if this problem still persists and you have updated to the latest version of ignite, please open a new issue stating the problem and the output of npx ignite-cli doctor.

Also, you can check out https://community.infinite.red to get help with us (and a bunch of other RN devs!) directly in Slack.

frankcalise avatar Aug 22 '22 12:08 frankcalise