"macOS에서 Xcode와 Flutter를 설치하여 iOS 앱 개발 환경을 구축하는 방법을 알아보세요. 이 가이드에서는 Xcode 설치, Flutter SDK 설정, 환경 변수 설정 등 iOS 개발을 위한 모든 준비 단계를 상세히 설명합니다."

1. Xcode 설치
Flutter로 iOS 앱을 개발하려면 Xcode가 필요하므로, App Store를 열어 Xcode를 검색한 후 다운로드 및 설치한다.
설치 후, Xcode를 처음 실행하여 필요한 추가 컴포넌트를 설치한다.
Xcode CLI (Command Line Tools) 도 설치한다.
% xcode-select --install xcode-select: note: install requested for command line developer tools
2. Homebrew 설치
Flutter 설치를 위해 Homebrew 패키지 관리자를 용하는 것이 편리하므로, Homebrew가 설치되어 있지 않다면 다음 명령어를 통해 설치할 수 있다.
% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ==> Checking for `sudo` access (which may request your password)... Password: ==> This script will install: /opt/homebrew/bin/brew /opt/homebrew/share/doc/homebrew /opt/homebrew/share/man/man1/brew.1 /opt/homebrew/share/zsh/site-functions/_brew /opt/homebrew/etc/bash_completion.d/brew /opt/homebrew Press RETURN/ENTER to continue or any other key to abort: ==> /usr/bin/sudo /usr/sbin/chown -R planv:admin /opt/homebrew ==> Downloading and installing Homebrew... remote: Enumerating objects: 79922, done. remote: Counting objects: 100% (23646/23646), done. remote: Compressing objects: 100% (283/283), done. remote: Total 79922 (delta 23454), reused 23490 (delta 23344), pack-reused 56276 (from 1) remote: Enumerating objects: 55, done. remote: Counting objects: 100% (34/34), done. remote: Total 55 (delta 33), reused 33 (delta 33), pack-reused 21 (from 1) ==> Updating Homebrew... ==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:e7340e4a1d7cc0f113686e461b93114270848cb14676e9037a1a2ff3b1a0ff32 ############################################################################################################ 100.0% ==> Pouring portable-ruby-3.3.5.arm64_big_sur.bottle.tar.gz Installing from the API is now the default behaviour! You can save space and time by running: brew untap homebrew/core Updated 1 tap (homebrew/bundle). ==> Installation successful! ==> Homebrew has enabled anonymous aggregate formulae and cask analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics No analytics data has been sent yet (nor will any be during this install run). ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Next steps: - Run brew help to get started
3. Flutter 설치 및 실행
1) sdk 다운로드
- 먼저 Flutter 공식 홈페이지에서 macOS용 Flutter SDK를 다운로드한다. 사용하고 있는 CPU 타입을 확인*하여 적절한 sdk 를 다운로드한다.
- 다운로드한 .zip 파일을 원하는 위치에 압축을 푼다. 일반적으로 /Users/your_username/flutter에 설치한다.
* 맥북 CPU 아키텍처 확인 방법: Intel 또는 Apple 실리콘 여부 쉽게 알아보는 법
2) 환경변수 설정
아래와 같이 Flutter SDK의 경로를 PATH에 추가해 준다.
% nano ~/.zshrc

파일을 저장한 후 변경사항을 반영한다.
% source ~/.zshrc
3) Flutter 도구가 제대로 설치되었는지를 다음 명령어를 통해 확인한다.
% flutter doctor ┌─────────────────────────────────────────────────────────┐ │ A new version of Flutter is available! │ │ │ │ To update to the latest version, run "flutter upgrade". │ └─────────────────────────────────────────────────────────┘ Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.13.0, on macOS 13.5.1 22G90 darwin-arm64, locale ko-KR) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] Connected device (2 available) [✓] Network resources • No issues found!
4) Flutter로 iOS 앱을 빌드하기 위해 CocoaPods 를 설치한다. CocoaPods는 Xcode 프로젝트에서 외부 라이브러리를 쉽게 관리할 수 있도록 도와주는 도구로, Homebrew를 이용해 다음과 같이 설치할 수 있다.
% brew install cocoapods
5) xcode 설정
iOS 개발을 위해 다음과 같은 추가 설정이 필요하다. Xcode 를 실행하여 Settings > Locations 탭에서 명령줄 도구(Command Line Tools)가 올바르게 선택되었는지 확인한다.

프로젝트를 빌드할 때 사용하는 시뮬레이터를 Xcode에서 설치하고 설정한다. Flutter에서 iOS 시뮬레이터를 사용하려면 다음 명령어를 사용할 수 있다.
% open -a Simulator
다음과 같이 iOS 시뮬레이터가 실행됨을 확인할 수 있다.

6) Flutter 프로젝트를 생성하고 실행한다.
- Flutter 프로젝트 생성
% flutter create my_flutter_app Creating project my_flutter_app... Resolving dependencies in my_flutter_app... Got dependencies in my_flutter_app. Wrote 129 files. All done! You can find general documentation for Flutter at: https://docs.flutter.dev/ Detailed API documentation is available at: https://api.flutter.dev/ If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev In order to run your application, type: $ cd my_flutter_app $ flutter run Your application code is in my_flutter_app/lib/main.dart.
프로젝트 디렉토리로 이동한 후 iOS 시뮬레이터에서 실행한다.
% cd my_flutter_app my_flutter_app % flutter run Resolving dependencies... async 2.11.0 (2.12.0 available) boolean_selector 2.1.1 (2.1.2 available) characters 1.3.0 (1.3.1 available) clock 1.1.1 (1.1.2 available) collection 1.17.2 (1.19.1 available) fake_async 1.3.1 (1.3.2 available) flutter_lints 2.0.3 (5.0.0 available) lints 2.1.1 (5.1.0 available) matcher 0.12.16 (0.12.17 available) material_color_utilities 0.5.0 (0.12.0 available) meta 1.9.1 (1.16.0 available) path 1.8.3 (1.9.1 available) stack_trace 1.11.0 (1.12.0 available) stream_channel 2.1.1 (2.1.2 available) string_scanner 1.2.0 (1.4.0 available) test_api 0.6.0 (0.7.3 available) web 0.1.4-beta (1.1.0 available) Got dependencies! Launching lib/main.dart on iPhone 14 Pro Max in debug mode... Running Xcode build... └─Compiling, linking and signing... 17.6s Xcode build done. 29.2s [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend. Syncing files to device iPhone 14 Pro Max... 113ms Flutter run key commands. r Hot reload. 🔥🔥🔥 R Hot restart. h List all available interactive commands. d Detach (terminate "flutter run" but leave application running). c Clear the screen q Quit (terminate the application on the device). A Dart VM Service on iPhone 14 Pro Max is available at: http://127.0.0.1:51063/jmYv9TXKYpE=/ The Flutter DevTools debugger and profiler on iPhone 14 Pro Max is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:51063/jmYv9TXKYpE=/
Xcode 시뮬레이터가 실행되며 Flutter 앱이 실행되는 것을 볼 수 있다.


'프로그래밍 Programming' 카테고리의 다른 글
Xcode 프로젝트 완벽 삭제 가이드 – 깨끗하게 정리하는 방법 (1) | 2024.12.27 |
---|---|
프로시저 시작 지점GetSystemTimePreciseAsFileTime을(를) DLL KERNEL32.에서 찾을 수 없습니다 (0) | 2024.11.08 |
맥북 CPU 아키텍처 확인 방법: Intel 또는 Apple 실리콘 여부 쉽게 알아보는 법 (0) | 2024.11.08 |
The model `text-davinci-003` has been deprecated (4) | 2024.10.25 |
OpenAI GPT 와 Chroma 를 이용하여 미국세법 관련 질문에 답하는 TaxGPT 만들기 Developing TaxGPT using OpenAI GPT and Chroma (0) | 2023.04.24 |
댓글을 사용할 수 없습니다.