iOS Implementation
Purpose and Scope
This document provides a technical overview of the iOS-specific implementation in the Flutter example app. It details the iOS configuration files, build settings, and dependencies that enable the Flutter app to run on iOS devices. For information about the Android implementation, see Android Implementation, and for WebView implementation details across platforms, see WebView Implementation.
iOS Architecture Overview
The iOS implementation of the Flutter example app follows the standard integration pattern for Flutter applications on iOS. The integration consists of several key components working together to host the Flutter engine and render the Flutter UI within an iOS application.
CocoaPods Integration
iOS Application
AppDelegate.swift
Flutter Engine
Info.plist
App Configuration
WKWebView Implementation
AppFrameworkInfo.plist
Flutter Framework
Podfile
Flutter Dependency
webview_flutter_wkwebview
Podfile.lock
Dependency Versions
Core iOS Configuration Files
AppFrameworkInfo.plist
The AppFrameworkInfo.plist file contains essential metadata for the Flutter framework when running on iOS. This file defines the Flutter app framework's properties including the bundle identifier, version information, and minimum iOS version requirement.
Key configurations in this file include:
| Key | Value | Purpose |
|---|---|---|
| CFBundleIdentifier | io.flutter.flutter.app | Identifies the Flutter framework bundle |
| CFBundleExecutable | App | Specifies the executable name |
| MinimumOSVersion | 12.0 | Sets the minimum supported iOS version |
| CFBundleVersion | 1.0 | Defines the build version |
Dependency Management with CocoaPods
The Flutter example app uses CocoaPods to manage iOS dependencies. Two critical files handle this process:
- Podfile: Defines the dependencies and configuration for the iOS project
- Podfile.lock: Records the exact versions of dependencies used
Podfile
flutter_ios_podfile_setup
Runner Target
use_frameworks!
flutter_install_all_ios_pods
post_install hooks
flutter_additional_ios_build_settings
Podfile.lock
Dependency List
Flutter (1.0.0)
webview_flutter_wkwebview (0.0.1)
Flutter
FlutterMacOS
iOS Dependency Structure
The example app has minimal but essential dependencies required for its functionality:
Primary Dependencies
- Flutter Framework: Core framework for running Flutter applications on iOS
- webview_flutter_wkwebview: Plugin that provides WebView functionality using WKWebView on iOS
These dependencies are defined in the Podfile and locked to specific versions in Podfile.lock:
Source Paths
Dependencies
Flutter (1.0.0)
webview_flutter_wkwebview (0.0.1)
Flutter path
webview_flutter_wkwebview path
FlutterMacOS
iOS Build Configuration Process
The iOS build process for Flutter apps involves several key steps that integrate Flutter with native iOS components.
"iOS App"Xcode"CocoaPods""Flutter CLI"Developer"iOS App"Xcode"CocoaPods""Flutter CLI"Developer
flutter build ios
Generate Flutter iOS framework
install dependencies
Read Podfile
Resolve dependencies
Update Podfile.lock
Configure project with pods
Apply build settings
Apply post_install configurations
Generate iOS app bundle
The Podfile orchestrates important build steps:
- Initial project configuration for different build types (Debug, Profile, Release)
- Flutter root path discovery for integration
- Pod setup and installation for the Runner target
- Post-installation configuration to ensure Flutter works correctly
Podfile Configuration Details
The Podfile contains several important sections that configure how the Flutter app integrates with iOS:
Project Configuration
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
This section maps the Flutter build modes to iOS build configurations.
Flutter Integration
def flutter_root
# Code to find Flutter root path
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
These functions locate the Flutter installation and set up the iOS environment to work with Flutter.
Target Configuration
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
# Test target configuration
end
This section configures the main app target, enabling Swift frameworks and installing all required Flutter iOS pods.
Post-Installation Hooks
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
The post-installation hook applies additional Flutter-specific build settings to all pod targets.
iOS Minimum Version Requirement
The example app requires iOS 12.0 or higher, as specified in the AppFrameworkInfo.plist:
<key>MinimumOSVersion</key>
<string>12.0</string>
This minimum version is necessary to support the latest features of Flutter and the WKWebView component used in the app.
Integration with WebView Functionality
The iOS implementation integrates with the Flutter WebView functionality through the webview_flutter_wkwebview plugin. This plugin provides a native implementation of WKWebView for iOS, enabling the app to display web content.
Key aspects of this integration:
- The plugin is included as a dependency in the Podfile
- The plugin requires both Flutter and FlutterMacOS frameworks
- The native WKWebView component is wrapped by the plugin to provide a Flutter-compatible interface
Summary
The iOS implementation of the Flutter example app demonstrates a standard Flutter-iOS integration pattern. It leverages CocoaPods for dependency management, includes necessary configuration files like AppFrameworkInfo.plist, and integrates the webview_flutter_wkwebview plugin for WebView functionality. The minimum iOS version requirement is 12.0, ensuring compatibility with modern iOS features while maintaining broad device support.