Target debug_ios_bundle_flutter_assets failed:
Asked Answered
E

15

6

Having trouble creating IOS app using flutter. can any one help how i can solve this issue??

Launching lib/main.dart on iPhone 14 Pro in debug mode... Running Xcode build... Xcode build done. 7.7s Failed to build iOS app Error (Xcode): Target debug_ios_bundle_flutter_assets failed: Exception: Failed to codesign /Users/vijaidwivedi/Projects/users/build/ios/Debug-iphonesimulator/App.framework/App with identity -.

Could not build the application for the simulator. Error launching application on iPhone 14 Pro.

Tried deleting the build directory cleaning the flutter app updating the app pubs

but no avail.

Ejector answered 31/5, 2023 at 14:4 Comment(0)
T
0

I was facing the same issue. I've solved that by deleting assets with the different type of extensions. For me, it was chat_icon.textClipping Then clean build folder and run the app again. Helped tom hikari's answer to solve this problem.

Thimblerig answered 2/4 at 3:43 Comment(1)
yes, I opened each image from assets and exported to jpg/png replacing original image, and it worked. Thanks for guidingEjector
G
4

Open Runner in Xcode then Go to Targets > Build Phases > Run Script: Add the following

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

Then build the project.

Geek answered 24/7, 2023 at 8:17 Comment(0)
P
2

I also encountered this issue while adding an extra PNG image to my assets folder. I tried everything from flutter clean; flutter pub get; pod install, to completely remaking the Podfile. None of that worked! In the end I analyzed the image and found that I had to remove all useless metadata. I modified the image using Photoshop and as such, it added a bunch of extra metadata to that the image including XML data which was the culprit in my situation. Hope this helps for some people!

Past answered 26/6 at 9:33 Comment(1)
Me too!!! The png format was the problem. Thanks!!!Echeverria
T
1

have the same error as you

this error came after i install flutter_launcher_icons and gen the icon .png with alpha removal from the image

in this newer lib version you can leave the alpha flag and use setting in pubspec

flutter_launcher_icons:
  android: "launcher_icon"
  image_path: " " 
  remove_alpha_ios: true

and regen everything and it's solve my problem

Taro answered 12/6, 2023 at 3:23 Comment(1)
I know this probably won't be the solution for many, but it was for me. In case anyone is using flutter_launcher_icons (the new version of flutter_icons), try this as well.Carmoncarmona
G
1

I was facing the same problem, the error message is not very clear. I've solved that by deleting assets with the same names but different extensions. For me, it was empty_cart.jpeg and empty_cart.png.

Guaranty answered 8/9, 2023 at 17:34 Comment(0)
P
0

It was an image name that prevented me from compiling my project.

After elimination it was only an image with the option on Mac to "hide the extension" (⌘+i on the file in Finder)

Pozzuoli answered 21/9, 2023 at 9:50 Comment(0)
F
0

You can add the command

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

to a "Run Script" build phase in Xcode by following these steps:

  1. Open your Flutter project in a terminal or command prompt.
  2. Run the following command to open your iOS project in Xcode:

open ios/Runner.xcworkspace

This command will open Xcode with your Flutter iOS project.

  1. In Xcode, locate and select the "Runner" target in the Project Navigator on the left side of the window. It's usually listed under the "Workspace" or "Project" section.

  2. In the main Xcode window, select the "Runner" target.

  3. Click on the "Build Phases" tab at the top of the Xcode window.

  4. In the "Build Phases" section, you will see a list of build phases. To add a new "Run Script" build phase, click the "+" button at the top left of the "Build Phases" section and select "New Run Script Phase."

  5. A new "Run Script" build phase will be added to your project. You can drag and drop it to the appropriate location in the build process if needed.

  6. Click on the disclosure triangle next to the "Run Script" phase to expand it.

  7. In the "Run Script" section, you can paste the following command into the script box:

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

Make sure that the "Shell" field is set to

/bin/sh.

  1. Save your Xcode project.

Finally, build your project by clicking the "Build" button in Xcode or the play button

Fence answered 24/10, 2023 at 23:17 Comment(1)
This just allows Xcode to ignore the error and continue to install. However, the installation will fail since the asset package was not code signed. So it did not work for me.Indecisive
C
0

I was facing the same problem. To solve this issue make sure that you don't have more than one /assets endpoints and in assets you don't have any image with same name and different format.

Conceptualize answered 7/3 at 12:50 Comment(0)
B
0

I was facing same issue. While googling, i came to this post. Looking upvotes, i tried the solution provided by @Mathew. Still same error msg came. Again, i started viewing other comments. @fingerup's comment remind me of something. I had added a screenshot image file only named as "connect" within assets directory which was saved automatically as png file. Then i renamed the file as "connect-vendor.png" explicitly. Later the error was gone and build was successful.

Then i tried removing script that i added following @Mathew and rebuild the project. Still build was successful. So, in my case, the cause of issue was naming of png image file within assets directory.

Barbule answered 28/3 at 9:35 Comment(0)
T
0

I was facing the same issue. I've solved that by deleting assets with the different type of extensions. For me, it was chat_icon.textClipping Then clean build folder and run the app again. Helped tom hikari's answer to solve this problem.

Thimblerig answered 2/4 at 3:43 Comment(1)
yes, I opened each image from assets and exported to jpg/png replacing original image, and it worked. Thanks for guidingEjector
T
0

I faced this issue after adding a new png image to the project. It was because the new image was a 16 bit image. I replaced it with 8 bit image and it worked.

So this was not working:

  pixelWidth: 48
  pixelHeight: 48
  typeIdentifier: public.png
  format: png
  formatOptions: default
  dpiWidth: 192.000
  dpiHeight: 192.000
  samplesPerPixel: 4
  bitsPerSample: 16   <----------
  hasAlpha: yes
  space: RGB 

And this was working:

  pixelWidth: 48
  pixelHeight: 48
  typeIdentifier: public.png
  format: png
  formatOptions: default
  dpiWidth: 72.000
  dpiHeight: 72.000
  samplesPerPixel: 4
  bitsPerSample: 8   <----------
  hasAlpha: yes
  space: RGB
  profile: sRGB IEC61966-2.1 
Tracay answered 14/5 at 6:12 Comment(0)
S
0

So nothing above worked for me! However, after 3 hours back and forth, I found the issue I was having. In my /assets folder I had images / files without correct ending. I had JPEG and PNG images where the file name did not end in .jpeg or .png. After adding this, it's resolved.

Sticker answered 20/6 at 10:20 Comment(0)
M
0

Solution 1:

Apple Developer Website Answers above problem Here.

Execute below command in terminal : First goto projects root folder

 xattr -cr <path_to_project_dir>

Clean Xcode and Re-build.

Solution 2:

Just go to project root directory and run this command xattr -cr .

xattr -cr .

Clean Xcode and Re-build.

this work for me which i got reference from this answer link.

Mohun answered 4/7 at 6:24 Comment(0)
T
0

For me I wasted more that 36 hours trying to figure out what was the problem. Finally after doing everything on the internet and after revoking all the certificates, uninstalling xcode and all its files. Nothing solved the issue.

After reading the answers I tried to cut all the files in my assets folder and run the code which was running successfully, so the issue was one of the .svg files and I fixed it by editing its content Hope this solves someones issue :)

Tergal answered 19/8 at 20:23 Comment(0)
D
0

I've just run into the same problem. None of the above solutions worked, but they led me in the right direction. For me, the error was caused by some assets that had extended file attributes.

You can spot these files by running ls -la in your terminal. If a file has extended attributes, you'll see an '@' after the permissions, like this:

-rw-rw-rw-@ 1 pm staff 3406 Mar 13 2015 car_off.png

You can use xattr -c [filename] to remove extended attributes.

After I removed the extended attributes, code signing worked again.

Disperse answered 16/10 at 8:0 Comment(0)
T
-1

write this command on terminal flutter cleanif you add dependency you must add it again and run project

Talcahuano answered 29/12, 2023 at 9:15 Comment(1)
I edit my massage bro let's do it it fully workingTalcahuano

© 2022 - 2024 — McMap. All rights reserved.