alex_lip
alex_lipJan. 14, 2018, 2:15 p.m.

Development on Qt for iOS

Content

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.

Do you like it? Share on social networks!

BlinCT
  • Jan. 14, 2018, 2:28 p.m.

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

Comments

Only authorized users can post comments.
Please, Log in or Sign up
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
ИМ
Игорь МаксимовNov. 22, 2024, 10:51 p.m.
Django - Tutorial 017. Customize the login page to Django Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…
Evgenii Legotckoi
Evgenii LegotckoiNov. 1, 2024, 12:37 a.m.
Django - Lesson 064. How to write a Python Markdown extension Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
A
ALO1ZEOct. 19, 2024, 6:19 p.m.
Fb3 file reader on Qt Creator Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html
ИМ
Игорь МаксимовOct. 5, 2024, 5:51 p.m.
Django - Lesson 064. How to write a Python Markdown extension Приветствую Евгений! У меня вопрос. Можно ли вставлять свои классы в разметку редактора markdown? Допустим имея стандартную разметку: <ul> <li></li> <li></l…
d
dblas5July 5, 2024, 9:02 p.m.
QML - Lesson 016. SQLite database and the working with it in QML Qt Здравствуйте, возникает такая проблема (я новичок): ApplicationWindow неизвестный элемент. (М300) для TextField и Button аналогично. Могу предположить, что из-за более новой верси…
Now discuss on the forum
m
moogoNov. 22, 2024, 6:17 p.m.
Mosquito Spray System Effective Mosquito Systems for Backyard | Eco-Friendly Misting Control Device & Repellent Spray - Moogo ; Upgrade your backyard with our mosquito-repellent device! Our misters conce…
Evgenii Legotckoi
Evgenii LegotckoiJune 25, 2024, 1:11 a.m.
добавить qlineseries в функции Я тут. Работы оень много. Отправил его в бан.
t
tonypeachey1Nov. 15, 2024, 5:04 p.m.
google domain [url=https://google.com/]domain[/url] domain [http://www.example.com link title]
NSProject
NSProjectJune 4, 2022, 1:49 p.m.
Всё ещё разбираюсь с кешем. В следствии прочтения данной статьи. Я принял для себя решение сделать кеширование свойств менеджера модели LikeDislike. И так как установка evileg_core для меня не была возможна, ибо он писался…

Follow us in social networks