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

docs: add Rosetta Simulator Instructions #4599

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,27 @@ packagingOptions {
exclude 'META-INF/LICENSE'
}
```

### Running Detox in a Rosetta environment

When working with dependencies that require running your iOS app in a Rosetta simulator, you may encounter issues with the `detox build` command. These issues often relate to SwiftEmitModule or SwiftCompile errors. To resolve this, follow these steps:

1. Modify your build command in the Detox configuration:

```json
"build": "xcodebuild -workspace ios/MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -arch x86_64 -derivedDataPath ios/build"
```
Comment on lines +136 to +140
Copy link
Contributor

Choose a reason for hiding this comment

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

Example is not enough, please emphasize that it's done by specifying arch=x86_64

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it will also work if you'll set that from the project's build settings

image

Choose a reason for hiding this comment

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

@asafkorem Setting it via the build settings might lead to conflicts with the necessary configuration for the app. In my project, for instance, I need specific build settings due to different dependencies. My goal is to adjust the architecture specifically for running the Detox tests, without altering the overall app build. That's why I chose to modify only the Detox build command. I want to emphasize that this is about changing Detox’s behavior, not my app’s – a crucial distinction!

Copy link
Contributor

Choose a reason for hiding this comment

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

@differenzPriv True, I get your point. If your app can run in the Rosetta environment on Apple Silicon without Detox, then Detox is the only concern here, and your approach makes perfect sense. However, if that's not the case, it would be reasonable to add this architecture under the Debug configuration in Xcode. It might be worth mentioning this distinction in the doc IMO.

Choose a reason for hiding this comment

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

In Xcode, you can enable "Show All Simulators". Here, we select the Rosetta simulator for the normal build. In the "Excluded Architectures" tab, we select the "arm64" architecture, not "x86_64". So, in my case, I only need to change the architecture for the "detox-build-command" and not the general one.

I like your suggestion to mention this distinction for better understanding and for choosing the right solution for a specific use case. 👍🏻

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense @differenzPriv.
@kagrawal98 can you add this note?


2. Run the following command in your terminal to ensure Xcode is properly selected:

```bash
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
kagrawal98 marked this conversation as resolved.
Show resolved Hide resolved
```
kagrawal98 marked this conversation as resolved.
Show resolved Hide resolved

3. Launch the iOS simulator in Rosetta mode:

```bash
arch -x86_64 /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator
```

After following these steps, the `detox build` command should run without errors in your Rosetta environment.