David PHAM-VAN

Fix iOS/macOS release build not working

1 # Changelog 1 # Changelog
2 2
  3 +## 5.0.2
  4 +
  5 +- Fix iOS/macOS release build not working
  6 +
3 ## 5.0.1 7 ## 5.0.1
4 8
5 - Update dependencies 9 - Update dependencies
  1 +/*
  2 + * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +#import <printing/printing-Swift.h>
  18 +
  19 +// Dart:ffi API
  20 +
  21 +void net_nfet_printing_set_document(uint32_t job,
  22 + const uint8_t* doc,
  23 + uint64_t size) {
  24 + [PrintingPlugin setDocumentWithJob:job doc:doc size:size];
  25 +}
  26 +
  27 +void net_nfet_printing_set_error(uint32_t job, const char* message) {
  28 + [PrintingPlugin setErrorWithJob:job message:message];
  29 +}
@@ -17,29 +17,26 @@ @@ -17,29 +17,26 @@
17 import Flutter 17 import Flutter
18 import Foundation 18 import Foundation
19 19
20 -// Dart:ffi API  
21 -private var _printingPlugin: PrintingPlugin?  
22 -  
23 -@_cdecl("net_nfet_printing_set_document")  
24 -func setDocument(job: UInt32, doc: UnsafePointer<UInt8>, size: UInt64) {  
25 - _printingPlugin!.jobs[job]?.setDocument(Data(bytes: doc, count: Int(size)))  
26 -}  
27 -  
28 -@_cdecl("net_nfet_printing_set_error")  
29 -func setError(job: UInt32, message: UnsafePointer<CChar>) {  
30 - _printingPlugin!.jobs[job]?.cancelJob(String(cString: message))  
31 -}  
32 -  
33 -// End of Dart:ffi API  
34 - 20 +@objc
35 public class PrintingPlugin: NSObject, FlutterPlugin { 21 public class PrintingPlugin: NSObject, FlutterPlugin {
  22 + private static var instance: PrintingPlugin?
36 private var channel: FlutterMethodChannel 23 private var channel: FlutterMethodChannel
37 public var jobs = [UInt32: PrintJob]() 24 public var jobs = [UInt32: PrintJob]()
38 25
39 init(_ channel: FlutterMethodChannel) { 26 init(_ channel: FlutterMethodChannel) {
40 self.channel = channel 27 self.channel = channel
41 super.init() 28 super.init()
42 - _printingPlugin = self 29 + PrintingPlugin.instance = self
  30 + }
  31 +
  32 + @objc
  33 + public static func setDocument(job: UInt32, doc: UnsafePointer<UInt8>, size: UInt64) {
  34 + instance!.jobs[job]?.setDocument(Data(bytes: doc, count: Int(size)))
  35 + }
  36 +
  37 + @objc
  38 + public static func setError(job: UInt32, message: UnsafePointer<CChar>) {
  39 + instance!.jobs[job]?.cancelJob(String(cString: message))
43 } 40 }
44 41
45 /// Entry point 42 /// Entry point
  1 +/*
  2 + * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +#import <printing/printing-Swift.h>
  18 +
  19 +// Dart:ffi API
  20 +
  21 +void net_nfet_printing_set_document(uint32_t job,
  22 + const uint8_t* doc,
  23 + uint64_t size) {
  24 + [PrintingPlugin setDocumentWithJob:job doc:doc size:size];
  25 +}
  26 +
  27 +void net_nfet_printing_set_error(uint32_t job, const char* message) {
  28 + [PrintingPlugin setErrorWithJob:job message:message];
  29 +}
@@ -17,29 +17,26 @@ @@ -17,29 +17,26 @@
17 import FlutterMacOS 17 import FlutterMacOS
18 import Foundation 18 import Foundation
19 19
20 -// Dart:ffi API  
21 -private var _printingPlugin: PrintingPlugin?  
22 -  
23 -@_cdecl("net_nfet_printing_set_document")  
24 -func setDocument(job: UInt32, doc: UnsafePointer<UInt8>, size: UInt64) {  
25 - _printingPlugin!.jobs[job]?.setDocument(Data(bytes: doc, count: Int(size)))  
26 -}  
27 -  
28 -@_cdecl("net_nfet_printing_set_error")  
29 -func setError(job: UInt32, message: UnsafePointer<CChar>) {  
30 - _printingPlugin!.jobs[job]?.cancelJob(String(cString: message))  
31 -}  
32 -  
33 -// End of Dart:ffi API  
34 - 20 +@objc
35 public class PrintingPlugin: NSObject, FlutterPlugin { 21 public class PrintingPlugin: NSObject, FlutterPlugin {
  22 + private static var instance: PrintingPlugin?
36 private var channel: FlutterMethodChannel 23 private var channel: FlutterMethodChannel
37 public var jobs = [UInt32: PrintJob]() 24 public var jobs = [UInt32: PrintJob]()
38 25
39 init(_ channel: FlutterMethodChannel) { 26 init(_ channel: FlutterMethodChannel) {
40 self.channel = channel 27 self.channel = channel
41 super.init() 28 super.init()
42 - _printingPlugin = self 29 + PrintingPlugin.instance = self
  30 + }
  31 +
  32 + @objc
  33 + public static func setDocument(job: UInt32, doc: UnsafePointer<UInt8>, size: UInt64) {
  34 + instance!.jobs[job]?.setDocument(Data(bytes: doc, count: Int(size)))
  35 + }
  36 +
  37 + @objc
  38 + public static func setError(job: UInt32, message: UnsafePointer<CChar>) {
  39 + instance!.jobs[job]?.cancelJob(String(cString: message))
43 } 40 }
44 41
45 /// Entry point 42 /// Entry point
@@ -7,7 +7,7 @@ description: > @@ -7,7 +7,7 @@ description: >
7 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing 7 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing
8 repository: https://github.com/DavBfr/dart_pdf 8 repository: https://github.com/DavBfr/dart_pdf
9 issue_tracker: https://github.com/DavBfr/dart_pdf/issues 9 issue_tracker: https://github.com/DavBfr/dart_pdf/issues
10 -version: 5.0.1 10 +version: 5.0.2
11 11
12 environment: 12 environment:
13 sdk: ">=2.12.0-0 <3.0.0" 13 sdk: ">=2.12.0-0 <3.0.0"