---
title: "Code Push for iOS add-to-app"
description: "Use Code Push in an add-to-app scenario with an iOS app"
---

This guide explains how to use Shorebird in an iOS add-to-app scenario (that is, your app embeds Flutter UI in non-Flutter UI). If you are new to this pattern, see the [Add Flutter to an existing app](/flutter-concepts/add-to-app/) Flutter Concepts article first.

Note

If your app is a pure Flutter app, follow the [standard Code Push guide](/code-push/initialize) instead.

## Prerequisites

[Section titled “Prerequisites”](#prerequisites)

This guide assumes you have already have an iOS app and a Flutter module. The example iOS app will be named `IosCodePushDemo` and the example Flutter module will be named `flutter_module`.

This guide also assumes that you have created a Shorebird account. If you have not created a Shorebird account, please see the [Code Push guide](/code-push/initialize) for instructions.

The reference code for this guide is available at <https://github.com/shorebirdtech/samples/tree/main/add_to_app>.

Note

Shorebird only supports the iOS Framework embedding method of adding Flutter to a native iOS app (see “Use iOS frameworks” in the [official integration docs](https://docs.flutter.dev/add-to-app/ios/project-setup)). There is an open issue to support embedding via CocoaPods ([link](https://github.com/shorebirdtech/shorebird/issues/1198)), but given that [Flutter plans to deprecate CocoaPods support](https://github.com/flutter/flutter/issues/168015), it is unlikely that this will be implemented.

## Add Shorebird to your Flutter module

[Section titled “Add Shorebird to your Flutter module”](#add-shorebird-to-your-flutter-module)

First, run `shorebird init` in your Flutter module:

```
shorebird init
```

## Create a Shorebird release

[Section titled “Create a Shorebird release”](#create-a-shorebird-release)

First, package the Flutter module for release. This will produce an `.xcframework` that can be embedded in your iOS app and provides Shorebird with the information it needs to apply patches.

To create a release, run the following the root directory of your Flutter module:

```
shorebird release ios-framework --release-version 1.2.3+4
```

The `release-version` parameter needs to match the version of the iOS app that uses this module (i.e., `version+build` from the Xcode settings, or `CFBundleShortVersionString+CFBundleVersion` from your app’s Info.plist).

![Xcode build version](/_astro/hybrid_ios_build_version.CLljq76e_thYgj.webp)

*The version number for this app would be 1.2.3+4*

The `ShorebirdFlutter.xcframework` and `App.xcframework` artifacts produced by the `shorebird release` command will be placed in the `release` directory in the root of your Flutter module.

Note

Because Shorebird only works with release builds, this will only produce a release version of your archive. This is similar to running `flutter build ios-framework --no-debug --no-profile`.

## Embed the Flutter module in your iOS app

[Section titled “Embed the Flutter module in your iOS app”](#embed-the-flutter-module-in-your-ios-app)

While there are multiple ways to embed a Flutter module in an iOS app, Shorebird requires that your Flutter module be embedded in your iOS app as an .xcframework.

Note

The steps to do this are the same as the [option B in the official instructions](https://docs.flutter.dev/add-to-app/ios/project-setup#option-b---embed-frameworks-in-xcode), so in the event of a conflict between the docs here and the official docs, defer to the official docs.

Note

`ShorebirdFlutter.xcframework` is nearly identically to `Flutter.xcframework` from Google, but as part of compliance with Apple’s signing requirements, the framework has been renamed when applying Shorebird’s (legally Code Town, Inc’s) digital signature.

### Add the path to your .xcframeworks to Framework Search Paths

[Section titled “Add the path to your .xcframeworks to Framework Search Paths”](#add-the-path-to-your-xcframeworks-to-framework-search-paths)

In Xcode:

1. Navigate to your app target’s “Build Settings” tab.
2. Find the “Framework Search Paths” setting (the Filter field on the top right of the build settings tab is helpful for this).
3. Add an entry to the “Framework Search Paths” list. This entry should be the relative path to the directory containing `ShorebirdFlutter.xcframework` and `App.xcframework` artifacts. By default, these artifacts are placed in the `release` directory in the root of your Flutter module, but you should feel free to move them elsewhere if you prefer.

![Xcode framework search paths](/_astro/hybrid_ios_framework_search_paths.D8dALScx_2vl85C.webp)

### Embed App.xcframework and Flutter.xcframework in your app

[Section titled “Embed App.xcframework and Flutter.xcframework in your app”](#embed-appxcframework-and-flutterxcframework-in-your-app)

In the “General” tab of your app target, add `App.xcframework` and `ShorebirdFlutter.xcframework` from to the “Frameworks, Libraries, and Embedded Content” section. Make sure to select “Embed & Sign” for both frameworks.

![Xcode embed frameworks](/_astro/hybrid_ios_embed_frameworks.Ck1H8aSI_Z7DL6W.webp)

Note

You may also see that `ShorebirdFlutter.xcframework` is signed by Code Town Inc. That’s the Shorebird team 🙂

## Verify that your app runs

[Section titled “Verify that your app runs”](#verify-that-your-app-runs)

In Xcode, update the current scheme’s build configuration to “Release”

![Xcode edit schemes](/_astro/hybrid_ios_edit_schemes.CnGS09JC_ZwcyOE.webp) ![Xcode release scheme](/_astro/hybrid_ios_release_scheme.DBc7Z2UN_1ncL2V.webp)

Now run your app on a device (*not* a simulator). Your app should run as normal, and you should see debug logs from Shorebird.

## Submit your app to the App Store

[Section titled “Submit your app to the App Store”](#submit-your-app-to-the-app-store)

This step isn’t covered in detail here, but this is where you would submit your app to the App Store. For Code Push to work, it is important that you submit *with the same `xcframework` generated by the release command above*.

You can skip this step if you just want to see Code Push working in an app.

## Verify that Shorebird is working with a patch

[Section titled “Verify that Shorebird is working with a patch”](#verify-that-shorebird-is-working-with-a-patch)

Make a user-visible change to the code in your Flutter module. Then run:

```
shorebird patch ios-framework --release-version 1.2.3+4
```

`release-version` should be the version of the iOS app you released with the output of the `release` command. As before, this should match your app’s version and build numbers in Xcode. The command above will patch the release created earlier in this guide.

You can now test the patch in your app by running the app from Xcode. After the app launches, you should see a logs from Shorebird informing you that the app is checking for new patches and saying that the patch was installed:

```
Sending patch check request: PatchCheckRequest { app_id: "db32f785-284a-429b-9348-d3ead3485438", channel: "stable", release_version: "1.2.3+4", patch_number: None, platform: "ios", arch: "aarch64" }

/// other logs

Patch 1 successfully installed.
```

For the app to reflect the changes, you will need to close and reopen the app. Do this by stopping the app in Xcode and then running it again.
