[Interest] Qt iOS and App Extensions

Nuno Santos nunosantos at imaginando.pt
Tue Jun 20 17:41:35 CEST 2017


Jake,

Thanks for your insights. 

Do you think it is possible to open a qml view inside a App Extension?

My options:

1) Try to do it via Qt side. Based on what you have just told me seems to be impossible.

2) Grab a Xcode project that already works an link with the necessary Qt frameworks so I can instantiate a Qml View and embed it inside the App Extension.

Thanks once again for your reply.

Regards,

Nuno

> On 20 Jun 2017, at 16:17, Jake Petroules <Jake.Petroules at qt.io> wrote:
> 
> Application extensions are simply normal Mach-O executables with _NSExtensionMain as their entry point instead of main. They are executed and quit by the system when needed, and the timing of these events cannot be controlled manually.
> 
> qmake does not support building app extensions (although the Qt libraries themselves are now built with -fapplication-extension, making them extension compatible) and most likely never will.
> 
> Qbs has some basic support for building app extensions already. The rest of the work needed is, as you say, in the platform plugin, which currently expects a normal main() entry point. I'm not sure yet how we'll solve that, as the iOS platform plugin is very tightly coupled to application initialization.
> 
> Typically in an application extension you give the Info.plist the name of a storyboard or view controller class to instantiate, and that's your primary "entry point". You cannot instantiate the UIApplication or set a UIApplicationDelegate yourself.
> 
>> On Jun 20, 2017, at 4:57 AM, Nuno Santos <nunosantos at imaginando.pt> wrote:
>> 
>> Hi,
>> 
>> I finally had some time to research on this.
>> 
>> I was able to create a test app with Qt Creator and manually place another app (extension) inside the generated .app bundle PlugIns folder. The app extension is an audio unit plugin for AUV3 hosts such as Modstep. I have then used Modstep to see if it could see my App Extension. He does find the App Extension but when trying to load it, it hangs. Now I’m in the darkness. The device log didn’t show much and the host app totally hanged.
>> 
>> App Extensions seem to be an app but without main. I have discovered that Xcode passes the -e _NSExtensionMain to an App Extension build. 
>> 
>> Questions: 
>> 
>> 1) When I set my Qt app to be an app, I’m forced to declare a main function, otherwise it gives the following error:
>> 
>> Undefined symbols for architecture armv7:
>>  "_main", referenced from:
>>      user_main_trampoline() in libqios_debug.a(qioseventdispatcher.o)
>> 
>> Can I make a Qt iOS that doesn’t have a main function? 
>> 
>> 2) What commands can I use to compare the type of binary files?
>> 
>> Is otool -l  the most indicated?
>> 
>> 
>> My ultimate goal is to keep using Qml to draw the App Extension user interface inside the host application. 
>> 
>> If that isn’t possible because of memory limits I still want to try pack and compile the whole thing in QtCreator, discovering the necessary flags and projecto configuration for that to happen. 
>> 
>> For that I need to know exactly what an App Extension is: a executable? a dynamic library? a static library? 
>> 
>> My knowledge of operating system underlying basics are very limited so I was trying to find some insights around here. 
>> 
>> Thanks,
>> 
>> Best regards,
>> 
>> Nuno
>> 
>>> On 22 May 2017, at 10:08, Mike Krus <mike.krus at kdab.com> wrote:
>>> 
>>>> 
>>>> On 22 May 2017, at 09:45, Nuno Santos <nunosantos at imaginando.pt> wrote:
>>>> 
>>>> Milke,
>>>> 
>>>> Thanks for your reply.
>>>> 
>>>> I was not expecting an out of the box process. The problem is that I’m still lost.
>>>> 
>>>> Let me show you the big picture. I have a synthesiser app. One of the functionalities of App Extensions are Audio Units. I want to provide the ability of other apps running multiple instances of my synthesiser app. This is called AudioUnit (which in the context of iOS is a V3 AudioUnit) I have found a cocoa example here: https://github.com/EricGeorge/AUInstrument
>>>> 
>>>> From the working example I need to have a the app, which I currently develop using Qt.
>>>> 
>>>> With the app development I always need Xcode in the end to enable app features such as inter-app audio, push notifications, etc since it is not possible to enable that on QtCreator. So, what I do is I run qmake and I have the generated Xcode project.
>>> I think those settings are stored in an entitlement file, if you have set it up once in Xcode, you should be able to copy the entitlement file to your source folder and have qmake deploy it for you.
>>> 
>>>> I also need to have a App Extension target which in the case of the example, links with a framework and makes part of the app membership, being placed inside the app target, under PlugIns dir.
>>>> 
>>>> 
>>>> I have already done an AudioUnit with Qt. in order to make an AudioUnit, the target is a plugin which generates a dynamic lib (dylib). The trick with Qt is that basically you need to handle the packaging yourself. There is the need of making a TARGET.component and make all the dirs inside, etc. 
>>>> 
>>>> I don’t believe an app extension will be any way different from this. Right now I just don’t know how to put everything together. Questions I have:
>>>> 
>>>> - What kind of target is an App Extension? dylib? Static lib? Exectuable? I think it might be a dylib just like a Mac OSX AudioUnit
>>> no, extensions are apps, with an appex extension (first hurdle, the .app extension for the targets generated by qmake is hard coded).
>>> The host app and your extension then communicate via one of the Apple designed IPX protocols (depending on the type of extension). That’s what the example you link to shows.
>>> 
>>>> - I think I will need to use Xcode anyway because of the code signing process
>>>> - I don’t know how to configure a target on Xcode that depends on Qt stuff without having qmake to generate all the stuff.
>>> I’ve never done it before but I guess the best path would be start from the sample project you found and then lots forensic examination of the project and associate files (plist and all) and see how to manually setup your own project. Lots of the editing the Xcode project file in a text editor to make it do what you want.
>>> 
>>> 
>>> Mike
>>> 
>>>> for now I’m just trying to handle project configuration issues. There will be an even more interesting challenge, which is to show a Qt app window, on the instance of the Audio Unit.
>>>> 
>>>> Any ideas?
>>>> 
>>>> Regards,
>>>> 
>>>> Nuno
>>>> 
>>>>> On 22 May 2017, at 09:21, Mike Krus <mike.krus at kdab.com> wrote:
>>>>> 
>>>>> As far as I know, qmake is not capable of generating Xcode projects with the right
>>>>> structure (need 2 to start with, different project types, etc).
>>>>> 
>>>>> Mike
>>>>> 
>>>>>> On 21 May 2017, at 11:13, Nuno Santos <nunosantos at imaginando.pt> wrote:
>>>>>> 
>>>>>> Robert,
>>>>>> 
>>>>>> There is clearly a communication problem here. Maybe I’m not using the correct word.
>>>>>> 
>>>>>> I want to know how to make an App Extension from QtCreator. In summary:
>>>>>> 
>>>>>> - In order to create an app extension with Qt Creator what should be the qmake flags?
>>>>>> 
>>>>>> I want to bypass Xcode. Is this possible?
>>>>>> 
>>>>>> Regards,
>>>>>> 
>>>>>> Nuno
>>>>>> 
>>>>>>> On 21 May 2017, at 10:12, Robert Iakobashvili <coroberti at gmail.com> wrote:
>>>>>>> 
>>>>>>> Yes, you can add frameworks to an extension like to
>>>>>>> any other project in XCode.
>>>>>>> 
>>>>>>> So it can look like:
>>>>>>> 
>>>>>>> Swift GUI <-> Obj-C-Bridging Code <-> C++ business logic using your
>>>>>>> frameworks/components.
>>>>>>> 
>>>>>>> But do not forget the memory limit - 30 MB.
>>>>>>> 
>>>>>>> Take care.
>>>>>>> 
>>>>>>> Kind regards,
>>>>>>> Robert
>>>>>>> 
>>>>>>> 
>>>>>>> On Sun, May 21, 2017 at 12:02 PM, Robert Iakobashvili
>>>>>>> <coroberti at gmail.com> wrote:
>>>>>>>> Dear Nuno,
>>>>>>>> Whatever I did was completely decoupled from Qt.
>>>>>>>> 
>>>>>>>> Only XCode project - it was an app with its bundle and within an app
>>>>>>>> it was a sub-app bundle.
>>>>>>>> 
>>>>>>>> But there are many types of extensions.
>>>>>>>> 
>>>>>>>> So, starting from an example of your extension and extending
>>>>>>>> it could be the right path.
>>>>>>>> 
>>>>>>>> If you find you still have memory up to 30 MB, you can link
>>>>>>>> QtCore if it helps you.
>>>>>>>> 
>>>>>>>> Your business logic could be in C++ and Swift interface can talk back
>>>>>>>> and forth with C++ via an objective-C Bridge - even with debugging
>>>>>>>> going smoothly between the pieces.
>>>>>>>> 
>>>>>>>> Sorry for being not too much helpful with a Qt-path.
>>>>>>>> Kind regards,
>>>>>>>> Robert
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On Sun, May 21, 2017 at 11:51 AM, Nuno Santos <nunosantos at imaginando.pt> wrote:
>>>>>>>>> Robert,
>>>>>>>>> 
>>>>>>>>> Right now I’m more interested in how to put things together.
>>>>>>>>> 
>>>>>>>>> Were you able to do it?
>>>>>>>>> 
>>>>>>>>> Where are you coding the extension? With Qt Creator or Xcode?
>>>>>>>>> 
>>>>>>>>> How are you setting the project?
>>>>>>>>> 
>>>>>>>>> Can the app extension be deployed as a plugin? Like a .component? A dynamic
>>>>>>>>> library packed in a bundle?
>>>>>>>>> 
>>>>>>>>> Because I have already done a AudioUnit in the past and I can make it with
>>>>>>>>> Qt using the following flags:
>>>>>>>>> 
>>>>>>>>> CONFIG += lib_bundle shared
>>>>>>>>> 
>>>>>>>>> The thing is that QtCreator doesn’t handle the packaging so I have to
>>>>>>>>> manually do everything.
>>>>>>>>> 
>>>>>>>>> But as for App Extensions I don’t know exactly what they are. I have a Xcode
>>>>>>>>> example but with Xcode is always hard to decipher how things were made.
>>>>>>>>> 
>>>>>>>>> Regards,
>>>>>>>>> 
>>>>>>>>> Nuno
>>>>>>>>> 
>>>>>>>>> On 21 May 2017, at 05:20, Robert Iakobashvili <coroberti at gmail.com> wrote:
>>>>>>>>> 
>>>>>>>>> On Sat, May 20, 2017 at 7:54 PM, Nuno Santos <nunosantos at imaginando.pt>
>>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> HI,
>>>>>>>>> 
>>>>>>>>> I’m trying to develop an app extension for my Qt iOS app but I don’t know
>>>>>>>>> what kind of target it is.
>>>>>>>>> 
>>>>>>>>> I always try to use Qt Creator to handle my Qt based projects. In case of
>>>>>>>>> iOS projects I try to use only Xcode to deployment and debug.
>>>>>>>>> 
>>>>>>>>> Is an app extension a framework or a executable?
>>>>>>>>> 
>>>>>>>>> As anyone tried this before?
>>>>>>>>> 
>>>>>>>>> I want to know how to configure the app extension on Qt Creator .pro
>>>>>>>>> 
>>>>>>>>> Regards,
>>>>>>>>> 
>>>>>>>>> Nuno
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Hi Nuno,
>>>>>>>>> When doing it recently, it appears that there's a unpublished memory
>>>>>>>>> limit of up to 30 MB imposed by Apple that an extension is allowed.
>>>>>>>>> 
>>>>>>>>> Initially, I was planning to use Swift interface with QtCore classes in my
>>>>>>>>> core logic connected by an Objective-C Bridge.
>>>>>>>>> 
>>>>>>>>> However, due to the memory limitations, I've migrated from Qt to
>>>>>>>>> some C-written hash maps, etc containers with less pointers and less
>>>>>>>>> consumption of memory.
>>>>>>>>> 
>>>>>>>>> Take care.
>>>>>>>>> 
>>>>>>>>> Kind regards,
>>>>>>>>> Robert
>>>>>>>>> 
>>>>>>>>> 
>>>>>> 
>>>>>> _______________________________________________
>>>>>> Interest mailing list
>>>>>> Interest at qt-project.org
>>>>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>>> 
>>>>> --
>>>>> Mike Krus | mike.krus at kdab.com | Senior Software Engineer
>>>>> KDAB (UK) Ltd., a KDAB Group company
>>>>> Tel: UK Office +44 1625 809908   Mobile +44 7833 491941
>>>>> KDAB - The Qt Experts
>>>>> 
>>>> 
>>> 
>>> --
>>> Mike Krus | mike.krus at kdab.com | Senior Software Engineer
>>> KDAB (UK) Ltd., a KDAB Group company
>>> Tel: UK Office +44 1625 809908   Mobile +44 7833 491941
>>> KDAB - The Qt Experts
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
> 
> -- 
> Jake Petroules - jake.petroules at qt.io
> The Qt Company - Silicon Valley
> Qbs build tool evangelist - qbs.io
> 




More information about the Interest mailing list