Skip to content

iOS app development

André Pedersen edited this page Sep 28, 2023 · 9 revisions

Before starting

  • To develop for iOS, you have to use an Apple device (e.g., macbook).
  • To make distributable apps (e.g., IPA/.ipa), you also need to an Apple Developer license that costs money (about 99 USD a year).
  • It is possible to develop apps for iOS for free, as well as run the debugger on a USB-connected device (e.g., iPhone), but to make distributable apps you need to own a license.

Setup IDE

To build for iOS, you will need to use XCode. It is possible to develop using a different IDE such as VS Code, but to build for iOS you need XCode.

I successfully developed a distributed IPA using macOS-12 with XCode 14.2, so I would recommend the same (see here for how to download XCode). I had issues with signing the IPA for older versions of XCode with older OS, i.e., macOS-11 and XCode 13, so I would recommend using the later versions (or preferably the same).

Setup Flutter

To use Flutter for iOS development, you will have to have XCode, git, and CocoaPods installed. Information on how to do that can be found on the Flutter documentations website.

Note that Flutter recommend installing CocoaPods with gem, but this resulted in issues on my setup. I used brew instead (see here):

brew install cocoapods

Setting up project

First be sure that Flutter is properly setup by running the command below and resolving all issues:

flutter doctor

Note that the Android Studio step is not required for iOS.

To use the app with XCode, you will need to initialize the iOS project using flutter build ios, and then open the ios/Runner.xcodeproj folder in XCode.

USB debugging

To debug on an iPhone, connect the phone with USB to the macbook, then run the app.

You might need to allow debugging on the phone, but it should work out-of-the-box.

Useful resources

  1. If you experience any issues with building the IPA with GitHub Actions, you can check which tools and versions that are bundled as part of a specific OS-version, for instance for macos-12, see here.

  2. This resource was also very helpful in me understanding why I was unable to sign my IPA with the Actions CI.

  3. When building the IPA and to be able to sign it with GitHub Actions CI workflows, here is a good example on how the generated exportOptions.plist should look like.

  4. If you are getting issues with Provisioning Profiles in the CI, codemagic made it possible a one-liner. Just be sure to install it using pip and calling xcode-project use-profiles, which should make the export_options.plist for you with automatically filled provision profile (given that you have provided the correct certificate/mobileprovision/passwords to GitHub Secrets).

  5. Other useful resources describing how to build IPAs with GitHub Actions from A-B, can be found on Medium, Apple Docs, Flutter CI examples, and this blog post.

  6. To avoid making a commit to test CIs, you can run the Actions locally using act. For instance on macos-11: brew install act > act build > act -j build-ipa -P macos-11=-self-hosted. Note the -self-hosted. That is quite important to get it working properly on your local setup. For more info, see here.

  7. Bug: _"The 'Pods-Runner' target has transitive dependencies that include statically linked binaries"_ - This issue you might experience at the very start trying to build the app (even for debugging). The fix can be see here.

  8. Bug: _"[Unable to find a target named Runnerin projectRunner.xcodeproj](https://stackoverflow.com/questions/67405994/unable-to-find-a-target-named-runner-in-project-runner-xcodeproj-did-find-d)"_ - Fix can be seen here.

  9. Bug: _"[Error: Could not find included file 'Generated.xcconfig' in search paths (in target 'Runner')](https://stackoverflow.com/questions/54321180/error-could-not-find-included-file-generated-xcconfig-in-search-paths-in-tar)"_ - This you might observe the very first attempt trying to run the app. You basically just have to run the flutter build once outside Xcode and you are good to go. See here.

  10. Changing the name of the App is surprisingly annoying, and for both iOS and Android, you will have to modify multiple places (see here). Note that on Flutter, the app name is directly linked to the project name - and CANNOT be changed (lazy coding). So you will need to change the project name if you want to change the app (as well as many other things). A good idea is to search for the app name, e.g., sw_app or swApp in the repo on GitHub to get all occurrences. Note that it might be inside the lib/ directory as well!

  11. On iOS only, for Ad-Hoc deployment, you will need to add the UDID for the mobile device that you wish to test the iOS app with. To find the UDID, you can use XCode/iTunes or the macbook you are connected to (see here). For information about Ad-Hoc testing or testing on any iOS device, see here.