DEV Community

Moses Karunia
Moses Karunia

Posted on

Fixing Flutter iOS build fail

I have sour experiences on configuring your iOS Flutter build, since I have no experience whatsoever in iOS. But after reading some articles on the internet, I found that many iOS devs also think iOS deployment is kinda hard to do. Often I did shadow punching on google before finding random stranger post a nice pointer.

This article mainly meant as reference in case someone (or myself in the future), hit some roadblock in order to make one. Most credits also go to guys who originally post these solutions I found on the internet. I cannot add any reference to you, because it lost in my search history. You can comment below if you want to be mentioned, though.

Please note that most problem can be solved by creating a new flutter project using the latest stable version, copy-pasting the content of iOS/, and applying manually-made changes (like adding permission on info.plist, firebase-related adjustments, etc)

I'll try to keep this article updated in future Flutter, iOS & XCode releases.

Works well on:

MacOS Catalina 10.15.6
Flutter 1.20.2
Dart 2.7.0
XCode 11.6
iPadOS 13.6.1 (iPad 10.2 - 2019)
iOS Deployment 9.0 (The one set in ios/Podfile as platform :ios, '9.0')


Use the latest STABLE release

Why? Because, it's nice if you can shave down your potential problems by using stable releases.

e.g. XCode version, iPadOS / iOS version, flutter version etc.

Frameworks, Libraries and Embedded Content

Alt Text

iOS Project Structure

Pay attention on the content under Flutter/ and Runner/

Alt Text

Targets > Runner > Build Phases

Run Script

The content should EXACTLY be

/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed

Enter fullscreen mode Exit fullscreen mode

With ONLY "Show environment variables in build log" checked.

Compile Sources, Link binary with libraries, Copy Bundle Resources and Embed Frameworks

Alt Text

Thin Library

Content should EXACTLY be:

/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" thin
Enter fullscreen mode Exit fullscreen mode

(NOT embed_and_thin)

With ONLY "Show environment variables in build log" checked.

Targets > Runner > Build Settings

All > Linking > Other Linker Flags

Alt Text


This is the snippet of my package.yaml if you are wondering (because sometimes build fails because of certain release of a library in your dependency)

Note that I didn't use any ^ to prefix the version to make things more certain.

environment:
  sdk: ">=2.7.0 <3.0.0"
  flutter: 1.20.2

dependencies:
  flutter:
    sdk: flutter

  material_design_icons_flutter: 4.0.5345
  cupertino_icons: 0.1.3
  google_fonts: 0.3.2
  get_it: 4.0.2
  equatable: 1.2.0
  dartz: 0.9.1
  meta: 1.1.8
  json_annotation: 3.0.1
  google_sign_in: 4.5.1
  sign_in_with_apple: 
  firebase_core: 0.4.4
  firebase_auth: 0.15.4
  firebase_messaging: 6.0.16
  firebase_analytics: 5.0.16
  graphql: 3.0.2
  flutter_bloc: 6.0.1
  qr_flutter: 3.2.0
  jaguar_jwt: 2.1.6
  barcode_scan: 3.0.1
  dio: 3.0.9
  image_cropper: 1.2.3
  image_picker: 0.6.7+4
  intl: 0.16.1
  stream_transform: 1.2.0
  flare_flutter: 2.0.3
  flutter_svg: 0.18.0
  shared_preferences: 0.5.7+3
  collection: 1.14.13
  flutter_local_notifications: 1.4.4+2
  pattern_formatter: 1.0.2
  hydrated_bloc: 6.0.1
  url_launcher: 5.5.0
  pull_to_refresh: 1.6.0
  copy_with_extension: ">=1.2.0 <2.0.0"
  flame: 0.24.0
  flutter_i18n: 0.17.0
  flutter_neumorphic: 3.0.1
  package_info: 0.4.1
  extended_image: 1.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  mockito: 4.1.1
  build_runner: 1.10.1
  json_serializable: 3.3.0
  bloc_test: 7.0.0
  copy_with_extension_gen: ">=1.2.0 <2.0.0"
  flutter_launcher_icons: 0.7.5
Enter fullscreen mode Exit fullscreen mode

That's all I think are important, if you wanna know any other configs, feel free to lemme know in the comment. I'll let you know if I know the answer.

Hope this saves your time!

Top comments (0)