Flutter & Firebase - iOS 오류

2022. 7. 15. 14:29DEV/Flutter

반응형

Android 보다 iOS 문제가 쉽게 잡히지 않는다. ㅂㄷㅂㄷ

Launching lib/main.dart on iPhone 13 Pro Max in debug mode...
lib/main.dart:1
CocoaPods' output:
↳
      Preparing
    Analyzing dependencies
    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
    cloud_firestore: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_auth` from `.symlinks/plugins/firebase_auth/ios`
    firebase_auth: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
    firebase_core: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
    -> Fetching podspec for `path_provider_ios` from `.symlinks/plugins/path_provider_ios/ios`
    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
    [!] CocoaPods could not find compatible versions for pod "cloud_firestore":
      In Podfile:
        cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
    Specs satisfying the `cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)` dependency were found, but they required a higher minimum deployment target.
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:317:in `raise_error_unless_state'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:299:in `block in unwind_for_conflict'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:297:in `tap'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:297:in `unwind_for_conflict'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:682:in `attempt_to_activate'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:254:in `process_topmost_state'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/resolver.rb:94:in `resolve'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1078:in `block in resolve_dependencies'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1076:in `resolve_dependencies'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:416:in `analyze'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in `install!'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `load'
    /usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `<main>'
Error output from CocoaPods:
↳
    [!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Error running pod install
Error launching application on iPhone 13 Pro Max.
Exited

플랫폼이 특정되지 않다며 Podfile Syntax Reference를 참고하라고 한다.

Podfile 수정

ios > Podfile

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0' # 기존 설정
platform :ios, '10.0' # 주석 제거 후 10.0으로 변경

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

pod install

$ cd [PROJECT_PATH]/ios # 프로젝트 내 ios 경로로 이동
$ pod install

참고로 9.0으로 설정하고 pod install 하면 아래와 같은 오류가 발생한다. 그래서 10으로 설정하고 진행하니 꽤 오랜 시간이 걸려서 업데이트를 완료했다.

$ pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "cloud_firestore":
  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)

Specs satisfying the `cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)` dependency were found, but they required a higher minimum deployment target.

10.0으로 진행한 결과이다.

$ pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '9.2.0' defined in 'firebase_core'
Downloading dependencies
Installing BoringSSL-GRPC (0.0.24)
Installing Firebase (9.2.0)
Installing FirebaseAuth (9.2.0)
Installing FirebaseCore (9.2.0)
Installing FirebaseCoreDiagnostics (9.3.0)
Installing FirebaseCoreInternal (9.3.0)
Installing FirebaseFirestore (9.2.0)
Installing Flutter (1.0.0)
Installing GTMSessionFetcher (2.0.0)
Installing GoogleDataTransport (9.1.4)
Installing GoogleUtilities (7.7.0)
Installing Libuv-gRPC (0.0.10)
Installing PromisesObjC (2.1.1)
Installing abseil (1.20211102.0)
Installing cloud_firestore (3.2.1)
Installing firebase_auth (3.4.1)
Installing firebase_core (1.19.1)
Installing gRPC-C++ (1.44.0)
Installing gRPC-Core (1.44.0)
xInstalling leveldb-library (1.22.1)
Installing nanopb (2.30909.0)
Installing path_provider_ios (0.0.1)
Generating Pods project
Integrating client project
Pod installation complete! There are 5 dependencies from the Podfile and 22 total pods installed.

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).

또 뭔가를 하라고 한다.

Target Support 설정 추가

ios > Fluuter > Release.xcconfig / Debug.xcconfig

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"

이렇게 해도 해결되지 않았다. 그래서 계속 찾아서 xcode를 열었다.

Open > [PROJECT_PATH]/ios

ios 폴더를 열어서 Product > Clean Build Folder를 실행한 뒤 Product > Build를 실행해준다.

이렇게 해고 나니 iOS Simulator에서 내 프로젝트 앱을 확인할 수 있었다! 하아...

다른 앱 사용 시 설정

macOS

macOS의 Flutter는 완전히 샌드박스 처리된 애플리케이션을 빌드합니다. 이 애플리케이션은 Firebase 서버와 통신하기 위해 네트워크를 사용하여 통합되므로 네트워크 클라이언트 권한으로 애플리케이션을 구성해야 합니다.

macos/Runner/DebugProfile.entitlements

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.cs.allow-jit</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
    <!-- Add the following two lines -->
    <key>com.apple.security.network.client</key>
    <true/>
</dict>
</plist>

macos/Runner/Release.entitlements

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <!-- Add the following two lines -->
    <key>com.apple.security.network.client</key>
    <true/>
</dict>
</plist>
반응형