Flutter - Building for iOS, but the linked and embedded framework 'App.framework' was built for iOS Simulator

27,511

Solution 1

Xcode 11.4 changed the way frameworks are linked and embedded, and you may experience issues switching between iOS devices and simulators. Flutter v1.15.3 and later will automatically migrate your Xcode project.

To get unstuck, follow the instructions below;

  • Quick fix (make your simulator work)

rm -rf ios/Flutter/App.framework

  • Official recommended Steps to migrate manually

    1. From the Flutter app directory, open ios/Runner.xcworkspace in Xcode.
    2. In the Navigator pane, locate the Flutter group and remove App.framework and Flutter.framework. enter image description here
    3. In the Runner target build settings Build Phases > Link Binary With Libraries confirm App.framework and Flutter.framework are no longer present. Also confirm in Build Phases > Embed Frameworks.

enter image description here

  1. Change the Runner target build settings Build Phases > Thin Binary script as follows:

    /bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed

    /bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" thin

enter image description here

  1. In the Runner target Build Settings > Other Linker Flags

    (OTHER_LDFLAGS) add $(inherited) -framework Flutter

enter image description here

Hope it helps!

Solution 2

  1. Select your Target from "TARGETS"
  2. Select 'Build Settings'
  3. Under 'Build Options' -> Set 'Validate Workspace' To 'YES'
  4. After successfully building, set it back to 'NO'

Reason : "In Xcode 12+, the default option for Validate Workspace is internally not set. We need to set it manually to avoid this kind of error. There is no problem in setting back to the default 'NO' option.

Solution 3

Xcode 11.4 changed the way frameworks are linked and embedded, which is causing issues switching between iOS devices and simulators.

Please follow official guide on how to migrate your project.

Solution 4

Updated to Xcode 11.4. Ios 13.4, Iphone X. App just fetches data using API. App started on white screen and then finally crashes, both on simulator and device.

I followed the offical guide (I also rm -rf ios/Flutter/App.framework) flutter.dev/docs/development/ios-project-migration. I ran several times flutter clean

I also tried deleting Pods/ folder and Podfile.lock, then reinstalling using pod install in the ios folder.

As I am using async data I also added as 1st line in main()

WidgetsFlutterBinding.ensureInitialized();

No help, app did not started either simulator.

Then I removed ios/ and android/ folders. After that in project folder I ran command flutter create . that regenerates mentioned folders.

After this my app started fine both on simulator and on device. I hope this would be help to others. NOTE!! if you have done any modifications manually to those folders please take backup or commit beforehand.

Solution 5

After several days trying to find a solution to test the Flutter app on iOS device, I finally found this:

flutter clean
flutter build ios

-Open xCode and run app on your device.

Share:
27,511
gordonturibamwe
Author by

gordonturibamwe

I design and develop digital products that make a difference.

Updated on January 07, 2021

Comments

  • gordonturibamwe
    gordonturibamwe over 3 years

    After updating to Catalina 10.15.4 beta with Xcode 13.4 beta, which also updated Simulator to 13.4 (921.4).

    The application compiles and runs correctly on a physically attached device, but no simulators of any devices can pass this stage.

    I got the errors

    Building for iOS, but the linked and embedded framework 'App.framework' was built for iOS Simulator.

    or

    Building for iOS Simulator, but the linked and embedded framework 'App.framework' was built for iOS.

    enter image description here

    How can I fix this?

  • Raymond Ativie
    Raymond Ativie about 4 years
    Still doesnt work for me. does the same thing when i try to run the flutter build ios
  • Matt
    Matt about 4 years
    After following the official guide, my app still did not load on my physical device. It was only after following the guide, running flutter clean several times, deleting Pods/ folder and Podfile.lock, then reinstalling using pod install in the ios folder that it finally worked.
  • gordonturibamwe
    gordonturibamwe about 4 years
  • Giedrius Šlikas
    Giedrius Šlikas about 4 years
    Works like charm !
  • Loolooii
    Loolooii about 4 years
    1.15.17 is not on the Stable channel yet.
  • malaki1974
    malaki1974 about 3 years
    worked for Mapbox as well when I migrated to Xcode 12.4
  • Paras Gupta
    Paras Gupta about 3 years
    One thing to notice here in the first step - remove reference
  • Shady Mohamed Sherif
    Shady Mohamed Sherif over 2 years