Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 379
gordonturibamwe Avatar asked Mar 27 '20 07:03

gordonturibamwe


People also ask

Can I use flutter with Xcode?

Flutter app can run in Xcode and not in Android Studio.

What is an XCFramework?

What is XCFramework? Apple defines XCFrameworks as a distributable binary package created by Xcode that contains variants of a framework or library so that it can be used on multiple platforms (iOS, macOS, tvOS, and watchOS), including Simulator builds.

Is missing one or more architectures required by this target x86_64?

framework' is missing one or more architectures required by this target: x86_64. This can happen when switching between simulator versions on a Cocoapods project. Cleaning the project should fix the issue. This error occurs when a arm64 iPhoneSimulator slice cannot be found for one of your binary dependencies.


3 Answers

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!

like image 171
Loïc Fonkam Avatar answered Oct 17 '22 08:10

Loïc Fonkam


  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.

like image 26
Jeethu Thomas Avatar answered Oct 17 '22 08:10

Jeethu Thomas


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.

like image 4
Viktor K Avatar answered Oct 17 '22 07:10

Viktor K