Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 4.0 #100

Open
zeusent opened this issue Sep 13, 2017 · 8 comments
Open

Swift 4.0 #100

zeusent opened this issue Sep 13, 2017 · 8 comments

Comments

@zeusent
Copy link
Contributor

zeusent commented Sep 13, 2017

Is there a branch for Swift 4.0? Are there plans for such a branch soon?

@VFUC
Copy link
Contributor

VFUC commented Sep 13, 2017

see #101

@VFUC
Copy link
Contributor

VFUC commented Sep 21, 2017

There seem to be some Swift 4 updates on the master branch already - has this been handled already? If so, I'll close my merge request. If not, I'll update it and resolve the conflicts.

@lotfyahmed
Copy link

lotfyahmed commented Oct 10, 2017

Please help me, I upgrade to Swift 4 and Xcode 9. But I couldn't run the code
screen shot 2017-10-10 at 12 53 47 pm
screen shot 2017-10-10 at 12 53 40 pm

How can we fix that?

@malcommac
Copy link

malcommac commented Oct 11, 2017

Have you tried using the master branch directly?
Seems it was not released yet thought cocoapods:

pod 'RSBarcodes_Swift', :git => 'https://github.com/yeahdongcn/RSBarcodes_Swift', :branch => 'master'

@kubajakowski
Copy link

I've tried - it's crashing

@skeletom
Copy link

skeletom commented Nov 2, 2017

you can just change swift language version param from this pod build settings back to 3.2 and it will work just fine until the new release with swift 4 support is available

@zeusent
Copy link
Contributor Author

zeusent commented Nov 21, 2017

Any news on this? I still see version 3.0.3 as being the latest. Can someone push a new Podspec file?

@ravenshore
Copy link

Just wanted to let you know, that there are only several items that need to be corrected for Swift 4, not a big deal. I am just going to paste some of the items here:

here the .rawValue needed to be added ( including a few other places ... )

 open func generateCode(_ contents: String, inputCorrectionLevel: InputCorrectionLevel, machineReadableCodeObjectType: String) -> UIImage? {
        var codeGenerator: RSCodeGenerator?
        switch machineReadableCodeObjectType {
            
        case AVMetadataObject.ObjectType.qr.rawValue, AVMetadataObject.ObjectType.pdf417.rawValue, AVMetadataObject.ObjectType.aztec.rawValue:
            return RSAbstractCodeGenerator.generateCode(contents, inputCorrectionLevel: inputCorrectionLevel, filterName: RSAbstractCodeGenerator.filterName(machineReadableCodeObjectType))
        case AVMetadataObject.ObjectType.code39.rawValue:
            codeGenerator = RSCode39Generator()
        case AVMetadataObject.ObjectType.code39Mod43.rawValue:
            codeGenerator = RSCode39Mod43Generator()
        case AVMetadataObject.ObjectType.ean8.rawValue:
            codeGenerator = RSEAN8Generator()
        case AVMetadataObject.ObjectType.ean13.rawValue:
            codeGenerator = RSEAN13Generator()
        case AVMetadataObject.ObjectType.interleaved2of5.rawValue:
            codeGenerator = RSITFGenerator()
        case AVMetadataObject.ObjectType.itf14.rawValue:
            codeGenerator = RSITF14Generator()
        case AVMetadataObject.ObjectType.upce.rawValue:
            codeGenerator = RSUPCEGenerator()
        case AVMetadataObject.ObjectType.code93.rawValue:
            codeGenerator = RSCode93Generator()
            // iOS 8 included, but my implementation's performance is better :)
        case AVMetadataObject.ObjectType.code128.rawValue:
            if self.isBuiltInCode128GeneratorSelected {
                return RSAbstractCodeGenerator.generateCode(contents, inputCorrectionLevel: inputCorrectionLevel, filterName: RSAbstractCodeGenerator.filterName(machineReadableCodeObjectType))
            } else {
                codeGenerator = RSCode128Generator()
            }
        case AVMetadataObject.ObjectType.dataMatrix.rawValue:
            codeGenerator = RSCodeDataMatrixGenerator()
        case RSBarcodesTypeISBN13Code:
            codeGenerator = RSISBN13Generator()
        case RSBarcodesTypeISSN13Code:
            codeGenerator = RSISSN13Generator()
        case RSBarcodesTypeExtendedCode39Code:
            codeGenerator = RSExtendedCode39Generator()
        default:
            print("No code generator selected.")
        }
        
        if codeGenerator != nil {
            codeGenerator!.fillColor = self.fillColor
            codeGenerator!.strokeColor = self.strokeColor
            return codeGenerator!.generateCode(contents, inputCorrectionLevel: inputCorrectionLevel, machineReadableCodeObjectType: machineReadableCodeObjectType)
        } else {
            return nil
        }
    }

The last row in the barHandler also:

func barHandler() {
        
        self.barcodesHandler = { barcodes in
            for barcode in barcodes {
                self.session.stopRunning()
                print("Barcode found: type=" + barcode.type.rawValue + " value=" + barcode.stringValue!)
                DispatchQueue.main.async(execute: { () -> Void in
                    //                        // MARK: NOTE: Perform UI related actions here.
                    if let barcode_discovered = barcode.stringValue {
                    discoveredBarcode = barcode_discovered
                    self.dismiss(animated: true, completion: nil)
                        
                    }
                    
                })
            }
        }
        
        let types = NSMutableArray(array: self.output.availableMetadataObjectTypes)
        types.remove(AVMetadataObject.ObjectType.qr)
        self.output.metadataObjectTypes = NSMutableArray(array: types) as? [AVMetadataObject.ObjectType]
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants