Privacy policyContactsAbout siteOpinionsGitHubDonate
© EVILEG 2015-2018
Recommend hosting
TIMEWEB

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.

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

Comments

Only authorized users can post comments.
Please, Log in or Sign up
P
Feb. 18, 2019, 3:39 p.m.
Poyar

C++ - Test 001. The first program and data types

  • Result:73points,
  • Rating points1
НБ
Feb. 15, 2019, 1:03 p.m.
Николай Булахтин

C++ - Test 002. Constants

  • Result:25points,
  • Rating points-10
Last comments
V
Feb. 14, 2019, 6:41 p.m.
Vlad15007

Спасибо огромное! Заработало!
А
Feb. 12, 2019, 9:26 a.m.
Александр90

Сам разборался, спасибо.
А
Feb. 12, 2019, 8:19 a.m.
Александр90

День добрый! Можешь выложить форму mainwindow.ui от урока? Заранее спасибо
Feb. 11, 2019, 10:51 a.m.
Евгений Легоцкой

Нет, у меня проблема с жёстким диском случилась, занимался восстановлением ПК, ещё пару вечеров придётся этим заниматься, увы.
Now discuss on the forum
Feb. 17, 2019, 5:28 p.m.
Евгений Легоцкой

Добрый день. Очень извиняюсь за долгий ответ Первое, что нашёл, так это необходимость перерисовать чекбокс. void CheckBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem ...
Feb. 15, 2019, 3:36 p.m.
Евгений Легоцкой

Ну я тут нашёл одно решение, но сам его не проверял. Вам нужно помещать фамилии скорее всего в ячейки заголовка, и потом просто перерисовывать их QHeaderView * header = m_ui->tableWidget...
Feb. 15, 2019, 7:53 a.m.
Евгений Легоцкой

Добрый день! Не работал с remoteobjects, поэтому глянул документацию, чтобы рассмотреть, что это за зверь. После просмотра документации сложилось стойкой впечатление, что это вполне возм...
m
Feb. 14, 2019, 6:28 p.m.
mr_roman

Нашел решение на Java. Удалось интегрировать в проект сервиса на Qt, теперь из Qt запускаю Java-код акселерометра.
Join us in social networks

For registered users on the site there is a minimum amount of advertising