New V6 API for Swift and Objective-C #115
ApolloZhu
started this conversation in
Announcement
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First of all, allow me to apologize for making breaking changes without changing the major version in the next release (probably v6.1.0). However, as noted, v6.0.0 is a pre-release (we had to do this because compile time error on Xcode 12).
What's new in the V6 API?
We took a look at the generator API, and realized that it's kind of like builder pattern, but you can't chain the calls that sets the parameters. With the new API, you can:
If you don't like builder pattern, now you can directly set the properties themselves as well. You might also notice that some parameters have a new name. I hope you find the new names more consistent and clear (in regards to what they do).
Objective-C Support
Currently, it's possible to use EFQRCode in Objective-C projects. However, some methods might be inaccessible due to recent Swift changes. In v6, we made sure all features of
EFQRCodeGenerator
andEFQRCodeRecognizer
are available in Objective-C.To help you get started, we included ObjCTests.m as an example of how to use EFQRCode in Objective-C.
Swift only APIs
Since Objective-C doesn't support default argument values, the helper methods from
EFQRCode
are only available in Swift. For Objective-C users, please use generator/recognizer directly and supply arguments as needed.With the builder pattern, we also introduced a helper method that sets a property and returns self:
Migration
To make the transition easier, we are only deprecating old APIs, and you can almost use fix-its to complete the transition process. Just select the first fix-it suggestion in Xcode, and use keyboard shortcut control + option + command + F to apply all fix-its in scope.
However, there are a few manual changes required after applying those fix-its:
pathToSave
parameter from generateGIF in 6926207, and now it's officially gone. Make sure you are saving the generated GIF data somewhere yourself (remove the extra argument also).nil
to representEFQRCodeMode.none
, so you might need to update to handleEFQRCodeMode?
instead.EFQRCodeRecognizer
now expects non-nilCGImage
input and output non-nil[String]
. You might need to check fornil
image before passing to a recognizer, and no longer need to check if the recognized contents array isnil
. Checking for empty array, however, is still needed in case if the input image is not a proper QR code.Documentation Updates
In addition to the updated user guide/readme, you'll start to see method/property description in Xcode quick help, as well as in the documentation website: https://efprefix.github.io/EFQRCode. There'll also be migration guides/demo videos.
同时,我们新发布了简体中文的 README 和用户指南到 https://efprefix.github.io/EFQRCode/zh (暂定,欢迎建议其他 URL)。
Playground
Playground
Questions/Concerns?
When you have time, please take a look at the new API/documentation, and let us know what you think about the changes.
Beta Was this translation helpful? Give feedback.
All reactions