Skip to content

Fix ios demo #54

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ SCodes library is using `SBarcodeFilter` class for Qt5 and `SBarcodesScanner` cl

If you want to read more about implementation details of the library in Qt6 read the document: [Implementation Details in Qt6](https://github.com/scytheStudio/SCodes/blob/master/doc/detailsQt6.md)

### Deploy on Ios quickfix

Project version with Qt6 on cmake is configured properly and as cmake files goes it's ready to use as is.
But a common issue that can occour while targeting the Ios is that by default ZXing library is build as dynamic .dylib format that not always is properly recognized by the mobile devices.

![Ios Quickfix Preview 0](/assets/fix_ios_0.png)

To fix it simply go to the CMakeLists.txt file responsible for building the ZXing library, while I'm writing this it's in here `/.../SCodes/src/zxing-cpp/core/CMakeLists.txt`.
You will know for sure when you find the list of all ZXing sources.

![Ios Quickfix Preview 1](/assets/fix_ios_1.png)

Scroll down into the line with `add_library` instruction, where the ZXing target is defined. Make this library static by writing the `STATIC` keyword.
Now we've changed the library format to static, which mean the ZXing code will be linked to your app during the compilation process. Rebuild your app and check if it works.

![Ios Quickfix Preview 2](/assets/fix_ios_2.png)

### Trying various formats
`SBarcodeFilter` is a class that you need to use for scanning case. By default it scans only specific basic formats of code (Code 39, Code 93, Code 128, QR Code and DataMatrix.).
Expand Down
Binary file added assets/fix_ios_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/fix_ios_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/fix_ios_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/QmlBarcodeReader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ endif()

target_link_libraries(${PROJECT_NAME} PRIVATE ${REQUIRED_QT_LIBS} SCodes)

if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/ios/Info.plist
)
endif()


if(QT_VERSION_MAJOR EQUAL 6)
qt_import_qml_plugins(${PROJECT_NAME})
Expand Down
57 changes: 57 additions & 0 deletions examples/QmlBarcodeReader/ios/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>

<key>CFBundlePackageType</key>
<string>APPL</string>

<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>

<key>CFBundleDisplayName</key>
<string>${QT_INTERNAL_DOLLAR_VAR}{PRODUCT_NAME}</string>

<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>

<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>

<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>

<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>

<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>

<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>

<key>NSCameraUsageDescription</key>
<string>App uses the camera to scan QR codes.</string>

<key>LSRequiresIPhoneOS</key>
<true/>

<key>NOTE</key>
<string>This file was generated by Qt's default CMake support.</string>

<key>UILaunchStoryboardName</key>
<string>@qt_ios_launch_screen_plist_entry@</string>

<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
6 changes: 6 additions & 0 deletions examples/QmlBarcodeReader/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "qcamera.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QPermissions>

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include "SBarcodeFilter.h"
Expand All @@ -16,6 +18,10 @@ int main(int argc, char* argv[])
#endif
QGuiApplication app(argc, argv);

app.requestPermission(QCameraPermission{}, [](const QPermission& permission) {
qDebug() << permission;
});

QQmlApplicationEngine engine;

qmlRegisterSingletonType(QUrl("qrc:/qml/Theme.qml"), "Theme", 1, 0, "Theme");
Expand Down