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

Adds PATH for macOS #10031

Merged
merged 14 commits into from
Jan 22, 2024
7 changes: 5 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ appmin:
intellij_idea: '2022.3'
android_sdk: 19
powershell: 5.0
xcode: '14'
ios: '16'
cocoapods: '1.9'
devmin:
windows: '64-bit version of Microsoft Windows 10'
macos: '10.14 (Mojave)'
macos: '10.15 (Catalina)'
linux:
debian: 10
ubuntu: '18.04 LTS'
Expand Down Expand Up @@ -207,7 +210,7 @@ alert:
<aside class="alert alert-info" role="alert" markdown="1">
**Bonus questions!**
important: >-
<aside class="alert alert-warning" role="alert" markdown="1">
<aside class="alert alert-warning alert-icon" role="alert" markdown="1">
<i class="material-icons" aria-hidden="true">error</i> **Important:**
info: >-
<aside class="alert alert-info" role="alert" markdown="1">
Expand Down
33 changes: 16 additions & 17 deletions src/_includes/docs/install/compiler/xcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

To develop Flutter apps for {{os}}, install Xcode to compile to native bytecode.

1. To configure the Xcode command-line tools to use the installed version,
1. To configure the command-line tools to use the installed version of Xcode,
run the following commands.

```terminal
Expand Down Expand Up @@ -74,31 +74,30 @@ With Xcode, you can run Flutter apps on an iOS device or on the simulator.
### Install CocoaPods

If your apps depend on [Flutter plugins][] with native {{os}} code,
install CocoaPods. Built using Ruby,
CocoaPods handles the bundling of various dependencies across Flutter
and {{os}} code.
install [CocoaPods][cocoapods].
This program bundles various dependencies across Flutter and {{os}} code.

To [install and set up CocoaPods][cocoapods], run the following commands:
To install and set up CocoaPods, run the following commands:

1. Install Homebrew if necessary.
1. Install `cocoapods` following the
[CocoaPods install guide][cocoapods].

```terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$ sudo gem install cocoapods
```
1. Launch your preferred text editor.

1. Install `ruby` using Homebrew.
1. Open the Zsh environmental variable file `~/.zshenv` in your text editor.

```terminal
{{prompt1}} brew install ruby
```

1. Install `cocoapods` using Homebrew.
1. Copy the following line and paste it at the end of your `~/.zshenv` file.

```terminal
{{prompt1}} brew install cocoapods
```conf
export PATH=$HOME/.gem/bin:$PATH
```

Using Homebrew reduces potential issues with chipsets and install permissions.
Copy link
Contributor

Choose a reason for hiding this comment

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

@jmagman Why do we recommend Homebrew, but the CocoaPods Getting Started guide says to use gem install with the system Ruby installation?

@atsansone It would be great if we can lean more on the CocoaPods documentation here. At the very least, we should try to match what they recommend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I included Homebrew is that it was included in a previous version of this doc for the reasons stated in the Software requirements: Homebrew handles chipset and permissions issues for you. I would love to avoid:

  1. Sending users to too many other sites.
  2. Needing to cover off more edge cases when something doesn't work.

Copy link
Member

@jmagman jmagman Jan 11, 2024

Choose a reason for hiding this comment

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

@johnpryan I wouldn't have suggested Homebrew, I wasn't a reviewer on #9736.

https://docs.flutter.dev/get-started/install/macos/mobile-ios#install-cocoapods currently sounds like Homebrew is a requirement to do Flutter iOS development and it just isn't. cc @christopherfujino

I don't use Homebrew to manage Ruby or CocoaPods. I use the built in Ruby version to macOS and I follow CocoaPod's own installation instructions. For the purpose of this doc I would personally just point them to https://guides.cocoapods.org/using/getting-started.html#installation and call it a day instead of trying to replicate dependency's installation instructions.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also not a fan of Homebrew and skip any steps involving it. Leaning on Cocoapods own installation instructions and the options there seems good 👍

Copy link
Member

Choose a reason for hiding this comment

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

I got lost searching through the git history, but TL;DR we used to recommend brew install cocoapods, but this caused pain for our users, and is NOT the official way to install this, so we standardized on gem install cocoapods across the tool and website as our official recommendation.

Copy link
Member

Choose a reason for hiding this comment

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

For the purpose of this doc I would personally just point them to https://guides.cocoapods.org/using/getting-started.html#installation and call it a day instead of trying to replicate dependency's installation instructions.

This is aligned with what the tool tells users to do if we detect it's either missing or broken: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/macos/cocoapods.dart#L50

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most any explanation I've consulted doesn't recommend the default macOS install of Ruby. We used Homebrew elsewhere, so it seemed better to have one way to install everything instead of one way for this app, another for this other app, etc. Think as a new user: keep it simple.

We refer to Homebrew in about as many pages in the public docs: around 1-2 times each.

Looking at this as a new user, I'd like to recommend simple, consistent ways to handle installs wherever possible. Homebrew offers that option.

Further, the CocoaPods install docs themselves are out of date (referring to bash_profile, for example).

Although, @christopherfujino , your point about what exists in the code makes sense and may need a future revisit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmagman : Understood that CocoaPods is not required to build iOS apps for Flutter. It's required to build Flutter plugins for iOS apps, right? We could make that note, but not in a Getting Started. I would then need to add an additional section or page later to cover that off. What say you?

Copy link
Member

Choose a reason for hiding this comment

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

CocoaPods is required as soon as you add a plugin. I believe in the docs that used to be called out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It still is. ;)

1. Save your `~/.zshenv` file.

1. To apply this change, restart all open terminal sessions.

[Flutter plugins]: {{site.url}}/packages-and-plugins/developing-packages#types
[cocoapods]: https://formulae.brew.sh/formula/cocoapods
[cocoapods]: https://guides.cocoapods.org/using/getting-started.html#installation
5 changes: 4 additions & 1 deletion src/_includes/docs/install/devices/ios-simulator.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ follow this procedure.
1. To start the Simulator, run the following command:

```terminal
open -a Simulator
$ open -a Simulator
```

1. Set your Simulator to use a 64-bit device.
Expand All @@ -17,9 +17,12 @@ follow this procedure.

1. Go to **Window** <span aria-label="and then">></span>
**Devices and Simulators**.

You can also press <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>2</kbd>.

2. Once the **Devices and Simulators** dialog opens,
click **Simulators**.

3. Choose a **Simulator** from the left-hand list or press **+** to
create a new simulator.

Expand Down
6 changes: 3 additions & 3 deletions src/_includes/docs/install/flutter-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ or download and install the Flutter bundle yourself.

<div class="tab-pane active" id="vscode" role="tabpanel" aria-labelledby="vscode-tab" markdown="1">

{% include docs/install/flutter/vscode.md os=os terminal=terminal %}
{% include docs/install/flutter/vscode.md os=os terminal=terminal target=v-target %}

</div>

<div class="tab-pane" id="download" role="tabpanel" aria-labelledby="download-tab" markdown="1">

{% include docs/install/flutter/download.md os=os terminal=terminal %}
{% include docs/install/flutter/download.md os=os terminal=terminal target=v-target%}

</div>
</div>
{% comment %} End: Tab panes. {% endcomment -%}

If you have installed all prerequisites and the Flutter SDK,
you should be able to start developing Flutter on
{{include.os}} for {{include.target}}.
{{os}} for {{v-target}}.
21 changes: 15 additions & 6 deletions src/_includes/docs/install/flutter/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

{% assign os = include.os %}
{% assign osl = include.os | downcase %}
{% assign target = include.target %}
{% case os %}
{% when 'Windows' -%}
{% when "Windows" -%}
{% assign unzip='Extract-Archive' %}
{% assign path='C:\dev\' %}
{% assign terminal='PowerShell' %}
Expand Down Expand Up @@ -39,13 +40,18 @@
{% assign mv1 = 'mv ' | append: dirdl %}
{% endcase -%}

To install Flutter,
download the Flutter SDK bundle from its archive,
move the bundle to where you want it stored,
then extract the SDK.

1. Download the following installation bundle to get the latest
{{site.sdk.channel}} release of the Flutter SDK.

{% if os=='macOS' %}

| Intel | | <span class="apple-silicon">Apple Silicon</span> |
|-------| | ---------------|
| Intel Processor | | Apple Silicon |
|-----------------|-|---------------|
| [(loading...)](#){:.download-latest-link-{{osl}}.btn.btn-primary} | | [(loading...)](#){:.download-latest-link-{{osl}}-arm64.apple-silicon.btn.btn-primary} |

{% else %}
Expand Down Expand Up @@ -84,6 +90,9 @@

[SDK archive]: {{site.url}}/release/archive

{% if os == 'Windows' %}
{% include docs/install/reqs/windows/set-path.md terminal=terminal %}
{% endif %}
{% case os %}
{% when 'Windows' %}
{% include docs/install/reqs/windows/set-path.md terminal=terminal target=target %}
{% when 'macOS' %}
{% include docs/install/reqs/macos/set-path.md terminal=terminal target=target dir=dirinstall %}
{% endcase %}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if it's just me but this structure is hard to review with all of these includes. I've noticed that the size of the _includes directory is increasing and I'm not sure that's a great trend for maintainability overall. If there are places where we can just add the docs in-line I think that would be better in the long term.

Includes are great for reusable snippets of instructions but might have diminishing returns if we use them too much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be on first pass, but future updates may be easier. Most of these types of pages get a lot of reuse as most (~75%) of the content is the same for all 4 development platforms.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's really hard for me to follow what's going on. I have to jump around from file to file rather than just read it in-line.

22 changes: 15 additions & 7 deletions src/_includes/docs/install/flutter/vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
### Use VS Code to install Flutter
{:.no_toc}

#### Start Flutter install
To install Flutter using these instructions, verify that
you have installed [Visual Studio Code][]
{{site.appmin.vscode}} or later and the [Flutter extension for VS Code][].

#### Prompt VS Code to install Flutter
{:.no_toc}

1. Open VS Code.
1. Launch VS Code.

1. To open the Command Palette,
1. To open the **Command Palette**,
press <kbd>{{special}}</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>.

1. In the Command Palette, type `flutter`.
1. In the **Command Palette**, type `flutter`.

1. Select **Flutter: New Project**.

Expand All @@ -26,10 +30,12 @@
{:type="a"}
1. If you have the Flutter SDK installed, click **Locate SDK**.

1. If you do not have the Flutter SDK installed, click **Download SDK**.
1. If you do not have the Flutter SDK installed,
click **Download SDK**.

This option sends you the Flutter install page if you have not installed
Git for Windows as directed in the [development tools prerequisites][].
This option sends you the Flutter install page if you have not
installed Git {% if os == "Windows" %}for Windows {% endif %}as directed in
the [development tools prerequisites][].

1. When prompted **Which Flutter template?**, ignore it.
Press <kbd>Esc</kbd>.
Expand Down Expand Up @@ -128,3 +134,5 @@
1. Restart VS Code.

[development tools prerequisites]: #development-tools
[Visual Studio Code]: https://code.visualstudio.com/docs/setup/mac
[Flutter extension for VS Code]: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused link?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When you run the current version of `flutter doctor`,
it might list a different version of one of these packages.
If it does, install the version it recommends.
19 changes: 10 additions & 9 deletions src/_includes/docs/install/reqs/macos/apple-silicon.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{{site.alert.important}}
When installing on an [Apple Silicon Mac][],
install the Rosetta translation environment.
Some components require the [Rosetta][need-rosetta].
Some Flutter components require the
[Rosetta 2 translation process][need-rosetta]
on Macs running [Apple silicon][].
To run all Flutter components on Apple silicon,
install [Rosetta 2][rosetta].

```terminal
sudo softwareupdate --install-rosetta --agree-to-license
```
{{site.alert.end}}
```terminal
$ sudo softwareupdate --install-rosetta --agree-to-license
```

[Apple Silicon Mac]: https://support.apple.com/en-us/HT211814
[Apple silicon]: https://support.apple.com/en-us/HT211814
[rosetta]: https://support.apple.com/en-us/HT211861
[need-rosetta]: {{site.repo.this}}/pull/7119#issuecomment-1124537969
25 changes: 19 additions & 6 deletions src/_includes/docs/install/reqs/macos/base.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{% assign target = include.target %}
{% case target %}
{% when 'mobile-ios' %}
{% assign v-target = "iOS" %}
{% when 'mobile-android' %}
{% assign v-target = "Android" %}
{% else %}
{% assign v-target = target %}
{% endcase %}
{% assign os = include.os %}

## System requirements

To install and run Flutter,
your {{os}} environment must meet these requirements:
your {{os}} environment must meet the following hardware
and software requirements.

### Hardware requirements

Expand All @@ -14,35 +23,39 @@ minimal hardware requirements.
<div class="table-wrapper" markdown="1">
| Requirement | Minimum | Recommended |
|:-----------------------------|:------------------------------------------------------------------------:|:-------------------:|
| x86_64 CPU Cores | 4 | 8 |
| CPU Cores | 4 | 8 |
| Memory in GB | 8 | 16 |
| Display resolution in pixels | WXGA (1366 x 768) | FHD (1920 x 1080) |
| Free disk space in GB | {% include docs/install/reqs/macos/storage.md target=target %}
</div>

### Software requirements

To write and compile Flutter code for {{target}},
you must have the following version of macOS and the listed
software packages.
To write and compile Flutter code for {{v-target}},
install the following packages.

#### Operating system
{:.no_toc}

Flutter supports macOS {{site.devmin.macos}} or later.
This guide presumes your Mac runs the `zsh` as your default shell.

{% include docs/install/reqs/macos/zsh-config.md target=target %}

{% include docs/install/reqs/macos/apple-silicon.md %}

#### Development tools
{:.no_toc}

Download and install the macOS version of the following packages:
Download and install the following packages.

{% include docs/install/reqs/macos/software.md target=target %}

The developers of the preceding software provide support for those products.
To troubleshoot installation issues, consult that product's documentation.

{% include /docs/install/reqs/flutter-sdk/flutter-doctor-precedence.md %}

#### Text editor or integrated development environment
{:.no_toc}

Expand Down
33 changes: 33 additions & 0 deletions src/_includes/docs/install/reqs/macos/set-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% assign terminal=include.terminal %}
{% assign target = include.target %}
{% assign dir = include.dir %}

### Add Flutter to your `PATH`
{:.no_toc}

To run Flutter commands in {{terminal}},
add Flutter to the `PATH` environment variable.
This guide presumes your [Mac runs the latest default shell][zsh-mac], `zsh`.
Zsh uses the `.zshenv` file for [environment variables][envvar].

1. Launch your preferred text editor.

1. If it exists, open the Zsh environmental variable file `~/.zshenv`
in your text editor. If it doesn't, create `~/.zshenv`.

1. Copy the following line and paste it at the end of your `~/.zshenv` file.

```conf
export PATH=$HOME/development/flutter/bin:$PATH
```

1. Save your `~/.zshenv` file.

1. To apply this change, restart all open terminal sessions.

If you use another shell,
check out [this tutorial on setting your PATH][other-path].

[zsh-mac]: https://support.apple.com/en-us/102360
[envvar]: https://zsh.sourceforge.io/Intro/intro_3.html
[other-path]: https://www.cyberciti.biz/faq/unix-linux-adding-path/
Loading
Loading