1.5 Flutter IOS setup

If you want to develop Flutter IOS applications under MacOS, you need to complete the following IOS setup. Install Xcode To develop Flutter apps for iOS, you need a Mac with Xcode installed. Install the latest stable version of Xcode (using web download or the Mac App Store). Configure the Xcode command-line tools to use […]

If you want to develop Flutter IOS applications under MacOS, you need to complete the following IOS setup.

Install Xcode

To develop Flutter apps for iOS, you need a Mac with Xcode installed.

  1. Install the latest stable version of Xcode (using web download or the Mac App Store).

  2. 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.

  3. Make sure the Xcode license agreement is signed by either opening Xcode once and confirming or running sudo xcodebuild -license from 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:

  1. On your Mac, find the Simulator via Spotlight or by using the following command:

    open -a Simulator
  2. 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.

  3. 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.

  1. You can skip this step if your apps do not depend on Flutter plugins with native iOS code. Install and set up CocoaPods by running the following commands:

    sudo gem install cocoapods

    Note:

    The default version of Ruby requires sudo to install the CocoaPods gem. If you are using a Ruby Version manager, you may need to run without sudo.

  2. Follow the Xcode signing flow to provision your project:

    1. Open the default Xcode workspace in your project by running open ios/Runner.xcworkspace in a terminal window from your Flutter project directory.

    2. Select the device you intend to deploy to in the device drop-down menu next to the run button.

    3. Select the Runner project in the left navigation panel.

    4. In the Runner target 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.

      xcode-account
      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 Trust in the dialog prompt when first connecting the iOS device to your Mac.

      trust-computer
      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.

      xcode-unique-bundle-id

  3. Start your app by running flutter run or clicking the Run button in Xcode.

Author: Hi, I’m iBllex

I am a freelancer. Currently working on Golang, PHP, WordPress, React, Vue, TypeScript, Flutter and other technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *