AmolGangadhare / flutter_barcode_scanner

Barcode scanner plugin for flutter. Supports barcode scanning for Android and iOS
https://pub.dev/packages/flutter_barcode_scanner
MIT License
379 stars 451 forks source link

'flutter_barcode_scanner/flutter_barcode_scanner-Swift.h' file not found?? #28

Open ly918 opened 5 years ago

ly918 commented 5 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

AmolGangadhare commented 5 years ago

Thanks for reporting the issue. Have you followed the Readme section to use the plugin? Can you add some error logs?

Viktoorrocha commented 5 years ago

I also had the same problem. I still couldn't solve it. I followed all the documentation steps

AmolGangadhare commented 5 years ago

@Viktoorrocha this error mainly occurs when the iOS part isn't created in swift. By default flutter creates iOS code in objective c. This plugin is written in swift so it requires iOS project to be created in swift. Some possible reasons are due to plugin not linked correctly, which can be resolved by flutter clean and reinstalling app.

huanglong6828 commented 5 years ago

I also have the same problem

AmolGangadhare commented 5 years ago

@huanglong6828 Thanks for using the plugin. Just to confirm that, is your iOS part is created in Swift? Or is it in Objective C?

huanglong6828 commented 5 years ago

@AmolGangadhare Thanks Reply I created the project according to Flutter's process. It was changed to 10 in the Runner. The swift version setting was not found in Xcode. The version in the terminal is version 5.

image image

AmolGangadhare commented 5 years ago

@huanglong6828 By default flutter creates Android part in Java and iOS part in Objective C. For iOS, the plugin is written in Swift so it requires iOS project in swift. Please create a new project with Swift support to iOS or just follow steps provided in README.

Please acknowledge the issue if it is solved or not

huanglong6828 commented 5 years ago

@AmolGangadhare Thanks, I am trying to convert to Swift.

huanglong6828 commented 5 years ago

@AmolGangadhare Thank you for providing such a great plugin that you can use successfully.

AmolGangadhare commented 5 years ago

@huanglong6828 Great. Did you face any other issues while using the plugin?

huanglong6828 commented 5 years ago

@AmolGangadhare No other questions

Viktoorrocha commented 5 years ago

I also have the same problem

@Viktoorrocha this error mainly occurs when the iOS part isn't created in swift. By default flutter creates iOS code in objective c. This plugin is written in swift so it requires iOS project to be created in swift. Some possible reasons are due to plugin not linked correctly, which can be resolved by flutter clean and reinstalling app.

I tried your solution. And he returned me:

Launching lib/main.dart on iPhone 7 in debug mode... Expected ios/Runner.xcodeproj but this file is missing. No application found for TargetPlatform.ios. Is your project missing an ios/Runner/Info.plist? Consider running "flutter create ." to create one.

oengmengthong commented 5 years ago

'flutter_barcode_scanner/flutter_barcode_scanner-Swift.h' file not found

it still error

AmolGangadhare commented 5 years ago

By default, flutter creates Android part in Java and iOS part in Objective C. For iOS, the plugin is written in Swift so it requires iOS project in swift. Please create a new project with Swift support to iOS or just follow steps provided in README.

markqq commented 5 years ago
  1. Open Runner.xcodeproj with Xcode;
  2. Right-click on Runner in the Project Navigator on the left, and click New File;
  3. Create a single empty Swift file to the project;
  4. When Xcode asks, press Create Bridging Header and do not remove Swift file then;
  5. Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import <flutter_barcode_scanner-Swift.h>;
  6. Re-run.
ghost commented 5 years ago
  1. Open Runner.xcodeproj with Xcode;
  2. Right-click on Runner in the Project Navigator on the left, and click New File;
  3. Create a single empty Swift file to the project;
  4. When Xcode asks, press Create Bridging Header and do not remove Swift file then;
  5. Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import <flutter_barcode_scanner-Swift.h>;
  6. Re-run.

Sorry, but can you explain from the step 5? what happen after we create new swift file? copy paste .m file? i dont understand

riccardogl commented 5 years ago

I just got it working fine. For newbie that do not understand the docs/README, follow this step:

  1. Go to your flutter project and delete the ios folder
  2. Then run flutter flutter create -i swift .
  3. Then you just re run your project.
z234009184 commented 4 years ago
  1. Runner.xcodeproj用Xcode 打开;
  2. Runner在左侧的Project Navigator中右键单击,然后单击New File;
  3. 为项目创建一个空的Swift文件;
  4. 当Xcode问,按,然后Create Bridging Header不删除Swift文件;
  5. 编辑.m文件,替换#import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h>#import <flutter_barcode_scanner-Swift.h>;
  6. 重新运行。

Good job, It's work!

Viktoorrocha commented 4 years ago

I updated lib but I still get the same error: BUILD FAILED

Xcode's output: ↳ === BUILD TARGET sqflite OF PROJECT Pods WITH CONFIGURATION Debug === /Users/sescti/.pub-cache/hosted/pub.dartlang.org/flutter_barcode_scanner-0.1.7/ios/Classes/FlutterBarcodeScannerPlugin.m:2:9: fatal error: 'flutter_barcode_scanner/flutter_barcode_scanner-Swift.h' file not found

import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h>

        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:35:11: warning: variable 'originRect' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
      if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:43:26: note: uninitialized use occurs here
                atSource:originRect];
                         ^~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:35:7: note: remove the 'if' if its condition is always true
      if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:35:11: warning: variable 'originRect' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
      if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:43:26: note: uninitialized use occurs here
                atSource:originRect];
                         ^~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:35:11: note: remove the '&&' if its condition is always true
      if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:35:11: warning: variable 'originRect' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
      if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:43:26: note: uninitialized use occurs here
                atSource:originRect];
                         ^~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:35:11: note: remove the '&&' if its condition is always true
      if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:35:11: warning: variable 'originRect' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
      if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
          ^~~~~~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:43:26: note: uninitialized use occurs here
                atSource:originRect];
                         ^~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:35:11: note: remove the '&&' if its condition is always true
      if (originX != nil && originY != nil && originWidth != nil && originHeight != nil) {
          ^~~~~~~~~~~~~~~~~
/Users/sescti/.pub-cache/hosted/pub.dartlang.org/share-0.6.2+1/ios/Classes/SharePlugin.m:34:7: note: variable 'originRect' is declared here
      CGRect originRect;
      ^
4 warnings generated.

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

AmolGangadhare commented 4 years ago

Try pod install the plugin might not have downloaded. Then open project using .xcworkspace

umaqs commented 4 years ago

Facing the same issue. I am using Swift for my iOS part by default

alexbhandari commented 4 years ago

I just got it working fine. For newbie that do not understand the docs/README, follow this step:

  1. Go to your flutter project and delete the ios folder
  2. Then run flutter flutter create -i swift .
  3. Then you just re run your project.

this was the only comment that worked for me

igorantolic commented 4 years ago
  1. Open Runner.xcodeproj with Xcode;
  2. Right-click on Runner in the Project Navigator on the left, and click New File;
  3. Create a single empty Swift file to the project;
  4. When Xcode asks, press Create Bridging Header and do not remove Swift file then;
  5. Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import <flutter_barcode_scanner-Swift.h>;
  6. Re-run.

Just STEP 5 was sufficient for me!

Xgamefactory commented 4 years ago

same issue. was working perfectly after upgrade. such annoying erors different on vscode run part and xcode run part.

daveparks23 commented 4 years ago
  1. Open Runner.xcodeproj with Xcode;
  2. Right-click on Runner in the Project Navigator on the left, and click New File;
  3. Create a single empty Swift file to the project;
  4. When Xcode asks, press Create Bridging Header and do not remove Swift file then;
  5. Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import <flutter_barcode_scanner-Swift.h>;
  6. Re-run. @markqq
  7. What do I name the empty file?
  8. Xcode never asks me.
  9. How do I replace something I never keyed in? Can you explain more? Thanks.
rodrigofbm commented 4 years ago
  1. Open Runner.xcodeproj with Xcode;
  2. Right-click on Runner in the Project Navigator on the left, and click New File;
  3. Create a single empty Swift file to the project;
  4. When Xcode asks, press Create Bridging Header and do not remove Swift file then;
  5. Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import <flutter_barcode_scanner-Swift.h>;
  6. Re-run. @markqq
  1. What do I name the empty file?
  2. Xcode never asks me.
  3. How do I replace something I never keyed in? Can you explain more? Thanks.

Did you make it work? Nothing helped me and looks like this issue will stay for a long time...

paulewetzel commented 4 years ago

Having the same issue, and not able to resolve so far with these solutions.

rodrigofbm commented 4 years ago

I think the solution it's to use other packege.

daveparks23 commented 4 years ago

@paulewetzel I went with @rodrigofbm's idea. I am using barcode_scan.

Xgamefactory commented 4 years ago

same h

@paulewetzel I went with @rodrigofbm's idea. I am using barcode_scan.

same here. maintened plugin is very importan.

paulewetzel commented 4 years ago

Me too.

On Sat, May 16, 2020 at 6:25 PM Xgamefactory notifications@github.com wrote:

same h

@paulewetzel https://github.com/paulewetzel I went with @rodrigofbm https://github.com/rodrigofbm's idea. I am using barcode_scan.

same here. maintened plugin is very importan.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AmolGangadhare/flutter_barcode_scanner/issues/28#issuecomment-629728811, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG26KZFB6STLQLKSBQ4BNLRR44JZANCNFSM4IKGVYBQ .

Harshdeep4295 commented 4 years ago

I have one query here... As we are building or run the app, we can change the header easily but how to make changes when there is CI/CD pipeline in case of building and deploying a flutter project.

funder7 commented 3 years ago

When building from XCode:

<unknown>:0: error: module map file '/my-app-folder/build/ios/Debug-iphonesimulator/flutter_barcode_scanner/flutter_barcode_scanner.modulemap' not found

Plenty of these errors. Maybe the plugin has been exported with this modulemap file missing? Just asking, I don't know how to create flutter libs.

balenaultra commented 2 years ago

Same error here. Already recreate the project as swift, done steps on the read me, no success. Anyone can help?

rifat-22 commented 2 years ago

Still facing the error. How to resolve? Anyone solved yet?

Harshdeep4295 commented 2 years ago

Hi @rifat-22 , Which issue you are referring to here.

rifat-22 commented 2 years ago

Hello @Harshdeep4295, this issue fatal error: 'flutter_barcode_scanner/flutter_barcode_scanner-Swift.h' file not found

Harshdeep4295 commented 2 years ago

HI @rifat-22 , there is this manual solution for now, which I was able to work with. It is https://github.com/AmolGangadhare/flutter_barcode_scanner/issues/28#issuecomment-595749195 this one only. Try this, hope this will work.

rifat-22 commented 2 years ago

Hi @Harshdeep4295 thanks for your response and I have these https://github.com/AmolGangadhare/flutter_barcode_scanner/issues/28#issuecomment-624425666 quires, can you help ?

Harshdeep4295 commented 2 years ago

Hi @rifat-22 , Have you tried using below

Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import ;

if you can see this pod project, just try importing flutter_barcode_scanner.h or flutter_barcode_scanner-Swift.h directly..

rifat-22 commented 2 years ago

Hello @Harshdeep4295 , I have edited the .m file then I am facing this error image

jarrett-m commented 2 years ago

It should be noted that you need to open your project via the ios/Runner.xcworkspace and NOT the ios/Runner.xcodeproj, I was having this issue and it was because I was running the xcodeproj and not the xcworksapce...

sahooz commented 2 years ago
  1. Open Runner.xcodeproj with Xcode;
  2. Right-click on Runner in the Project Navigator on the left, and click New File;
  3. Create a single empty Swift file to the project;
  4. When Xcode asks, press Create Bridging Header and do not remove Swift file then;
  5. Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import <flutter_barcode_scanner-Swift.h>;
  6. Re-run.

It works for me

shobith10 commented 1 year ago
  1. Open Runner.xcodeproj with Xcode;
  2. Right-click on Runner in the Project Navigator on the left, and click New File;
  3. Create a single empty Swift file to the project;
  4. When Xcode asks, press Create Bridging Header and do not remove Swift file then;
  5. Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import <flutter_barcode_scanner-Swift.h>;
  6. Re-run.

It works for me

for one project it worked perfectly and for another project its not working

lydia-lau commented 1 year ago
  • Open Runner.xcodeproj with Xcode;
  • Right-click on Runner in the Project Navigator on the left, and click New File;
  • Create a single empty Swift file to the project;
  • When Xcode asks, press Create Bridging Header and do not remove Swift file then;
  • Edit .m file, replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import <flutter_barcode_scanner-Swift.h>;
  • Re-run.

This works for me. I just need to do step 5. Thumbs up.

vinay-jaiswal-g10x commented 11 months ago

replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import

open xcode and check and replace this import line, its worked for me.

PillarChen commented 8 months ago

replace #import <flutter_barcode_scanner/flutter_barcode_scanner-Swift.h> with #import

open xcode and check and replace this import line, its worked for m