kakzaki / blue_thermal_printer

Working with thermal printer via bluetooth (Flutter)
MIT License
164 stars 205 forks source link

Error with MacOS while building #154

Closed A7MeDG0L0L closed 1 year ago

A7MeDG0L0L commented 2 years ago

flutter/.pub-cache/hosted/pub.dartlang.org/blue_thermal_printer-1.2.2/macos/Classes/SwiftBlueThermalPrinterPlugin.swift:9:17: error: cannot find 'Music' in scope let music = Music(messenger: registrar.messenger, registrar: registrar) ^~~~~

utpalruparel commented 2 years ago

'FlutterBinaryMessenger' let channel = FlutterMethodChannel(name: "blue_thermal_printer", binaryMessenger: registrar.messenger()) ^ ~~ 1.2.3/macos/Classes/SwiftBlueThermalPrinterPlugin.swift:14:21: error: cannot find 'UIDevice' in scope result("iOS " + UIDevice.current.systemVersion) ^~~~ BUILD FAILED

A7MeDG0L0L commented 2 years ago

After Update to 1.2.3

Launching lib/main.dart on macOS in debug mode...
Building macOS application...
../blue_thermal_printer-1.2.3/macos/Classes/BlueThermalPrinterPlugin.m:6:4: error: unknown receiver 'SwiftBlueThermalPrinterPlugin'; did you mean 'BlueThermalPrinterPlugin'?
  [SwiftBlueThermalPrinterPlugin registerWithRegistrar:registrar];
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   BlueThermalPrinterPlugin
In file included from ../blue_thermal_printer-1.2.3/macos/Classes/BlueThermalPrinterPlugin.m:1:
@interface BlueThermalPrinterPlugin : NSObject<FlutterPlugin>
           ^
1 error generated.
** BUILD FAILED **

Exception: Build process failed
flutter-painter commented 1 year ago

Hi @A7MeDG0L0L,

I added those files to be able to build app on macos, I have no exeprience in making a flutter package for macos so i trimmed files found in just audio package to trick pod ; hence the AssetsAudioPlayer reference in .swift file

This works on my mac, What error do you get if you try to build macos version of blue_thermal_printer/example ?

A7MeDG0L0L commented 1 year ago

Hi @A7MeDG0L0L,

I added those files to be able to build app on macos, I have no exeprience in making a flutter package for macos so i trimmed files found in just audio package to trick pod ; hence the AssetsAudioPlayer reference in .swift file

This works on my mac, What error do you get if you try to build macos version of blue_thermal_printer/example ?

Hi @flutter-painter as I mention above that I get when build example I tried again and got same error

`/Users/ahmedgalal/StudioProjects/blue_thermal_printer/macos/Classes/BlueThermalPrinterPlugin.m:6:4: error: unknown receiver 'SwiftBlueThermalPrinterPlugin'; did you mean 'BlueThermalPrinterPlugin'? [SwiftBlueThermalPrinterPlugin registerWithRegistrar:registrar]; ^~~~~~~~~ BlueThermalPrinterPlugin In file included from /Users/ahmedgalal/StudioProjects/blue_thermal_printer/macos/Classes/BlueThermalPrinterPlugin.m:1: @interface BlueThermalPrinterPlugin : NSObject ^ 1 error generated. BUILD FAILED

Exception: Build process failed `

A7MeDG0L0L commented 1 year ago

@flutter-painter Can you tell me which files you tirmmed from JustAudio package and where you put these files into that package ?

flutter-painter commented 1 year ago

Hi @A7MeDG0L0L

The three classes are here : macos/

I also reworked a typo in the podspec macos/blue_thermal_printer.podspec

A7MeDG0L0L commented 1 year ago

@flutter-painter Can you create a new fork with your changes to use it because I didn't understand which files from JustAudio/macos Or JustAudio/example/macos Thanks in advance

flutter-painter commented 1 year ago

You should not need to add anyhting else, I was just providing context to the peculiar look of the /macos folder in this package.

It works without any edits from the latest version of blue_thermal_printer I am sure you tried to run : flutter clean

But did you also remove all versions of blue_thermal_printer from your .pub-cache ? It should be here : flutter/.pub-cache/hosted/

A7MeDG0L0L commented 1 year ago

@flutter-painter Currently I cloned this repo and run example but can you explain to me what you did with these three classes (Removed / Copied from another source / edited) image

flutter-painter commented 1 year ago

You are right I think I changed locally in BlueThermalPrinterPlugin.m

SwiftBlueThermalPrinterPlugin -> BlueThermalPrinterPlugin

I have issues building at the moment so I cannot test and PR, but it should fix it for you

A7MeDG0L0L commented 1 year ago

You are right I think I changed locally in BlueThermalPrinterPlugin.m

SwiftBlueThermalPrinterPlugin -> BlueThermalPrinterPlugin

I have issues building at the moment so I cannot test and PR, but it should fix it for you

By Changing that it failed to build. image

flutter-painter commented 1 year ago

Hi @A7MeDG0L0L,

Thank you for trying it out and sorry for the trouble, I messed around with the macos files again and straightened it out. PR submitted here :

https://github.com/kakzaki/blue_thermal_printer/pull/169

#import "BlueThermalPrinterPlugin.h"

static NSString *const CHANNEL_NAME = @"plugins.kzaki.com/blue_thermal_printer";

@implementation BlueThermalPrinterPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
    FlutterMethodChannel* channel = [FlutterMethodChannel
                                     methodChannelWithName:CHANNEL_NAME
                                     binaryMessenger:[registrar messenger]];
    BlueThermalPrinterPlugin* instance = [[BlueThermalPrinterPlugin alloc] init];
    [registrar addMethodCallDelegate:instance channel:channel];
}

@end

// note reformatting this to ease copy paste @kakzaki if you could generate a new version of blue_thermal_printer (^1.2.4) it would be much appreciated

A7MeDG0L0L commented 1 year ago

@flutter-painter Thanks alot your branch works well. and it merged but I wait it to push into pub.dev