If you want to develop Flutter IOS applications under MacOS, you need to complete the following IOS setup.
To develop Flutter apps for iOS, you need a
Configure the Xcode command-line tools to use the newly-installed version of Xcode by running the following from the command line:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch
This is the correct path for most cases, when you want to use the latest version of Xcode. If you need to use a different version, specify that path instead.
Make sure the Xcode license agreement is signed by either opening Xcode once and confirming or running
sudo xcodebuild -licensefrom the command line.
Versions older than the latest stable version may still work, but are not recommended for Flutter development. Using old versions of Xcode to target bitcode is not supported, and is likely not to work.
With Xcode, you’ll be able to run Flutter apps on an iOS device or on the simulator.
Set up the iOS simulator
To prepare to run and test your Flutter app on the iOS simulator, follow these steps:
On your Mac, find the Simulator via Spotlight or by using the following command:
open -a Simulator
Make sure your simulator is using a 64-bit device (iPhone 5s or later) by checking the settings in the simulator’s Hardware > Device menu.
Depending on your development machine’s screen size, simulated high-screen-density iOS devices might overflow your screen. Grab the corner of the simulator and drag it to change the scale. You can also use the Window > Physical Size or Window > Pixel Accurate options if your computer’s resolution is high enough.
- If you are using a version of Xcode older than 9.1, you should instead set the device scale in the Window > Scale menu.
Deploy to iOS devices
To deploy your Flutter app to a physical iOS device you’ll need to set up physical device deployment in Xcode and an Apple Developer account. If your app is using Flutter plugins, you will also need the third-party CocoaPods dependency manager.
sudo gem install cocoapods
The default version of Ruby requires
sudoto install the CocoaPods gem. If you are using a Ruby Version manager, you may need to run without
Follow the Xcode signing flow to provision your project:
Open the default Xcode workspace in your project by running
open ios/Runner.xcworkspacein a terminal window from your Flutter project directory.
Select the device you intend to deploy to in the device drop-down menu next to the run button.
Runnerproject in the left navigation panel.
Runnertarget settings page, make sure your Development Team is selected under Signing & Capabilities > Team.
When you select a team, Xcode creates and downloads a Development Certificate, registers your device with your account, and creates and downloads a provisioning profile (if needed).
- To start your first iOS development project, you might need to sign into Xcode with your Apple ID.
Development and testing is supported for any Apple ID. Enrolling in the Apple Developer Program is required to distribute your app to the App Store. For details about membership types, see Choosing a Membership.
- The first time you use an attached physical device for iOS development, you need to trust both your Mac and the Development Certificate on that device. Select
Trustin the dialog prompt when first connecting the iOS device to your Mac.
Then, go to the Settings app on the iOS device, select General > Device Management and trust your Certificate. For first time users, you may need to select General > Profiles > Device Management instead.
- If automatic signing fails in Xcode, verify that the project’s General > Identity > Bundle Identifier value is unique.
Start your app by running
flutter runor clicking the Run button in Xcode.