Development on Qt for iOS

ios, qt

Preamble

The most democratic country in the world has created the most totalitarian operating system. Therefore, if you want to test your software on an iPad or IPhone, you must register with https://developer.apple.com/ as a developer. At the first stage, you do not have to pay money. Good Uncle Jobs will give you a certificate, for use to test your device, for a period of 7 (seven) days. At the end of the certificate, your software will not start and it will need to be downloaded again from the computer. If you want to install your software on another person's device - its apple ID will need to be written in the same way in Xcode as yours.

Problems

To study Qt, I decided to develop a mobile workplace for the workflow for the test task. Because the documents can be in the form of word, pdf, jpg, etc. I naturally need after downloading them from the server something to open them. Qt has a wonderful design

QDesktopServices :: openUrl ( QUrl :: fromLocalFile ( QStandardPaths :: writableLocation ( QStandardPaths :: GenericDataLocation ) + "/temp_esd/file." + file_ext ));
// File _ ext I pull out according to the MIME type
if ( head == "Content-Type" ) {
    if ( content_from_url == "image/jpeg" )
        file_ext = "jpg";
    else if ( content_from_url == "application/pdf" )
        file_ext = "pdf";
    else if ( content_from_url == "application/vnd.openxmlformats-officedocument.wordprocessingml.document" )
        file_ext = "docx";
    else if ( content_from_url == "application/msword" )
        file_ext = "doc";
    else if ( content_from_url == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" )
        file_ext = "xlsx";
    else if ( content_from_url == "application/vnd.ms-excel" )
        file_ext = "xls";
    else if ( content_from_url == "application/vnd.oasis.opendocument.text" )
        file_ext = "odt";
    else if ( content_from_url == "application/vnd.oasis.opendocument.spreadsheet" )
        file_ext = "ods";
    else if ( content_from_url == "application/octet-stream" )
        file_ext = "7z";
    else if ( content_from_url == "video/x-msvideo" )
        file_ext = "avi";
    else if ( content_from_url == "image/bmp" )
        file_ext = "bmp";
    else if ( content_from_url == "application/cdr" )
        file_ext = "cdr";
    else if ( content_from_url == "image/gif" )
        file_ext = "gif";
    else if ( content_from_url == "video/quicktime" )
        file_ext = "mov";
    else if ( content_from_url == "audio/mpeg" )
        file_ext = "mp3";
    else if ( content_from_url == "image/png" )
        file_ext = "png";
    else if ( content_from_url == "application/vnd.ms-powerpoint" )
        file_ext = "ppt";
    else if ( content_from_url == "application/vnd.openxmlformats-officedocument.presentationml.presentation" )
        file_ext = "pptx";
    else if ( content_from_url == "application/x-rar-compressed" )
        file_ext = "rar" ;
    else if ( content_from_url == "application/rtf" )
        file_ext = "rtf";
    else if ( content_from_url == "image/tiff" )
        file_ext = "tif";
    else if ( content_from_url == "text/plain" )
        file_ext = "txt" ;
    else if ( content_from_url == "audio/x-ms-wma" )
        file_ext = "wma";
    else if ( content_from_url == "application/zip" )
        file_ext = "zip";
}

But in iOS - in accordance with the recently adopted security standards it is forbidden to open a local URL in one application by running another one. Therefore, under IOS, the use of this construction caused an error

this plugin does not support

First I went in the direction of using Info.plist - especially since under iOS it is still needed. Registered in section

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>ms-word</string> 
        <string>ms-powerpoint</string> 
        <string>ms-excel</string>
    </array>

But this works only if the files are opened NOT locally - but on the Internet link. After further study of the problem, I came across the article https://code.tutsplus.com/tutorials/ios-sdk-previewing-and-opening-documents--mobile-15130 which describes how to use the UIDocumentInteractionController to open files in the sandbox of the ios application . Also thank you very much Ekkehard Gentz for a completely wonderful blog, which details the use of the above function in Qt.

Solution

And so we have a MAC MINI for compiling source and IPAD for testing. On the MAC MINI install QT. During the installation you will be offered to download XCODE - we agree. Everything is perfectly established. Next, in Xcode - Preferences - Accounts, add your Apple account and request a certificate (via Manage Certificates). Naturally, you must first register on the Apple website as a developer. Next, connect your IPAD and in the Settings - Developer - UI AUTOMATION - enable Enable UI Automation. Thus, we have transferred the iPad to the debugged mode.

In Xcode - Window - Devices and Simulators, you can check your connected device. Of course, during the connection you will be asked a couple of times about the trust of the computer to the device and the device of the computer - say YES.

In the Qt in the project file, add the following section

ios {
OBJECTIVE_SOURCES += ios/iosshareutils.mm \
ios/docviewcontroller.mm

QMAKE_INFO_PLIST = ios/Info.plist

LIBS += - framework UIKit
}

In this section we specify the location of Info.plist - this is a textual configuration file that you can edit manually.

OBJECTIVE_SOURCES are our files on OBJECTIVE- C

The LIBS directive is probably outdated. But I did not remove it.

In the sources themselves it is very convenient to use the directive

#if defined( Q_OS_IOS )

QString temp_url= QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/temp_esd/file." +file_ext;
qDebug() << "path_file " << temp_url;
IosShareUtils ios;
ios.viewFile(temp_url, "View File" , "application/pdf" , 21 );

#else
QDesktopServices :: openUrl ( QUrl :: fromLocalFile ( QStandardPaths :: writableLocation ( QStandardPaths :: GenericDataLocation ) + "/temp_esd/file." + file_ext ));
#endif

You can see the source code in the blog https://blog.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app/

In general, after the source texts are ready, we proceed to the de-file. Please note that in Qt Creator when you release on Qt 5.10 for iOS, the green dot on the right below the icon of the phone with the apple is burning. Hover over it and see the information about the device and whether it works in developer mode. After that, we compile the sources and try to upload them to the phone. From the first time does not work. Go to the Release folder and open the Xcode project of our application. At the top, where the name of your circuit is, select the active circuit on the device that is connected to the computer. Then click on the "Build and then run the current scheme" icon. But that is not all. Your application icon will appear on your device, but it will not start. Or it will start, but it will close quickly. Open the Ipad - go to settings - basic - device management - software developer - choose your apple id - then we say that we trust this developer. After all these operations, you can safely unplug the application directly from Qt Creator.

Thanks to all of the internet who patiently answered my stupid questions. And God will forgive those who tried to shake me off money. It seems to me - some kind of altruism should be present for every professional.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Вот честно, на сколько же муторно под огрызок что то делать. Куча проблем)
А вод линь или под Андроид все просто и тривиально))

Comments

Only authorized users can post comments.
Please, Log in or Sign up
How to become an author?

Contribute to the evolution of the EVILEG community.

Learn how to become a site author.

Learn it
Donate

Good day, Dear Users!!!

I am Evgenii Legotckoi, developer of EVILEG. And it is my hobby project, which helps to learn programming another programmers and developers

If the site helped you, and you want also support the development of the site, than you can donate by following ways

PayPalYandex.Money
Timeweb

Let me recommend you the excellent hosting on which EVILEG is located.

For many years, Timeweb has been proving his stability.

For projects on Django I recommend VDS hosting

View Hosting Timeweb
n
June 5, 2020, 2:28 a.m.
n1k0m1

Qt - Test 001. Signals and slots

  • Result:0points,
  • Rating points-10
s
June 3, 2020, 1:56 a.m.
silo1995

C++ - Тест 003. Условия и циклы

  • Result:35points,
  • Rating points-10
AP
June 2, 2020, 9:11 p.m.
Aleksej Pikenin

C++ - Test 005. Structures and Classes

  • Result:75points,
  • Rating points2
Last comments
June 5, 2020, 10:52 a.m.
progammist

Распознавание изображений на Python с помощью TensorFlow и Keras

Огромное спасибо за метериал, по-больше бы подобных статей (с подробным описанием работы и примерами применения). Вопрос поразмышлять. На текущий момент реализовано немало технологий в осно…
June 5, 2020, 1:39 a.m.
Evgenij Legotskoj

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

По-моему, смысла в этом нет особого. Если делегат будет игнорировать настройки таблицы, то это приведёт ещё к большему непониманию, что вообще происходит, для программиста, который после вас буд…
June 5, 2020, 1:34 a.m.
IscanderChe

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

Сижу, размышляю: можно ли переписать делегата так, чтобы независимо от настроек строк выделялись строки?
June 5, 2020, 1:31 a.m.
Evgenij Legotskoj

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

Понятно. Я не обратил внимания на то, что там было в старом коде по настройкам строк :)
June 5, 2020, 1:27 a.m.
IscanderChe

Qt/C++ - Tutorial 091. How to write a custom delegate controlling the highlighting of a row in a table

Разобрался. У вас изначально в проекте были вот эти настройки: ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);ui->tableView->setSelectionMode(QAbstractItemVie…
Now discuss on the forum
June 5, 2020, 6:13 a.m.
IscanderChe

Фильтр для QtableView sql

Добрый день. Для такой фильтрации необходимо использовать QSortFilterProxyModel. В оффдоках есть хороший пример.
MA
June 4, 2020, 2:46 a.m.
Mihail A

Qt- C++ QTableView подсветить строку

Спасибо.
f
June 3, 2020, 1:49 a.m.
fryn3

Можно ли сделать в QML таблицу как в Excel?

edi-tableview - нашел пока такое выглядит коряво, посмотрим что можно сделать
June 2, 2020, 2:46 a.m.
Evgenij Legotskoj

Медиа файлы Google Firebase

Картинки можете попробовать сжимать через QPixmap, там есть возможность установки scaleFactor, через него можете устанавливать нужные параметры. А что касается конвертации видео, то лучше п…
June 2, 2020, 2:01 a.m.
Evgenij Legotskoj

Перехват обращения к локальным файлам QWebEngineView

В вашем случае вполне адекватное решение. Так сказать меньше зло. В противном случае пришлось бы очень много переписывать и перепиливать.
About
Services
© EVILEG 2015-2020
Recommend hosting TIMEWEB