One would think it would be straightforward to install an iOS app you built yourself to your own iPhone. And yet...it took this lifesaver of a StackOverflow post to help me figure this out.

iOS

Preparation

Follow instructions on reviewing Xcode project settings.

Build

First, build the app.

flutter build ipa

Distribution

With an Apple Developer Account

Then open the "Devices and Simulators" window in Xcode.

open build/ios/archive/Runner.xcarchive

In Archives -> select the latest created archive. Then click "Validate app". If you see any errors about "CONTRACT_STATE" or what not, you gotta go to App Store Connect - Agreements, then try to validate again.

Once complete, click on Distribute App -> Ad Hoc. Follow the prompts. In Distrubution manifest information, set the Name and URLs to your own app's. Export to a folder somewhere.

This will generate a folder with an .ipa file and some Plist files.

Without an Apple Developer Account

You do not need to shell out $99/year if you just want to test apps on your own device. To do this, open PROJECT_DIR/build/ and find the *.ipa , which you can install.

Install on device

Connect iPhone to Mac.

Open Finder, then select Locations -> iPhone.

In another Finder window, open the folder where the ipa was exported. Drag the ipa to the iPhone window. The storage bar will turn into a progress bar.

Linux

Build

This will create build/linux/x64/release/bundle in your project directory:

flutter build linux --release -v  # Run verbose mode

[!NOTE] This process took awhile, so I highly recommend passing the --verbose/-v flag to see the progress.

Distribution

AppImage

Then build an AppImage with appimage-builder which is a utility that will create an AppImage from your Flutter Linux app.

Download appimage-builder

To setup:

chmod +x appimage-builder-x86_64.AppImage

mkdir ~/Applications/
mv appimage-builder-x86_64.AppImage ~/Applications/appimage-builder

[!NOTE] Running appimage-builder --generate didn't work for me, so I just copied an example AppImageBuilder.yml.

Then, in your project directory, download the AppImageBuilder.yml example from here and place in your project folder.

Copy the project build files to an AppDir:

cp -r build/linux/x64/release/bundle $PWD/AppDir

Finally, run appimage-builder to create the AppImage:

appimage-builder --recipe AppImageBuilder.yml --skip-test

macOS

Prepare for Distribution

With Apple Developer Account

First, make sure you have a Developer ID certificate set up.

Open up the Xcode workspace:

open macos/Runner.xcworkspace

Then go to Xcode -> Settings -> Accounts. Add your Apple ID if it isn't already there. Then click on "Manage Certificates".

Click the + button and select Developer ID Application to generate the certificate.

Back in the Xcode workspace, click on "Runner" on the left sidebar, then in the inner window under TARGETS, select Runner.

In the tabs above that screen, click on Signing & Certificates. Uncheck "Automatically manage signing" and set Team to your Apple ID that's associated with your Apple Developer Account. under Signing Certificate, select "Developer ID Application"

Notarization

In order to properly distribute your app, you have to modify the Signing & Capabilities settings. See Common Notarization Issues

Notarizing

https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution#3087730

Without an Apple Developer Account

Then open Runner.xcworkspace:

open macos/Runner.xcworkspace

Click on Product -> Archive.

In the Archives window, select a build, then click Distribute App. Select Copy App, then select a location to export the app. This will produce a folder Runner 2023-02-05 14-11-58 inside which the *.app will be created.

Build app

flutter build macos

With Apple Developer Account

Verify codesigning:

codesign -vvv --deep --strict build/macos/Build/Products/Release/diarist.app/
spctl -vvv --assess --type exec build/macos/Build/Products/Release/diarist.app
codesign -dvv build/macos/Build/Products/Release/diarist.app

Open Xcode -> Product -> Archive.

Xcode -> Window -> Organizer.

select the most recent archive. click Distribute App. Follow prompts, this will upload your app to Apple notarization, which should complete in less than an hour.

Create a dmg

Install appdmg:

npm install -g appdmg

Create a config file:

mkdir -p PROJECT_DIR/assets/
touch PROJECT_DIR/assets/app.json

And paste:

{
  "title": "MyApp",
  "contents": [
    { "x": 448, "y": 344, "type": "link", "path": "/Applications" },
    { "x": 192, "y": 344, "type": "file", "path": "../build/macos/Build/Products/Release/myapp.app/" }
  ]
}

Then run:

appdmg assets/app.json MyApp.dmg

This will put the macos build in the DMG.

Troubleshooting

Cocoapods not found

Standalone flutter

This refers to the mainline release.

Whenever macOS updates to a new version you will have to uninstall cocoapods if installed through gem:

sudo gem uninstall cocoapods cocoapods-core

Then install with brew:

brew install cocoapods

If any issues arise regarding the brew link step:

brew link --overwrite cocoapods
brew reinstall cocoapods

flutter doctor

source: StackOverflow post

With fvm

Running fvm flutter doctor will sometimes lead to cocoapods not being found even if it's installed. This appears to be a bug.

So in order to account for this, we can set an alias in .zprofile/.bash_profile/.zshrc:

alias f=".fvm/flutter_sdk/bin/flutter"`

Then restart shell.

exec $SHELL

Check if flutter doctor finds any issues:

f doctor

Information

updated5th Feb 2023

created28th Feb 2022

stageseedling