[Fixed] Target debug_ios_bundle_flutter_assets failed: – Ios

by
Ali Hasan
axios flutter

Quick Fix: In Xcode, under Targets > Build Phases > Run Script, add the following script:

xattr -cr ~/Library/Developer/Xcode/DerivedData || echo Clear

Then rebuild the project.

The Problem:

Having trouble creating an iOS app using Flutter. Getting the error message:

Target debug_ios_bundle_flutter_assets failed: Exception: Failed to codesign /Users/…/App.framework/App with identity -.

Tried deleting the build directory, cleaning the Flutter app, and updating the app pubs, but the issue persists.

The Solutions:

Solution 1: Clear Extended Attributes

When encountering the error "Target debug_ios_bundle_flutter_assets failed: Exception: Failed to codesign […] with identity -.", it indicates an issue with code signing. To resolve this:

  1. Open the Runner project in Xcode.
  2. Navigate to Targets > Build Phases > Run Script.
  3. Add the following command:
xattr -cr ~/Library/Developer/Xcode/DerivedData || echo Clear

This command clears any extended attributes (xattrs) on the Xcode DerivedData folder, which can sometimes interfere with code signing.

  1. Build the project again.

This should resolve the code signing issue and allow you to build the iOS app successfully.

Solution 2: Use flutter_launcher_icons package with updated settings

\n

In the pubspec.yaml file, update the flutter_launcher_icons settings to the following:

<!– begin snippet: js hide: false console: true babel: false –>

<!– language: lang-html –>

flutter_launcher_icons:
  android: &quot;launcher_icon&quot;
  image_path: &quot; &quot; 
  remove_alpha_ios: true

<!– end snippet –>

\n

This will solve the issue related to the removal of alpha channels from the PNG icons.

Solution 3: Check for Same Named Assets with Different Extensions

Delete all assets that share the same name but have different extensions within the assets folder. For instance, if you have "empty_cart.jpeg" and "empty_cart.png" assets, remove one of them to resolve the conflict.

Solution 4: Hide image file extensions

In some cases, the issue can be caused by image files with hidden extensions on macOS. To resolve this, make sure the file extensions for all images are visible. To do this, follow these steps:
1. Open Finder.
2. Select the image file(s) with hidden extensions.
3. Press Command (⌘) + I to open the Get Info window.
4. In the “Name & Extension” section, uncheck the “Hide extension” checkbox.
5. Click “Change” to save the changes.

Solution 5: Embed the Command in Xcode

You can resolve the "Target debug_ios_bundle_flutter_assets failed" error by embedding the following command in Xcode’s "Run Script" build phase:

xattr -cr ~/Library/Developer/Xcode/DerivedData || echo Clear

Steps:

  1. Open your iOS project in Xcode using open ios/Runner.xcworkspace.
  2. Select the "Runner" target.
  3. Go to the "Build Phases" tab.
  4. Click the "+" button and select "New Run Script Phase".
  5. Drag and drop the new phase to the desired location in the build process.
  6. Expand the "Run Script" phase.
  7. Paste the command into the script box.
  8. Set the "Shell" field to "/bin/sh".
  9. Save the project.

This command will clear any extended attributes on the DerivedData directory, which can cause the Xcode build to fail.

Q&A

How to fix the error ‘Target debug_ios_bundle_flutter_assets failed’?

Add the following to a ‘Run Script’ build phase in Xcode: xattr -cr ~/Library/Developer/Xcode/DerivedData || echo Clear

Flutter_launcher_icons error

In flutter_launcher_icons, leave the alpha flag and use setting in pubspec: remove_alpha_ios: true

iOS app compile error

Delete assets with same names but different extensions

Video Explanation:

The following video, titled "”[SOLVED", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

This video provides further insights and detailed explanations related to the content discussed in the article.

error (xcode): target debug_unpack_ios failed:exception …” description=”[SOLVED] error (xcode): target debug_unpack_ios failed:exception: failed to codesign | Flutter | IOS … [Fixed] Error (Xcode): File not found: / …”]