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

fix: add missing argument to xcodebuild shell (destination) #1934

Merged

Conversation

MichelBahl
Copy link
Contributor

@MichelBahl MichelBahl commented May 10, 2023

  • destination is used for to specify the arch for iOS build
  • this is needed for modules which require arch x84_64

Summary:

With the destination build parameter it can be specified what destination (arch x86_64) gonna be used to build iOS

In case you are using an apple silicon Mac to build your app and you are using Pod dependencies which were not made for apple silicon it were not possible to change the arch for these dependencies from cli.

Error:
could not find module 'Adyen' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, at:

xcode would prompt to Build for Rosetta and add en config file

buildforrosetta

And create a settings file (which has no effect for cli build):
Bildschirmfoto 2023-05-10 um 18 15 45

Bildschirmfoto 2023-05-10 um 18 46 16

Test Plan:

  1. Install this fork
  2. Run following command npx react-native run-ios --simulator="iPhone 14 Pro" --destination arch=x86_64

@adamTrz
Copy link
Collaborator

adamTrz commented May 11, 2023

Hi @MichelBahl thanks for the PR! 💪

Looks like prettier check is failing? 🤔 Mind resolving that?
Also, why there're all those changes in yarn.lock file? :)

@MichelBahl
Copy link
Contributor Author

Removed changes in yarn.lock

@uloco
Copy link

uloco commented May 12, 2023

I'd like to test this but have no clue how to install this fork in my project since it is bundled into react-native....

@adamTrz
Copy link
Collaborator

adamTrz commented May 12, 2023

I'd like to test this but have no clue how to install this fork in my project since it is bundled into react-native....

Here's the guide :)

Basically you have to pull the fork (you can use GH CLI to do it or do it manually with git cmd ) and link it.
Then you should be able to test changes by running react-native commands against cloned repo

@uloco
Copy link

uloco commented May 12, 2023

@adamTrz I followed that guide but I still get error: unknown option '--destination' error

EDIT: Oh my bad I was on the wrong branch. Trying again 😓

@uloco
Copy link

uloco commented May 12, 2023

Now I'm getting this:

npx react-native run-ios --simulator="iPhone 14 Pro" --destination arch=x86_64
node:internal/modules/cjs/loader:1050
  throw err;
  ^

Error: Cannot find module '@react-native-community/cli-tools'
Require stack:
- /Users/uloco/Source/forks/cli/packages/cli/build/commands/init/errors/InvalidNameError.js
- /Users/uloco/Source/forks/cli/packages/cli/build/commands/init/validate.js
- /Users/uloco/Source/forks/cli/packages/cli/build/commands/init/init.js
- /Users/uloco/Source/forks/cli/packages/cli/build/commands/init/index.js
- /Users/uloco/Source/forks/cli/packages/cli/build/commands/index.js
- /Users/uloco/Source/forks/cli/packages/cli/build/index.js
- /Users/uloco/Source/RN71/node_modules/react-native/cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1047:15)
    at Module._load (node:internal/modules/cjs/loader:893:27)
    at Module.require (node:internal/modules/cjs/loader:1113:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at _cliTools (/Users/uloco/Source/forks/cli/packages/cli/build/commands/init/errors/InvalidNameError.js:8:16)
    at Object.<anonymous> (/Users/uloco/Source/forks/cli/packages/cli/build/commands/init/errors/InvalidNameError.js:14:32)
    at Module._compile (node:internal/modules/cjs/loader:1226:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1280:10)
    at Module.load (node:internal/modules/cjs/loader:1089:32)
    at Module._load (node:internal/modules/cjs/loader:930:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/uloco/Source/forks/cli/packages/cli/build/commands/init/errors/InvalidNameError.js',
    '/Users/uloco/Source/forks/cli/packages/cli/build/commands/init/validate.js',
    '/Users/uloco/Source/forks/cli/packages/cli/build/commands/init/init.js',
    '/Users/uloco/Source/forks/cli/packages/cli/build/commands/init/index.js',
    '/Users/uloco/Source/forks/cli/packages/cli/build/commands/index.js',
    '/Users/uloco/Source/forks/cli/packages/cli/build/index.js',
    '/Users/uloco/Source/RN71/node_modules/react-native/cli.js'
  ]
}

Node.js v18.14.0

But I linked them correctly and I can also see the link in the links folder.
I created a new RN project because I thought it is related to my project but dunno.....

@uloco
Copy link

uloco commented May 12, 2023

Looks like I needed to go into the linked directory and run yarn again. Build is running now, let's see if it runs through.

@uloco
Copy link

uloco commented May 12, 2023

IT WORKED! 🎉 🚀

Copy link
Collaborator

@szymonrybczak szymonrybczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! Thank you for contribution! 🎉

Comment on lines +231 to +234
{
name: '--destination <string>',
description: 'Explicitly extend distination e.g. "arch=x86_64"',
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this flag to the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to docs

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of react-native and the cli is this option available from? Doesn't seem to work in 0.70.14 with cli version 9.2.1. Thanks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @domthomhive, it's available since 0.72 (CLI version: 11.x).

- destination is used for to specify the arch for iOS build
- this is needed for modules which require arch x84_64
@MichelBahl MichelBahl force-pushed the fix/add-argument-destination branch from 93cef87 to ed5e9cf Compare May 16, 2023 06:35
@github-actions github-actions bot added the docs Documentation change label May 16, 2023
@adamTrz adamTrz added feature and removed bugfix labels May 16, 2023
@adamTrz adamTrz merged commit 29c7ea0 into react-native-community:main May 16, 2023
6 checks passed
thymikee pushed a commit that referenced this pull request May 16, 2023
- destination is used for to specify the arch for iOS build
- this is needed for modules which require arch x84_64
@medjamiaanes
Copy link

2. npx react-native run-ios --simulator="iPhone 14 Pro" --destination arch=x86_64

It's throwing unknown option '--destination' for me :/ . Any idea ?

@szymonrybczak
Copy link
Collaborator

Hey @medjamiaanes, are you sure that you correctly linked packages? (Please follow steps described here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation change feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants