Installing flutter on MacOS

Download flutter stable from the flutter development website
https://flutter.dev/

Create new folder in user document

cd ~
mkdir development

Then move the downloaded file to your development folder

Go to your development from terminal

cd development
export PATH="$PATH:`pwd`/flutter/bin"

Note : You need to be in your development folder and this only set temporary to your current terminal windows

Updating the path permanently
In your mac go to your user folder (Cmd + Shift + H from finder)
Make sure you show your hidden files by pressing (Cmd + Shift + Dot)

Open .bash_profile file to add the path permanently.
If you don't have .bash_profile or .zpofile, create one
  1. Start up Terminal.
  2. Type "cd ~/" to go to your home folder.
  3. Type "touch . bash_profile" to create your new file.
  4. Edit . bash_profile with your favorite editor (or you can just type "open -e . bash_profile" to open it in TextEdit).
  5. Type "source . bash_profile" to reload . bash_profile and update any functions you add.

Download and install android studio

Install and download android studio from https://developer.android.com/studio/

Download and install xCode

Install xCode from app store if you haven't got it yet.
After that install xCode command line tools
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
sudo xcodebuild -license

Precahe other dependencies

flutter precache

Open Device simulator

open -a simulator to open device simulator

and now you're ready to run your first flutter app in iOS

Creating and running new flutter app

cd ~
mkdir flutter_projects
cd flutter_projects
flutter create first_app
cd first_app
flutter run

Deploying flutter app to device

gem install cocoapods

If the following error occurs, which means you need to update your ruby version
ERROR: Failed to build gem native extension.

ruby -v to check your current ruby version
if your ruby version is <2.4 then you need to update

curl -L https://get.rvm.io | bash -s stable
source /Users/your_user_name/.rvm/scripts/rvm to update the added bashes
rvm install ruby-2.6.3
rvm use ruby-2.6.3
rvm --default use 2.6.3

gem install cocoapods
podsetup

Install it on the actual device

cd flutter_projects/first_app
open ios/Runner.xcworkspace

Then apply development profile, select your phone and run it

Defining Global iOS Deployment 

This is the important step and if you didn't do it, you application might not run with thirdparty plugins such as facebook_login

Open Podfile in ios folder
uncomment platform:ios,'9.0' and change to platform:ios'10.0'.
Default platform version is 8.0 which doesn't work with most of the thirdparty plugins.

Note : Always do flutter clean once you've installed new plugins
Note : Never change Display name ("Runner") in XCode




Comments

Popular posts from this blog

Publishing Flutter app

Solving flutter web app CORS policy