This application cannot tree shake icons fonts

15,680

Solution 1

Try build with --no-tree-shake-icons command.

Solution 2

Add a "const" before the IconData.

Icon(
  const IconData(
    0xe911,
    fontFamily: 'icomoon',
  ),
  color: Colors.black,
),

Solution 3

For flutter you can export apk with this

flutter build apk --split-per-abi --no-tree-shake-icons
Share:
15,680

Related videos on Youtube

iven
Author by

iven

Updated on June 03, 2022

Comments

  • iven
    iven almost 2 years

    While trying to build my app in release mode I encountered the following the compiler error:
    "This application cannot tree shake icons fonts."

    terminal logs:

    flutter build ios --release  
    Building com.xxx.xxx for device (ios-release)...
    Automatically signing iOS for device deployment using specified development team in Xcode project: C7T4CHU88Y
    Running Xcode build...                                                  
                                                       
    Xcode build done.                                           31.8s
    Failed to build iOS app
    Error output from Xcode build:
    ↳
        ** BUILD FAILED **
    
    
    Xcode's output:
    ↳
        This application cannot tree shake icons fonts. It has non-constant instances of IconData at the following locations:
          - file:///Users/user-app/lib/screens/categories/subcategories.dart:830:35
          - file:///Users/user-app/lib/screens/home/home.dart:387:17
          - file:///Users/user-app/lib/screens/home/home.dart:399:17
          - file:///Users/user-app/lib/screens/home/home.dart:411:17
          - file:///Users/user-app/lib/screens/home/home.dart:423:17
          - file:///Users/user-app/lib/screens/product/all_products.dart:516:31
          - file:///Users/user-app/lib/screens/tab/saveditems.dart:324:31
          - file:///Users/user-app/lib/screens/tab/searchitem.dart:496:31
    

    The error could result from the following file:

    Column(
      children: <Widget>[
        Row(
          children: <Widget>[
            new Text(
              MyLocalizations.of(context).goToCart,
              style: textBarlowRegularBlack(),
            ),
            SizedBox(width: 4),
            Icon(
              IconData(
                0xe911,
                fontFamily: 'icomoon',
              ),
              color: Colors.black,
            ),
          ],
        ),
      ],
    ),
    
  • Nick Wright
    Nick Wright over 3 years
    Can someone tell me where I can set this in Xcode please? Thanks.
  • U.Savas
    U.Savas over 3 years
    for further explanation about this please refer to github.com/Ahmadre/FlutterIconPicker/issues/…
  • Shalabyer
    Shalabyer over 3 years
    @NickWright flutter build ios --no-tree-shake-icons in terminal
  • ajnabz
    ajnabz about 3 years
    @anson when I do this, none of the material icons I have used show up - do you know why this could be?
  • MJ Montes
    MJ Montes about 3 years
    added this one in Codemagic build arguments and works. :D