Set up iOS development
Learn how to set up your development environment to run, build, and deploy Flutter apps for iOS devices.
Install Xcode
#With Xcode, you can run Flutter apps on an iOS physical device or on the iOS Simulator.
If you haven't done so already, install and set up Xcode.
-
Configure Xcode's command-line tools:
sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch'
-
Sign the Xcode license agreement:
sudo xcodebuild -license
-
Download iOS platform support and simulator runtimes:
xcodebuild -downloadPlatform iOS
Install Rosetta
#If you are developing on an Apple Silicon (ARM) Mac, install Rosetta 2.
sudo softwareupdate --install-rosetta --agree-to-license
Install CocoaPods
#To support Flutter plugins that use native iOS code, install CocoaPods. CocoaPods bundles various dependencies that support connecting Flutter to native iOS code.
Install cocoapods
following the
CocoaPods installation guide.
Configure your target iOS device
#We recommend starting with the iOS Simulator as it's easier to get set up than a physical iOS device. However, you should also test your app on an actual physical device.
Configure your iOS Simulator
#Start the iOS Simulator with the following command:
open -a Simulator
If you need to install a simulator for a different OS version, check out Downloading and installing additional Xcode components on the Apple Developer site.
Set up each iOS device on which you want to test.
Configure your physical iOS device
#-
Attach your iOS device to the USB port on your Mac.
-
On first connecting an iOS device to your Mac, your device will display the Trust this computer? dialog.
-
Click Trust.
Enable Developer Mode
#Apple requires enabling Developer Mode on the device to protect against malicious software.
-
Tap on Settings > Privacy & Security > Developer Mode.
-
Tap to toggle Developer Mode to On.
-
Restart the device.
-
When the Turn on Developer Mode? dialog appears, tap Turn On.
Create a developer code signing certificate
#To send your app to a physical iOS device, even for testing, you must establish trust between your Mac and the device. In addition to trusting the device when that popup appears, you must upload a signed developer certificate to your device.
To create a signed development certificate, you need an Apple ID. If you don't have one, create one. You must also enroll in the Apple Developer program and create an Apple Developer account. If you are just testing your app on an iOS device, a personal Apple Developer account is free and works.
Prepare the device
#Find your Profiles & Device Management menu under Settings. (The exact location can vary by device.) Toggle your certificate to Enable.
-
Under the Developer App heading, you should find your certificate.
-
Tap the certificate.
-
Tap Trust "<certificate>".
-
When the dialog displays, tap Trust.
If the codesign wants to access key... dialog appears:
-
Enter your macOS password.
-
Tap Always Allow.
Start developing for iOS
#Congratulations. You can now start developing and testing Flutter apps on iOS!
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2025-05-09。 查看文档源码 或者 为本页面内容提出建议.