-
-
Notifications
You must be signed in to change notification settings - Fork 464
Adding a wrapper for iOS #337
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
Conversation
Hallo Hendrik und Christian, thanks for your offer to contribute, much appreciated. I skimmed through your PR and have a few comments and suggestions for improvement. First, a few general things:
|
Since you did not react to my comments, yet, I'm wondering if I completely put you off with that feedback. If so, I'd like to invite you shortly describe what part of it was too much, so I may learn from my mistakes :). |
Co-authored-by: Christian Braun <braun.christian.bamberg@gmail.com>
Hi Axxel, thanks for your thoughtful analysis. Regarding your questions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went over the code again and started with a bunch of individual comments.
I'm looking at possibly using zxing-cpp for cross platform barcode scanning, so I was happy to see this PR 🎉. I just checked out this branch and tried to follow the steps and ran into a few issues though:
|
@ryantrem Thanks for joining the discussion and sharing your experience. Since I can't test the code myself, it is highly appreciated to have some 'external' feedback. I'd like to say something about 2 of your points:
I'll let the authors comment on the other two. |
@ryantrem Thank you for checking out this PR! |
@ChristianNorbertBraun thanks for picking this up again. Sorry for being so blunt but we seem to move 2 steps forward and then 1 step back:
|
@axxel All good, thank you for your feedback. I'm sorry for the inconvenience. I will try to clean up this mess tomorrow. |
disable blackbox tests by default and tune ZXingReaderTest to not fail when samples folder is missing. This fixes zxing-cpp#312.
Deprecate the namespace `CharacterSetECI` and header and use name consistent with `BarcodeFormatFromString()`.
Fixes zxing-cpp#168. This has been tested to work with the example applications. This is a pretty sharp "deprecation" of a whole lot of internal API and reduces the published interface to merely `ReadBarcode` and `MultiFormatWriter`. It is obviously somewhat risky but I see no other practical way of moving forward with limiting the API.
We've added a build-ios job within the ci.yml. Is this sufficient for ci integration? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fmtlib-src git submodule that you accidentally added needs to be removed again.
I was looking for the developer team name (or whatever it was called) to see if it was cleared but could not find it anymore.
width:(int)width | ||
height:(int)height | ||
format:(ZXIFormat)format | ||
charset:(ZXICharset)charset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is still an open question.
The team was set to none here: 7f6256f |
|
||
NSMutableArray* zxiResults = [NSMutableArray array]; | ||
for (auto result: results) { | ||
if(result.error() == Error::None) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not compile. The way to go here is using result.isValid()
. But if you don't pass DecodeHints::returnErrors(true)
and the default is not to, then all returned results are valid, so this check can completely be removed.
Also, the next line uses .c_str()
which will fail if the text()
property contains a \0
byte, which may be the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out.
Regarding the c_str()
. I'm afraid I don't quite understand. The function call actually expects a null terminated string. And doesn't a cstring contain a \0
byte per definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, a cstring ends with a \0
but the point is that the utf8 encoded content here may contain a \0
byte somewhere in the middle of the string. That is uncommon but possible and might lead to weird/silent bugs down the line. Better to fix it right here. Please use initWithBytes
with NSUTF8StringEncoding
. That should do the trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -2,6 +2,7 @@ | |||
// | |||
// SPDX-License-Identifier: Apache-2.0 | |||
|
|||
#define ZX_USE_UTF8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the back and forth but since this PR was too late for 1.4.0 and will now be part of 2.0 (I hope) this define is not necessary anymore and would merely be noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, I removed the define
Thanks a lot for your continued and cooperative work on this. Let's hope it further broadens the reach of the project. |
Something I only noticed now: the build time of the ios CI block is longer than any other. The demo-app alone takes 5 minutes to build, which seems excessive also compared to the faster build of the framework which has way more files to process (and is c++ instead of swift/objective-c). Is that also the case on your development machine? Any idea why that is and if something could be done about that? maybe a missing parallel build flag? |
We will take a look into it! Thank you for the collaboration. |
Building the demo app on my machine takes about 1 minute.
So maybe the 5 minute build was some problem with a single runner. As I can not reproduce these long build times I consider this problem as solved. |
Co-authored-by: Christian Braun braun.christian.bamberg@gmail.com
This pull request adds a wrapper of ZXing for iOS. It offers one class for reading and one for writing.
ZXing itself will be compiled to an universal framework,
xcframework
, that contains the binaries andheaders for the iOS-simulator and for iOS-devices. The wrapper-code is written in Objective-C++, whereas
the public part of the wrapper is Objective-C only. By this, it can also be used in Swift.
To build the
xcframework
, I had to add a section to the CMakeLists.txt. This enables buildingframeworks
for Apple platforms. Those frameworks are only either for the simulator, or for real devices. But they can be
combined to a single
xcframework
. This process is automated by thebuild-release.sh
-script.The section in the CMakeLists.txt should not change the behaviour on other platforms (tested on Linux so
far).
To use the wrapper, you first have to build the
xcframework
by calling the build-script and then addingthe
Package.swift
-file to your project. A demoproject is included, where also the usage is demonstrated.