Discussion:
[Qt-creator] Using Qt Creator for legacy ObjectiveC++ project
Henry Skoglund
2018-02-28 22:29:54 UTC
Permalink
Hi,

reading some recent posts about reusing Qt Creator for other project
flavors than Qt/C++, on a lark I decided to try it on my 6 year old
ObjectiveC++ LOB app (about 20K SLOC) and it's working great.

I inserted a .pro file with some HEADERS += and SOURCES += in the
directory, doubleclicked on it and voila, I can use Qt Creator to edit
those old .mm files (I need to rescale the UI for iPhone X and stuff
like that). It's a relief not having to work in Xcode, the current
version 9.2 sometimes feels like waiting for Deep Thought to answer.


A few things in case someone else endeavors to do the same: to get
IntelliSense to work with all the NSxxx types (which is great, then Qt
Creator can auto-expand [myString stringByAppendingString:myOtherString]
and other similar API calls for you) you need to get #includes like
these up and running:

#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
#import <MessageUI/MessageUI.h>

because Qt Creator will complain: "not found". I think Xcode does some
tweaking with the include paths into /Applications/Xcode to get those
#includes to work, here's what I did:

inserted this in the pro file:

INCLUDEPATH =
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
# (you gotta love Apple for those "simple" directory trees)

and created these symbolic links inside the XCode.app:

cd
/Applications/Xcode.app/Contents/Developer/Platform/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
sudo ln -s CoreData.framework/Headers CoreData
sudo ln -s Foundation.framework/Headers Foundation
sudo ln -s MessageUI.framework/Headers MessageUI
sudo ln -s UIKit.framework/Headers UIKit
sudo ln -s UserNotificaitons.framework/Headers UserNotifications

Those will probably vanish when Xcode 9.3 or 10.0 arrives, but they're
easy to reapply.


The code model still complains about some minor things in XCode's files,
currently I have these 2:

"expecting a type" for NSComparator in NSArray.h in line 74:
- (NSArray<ObjectType> *)sortedArrayUsingComparator:(NSComparator
NS_NOESCAPE)cmptr API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0),
tvos(9.0));

"nullability specifier _Nullable" cannot be applied to non-pointer type
'uuid_t' (aka 'unsigned char [16]') in NSUUID.h line 26:
- (instancetype)initWithUUIDBytes:(const uuid_t _Nullable)bytes;

but I can click that green "Minimize" button in the top right corner to
hide those errors and carry on working anyway.


Finally, got one question:
who's Uncle Bob? (he's listed as one of the Code Model's configurations :-)

Rgrds Henry
Eike Ziller
2018-03-01 08:09:21 UTC
Permalink
Hi, great that you were able to use Qt Creator for that!

A few notes:

QMake has a separate variable for Objective-C/++ sources called OBJECTIVE_SOURCES. Not sure if it makes a difference in Qt Creator though (or if we only care about the file extension).

I suppose you can get rid of your INCLUDEPATH and links if you set the Sysroot in your kit to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk

Br, Eike
Hi,
reading some recent posts about reusing Qt Creator for other project flavors than Qt/C++, on a lark I decided to try it on my 6 year old ObjectiveC++ LOB app (about 20K SLOC) and it's working great.
I inserted a .pro file with some HEADERS += and SOURCES += in the directory, doubleclicked on it and voila, I can use Qt Creator to edit those old .mm files (I need to rescale the UI for iPhone X and stuff like that). It's a relief not having to work in Xcode, the current version 9.2 sometimes feels like waiting for Deep Thought to answer.
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
#import <MessageUI/MessageUI.h>
INCLUDEPATH = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
# (you gotta love Apple for those "simple" directory trees)
cd /Applications/Xcode.app/Contents/Developer/Platform/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
sudo ln -s CoreData.framework/Headers CoreData
sudo ln -s Foundation.framework/Headers Foundation
sudo ln -s MessageUI.framework/Headers MessageUI
sudo ln -s UIKit.framework/Headers UIKit
sudo ln -s UserNotificaitons.framework/Headers UserNotifications
Those will probably vanish when Xcode 9.3 or 10.0 arrives, but they're easy to reapply.
- (NSArray<ObjectType> *)sortedArrayUsingComparator:(NSComparator NS_NOESCAPE)cmptr API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));
- (instancetype)initWithUUIDBytes:(const uuid_t _Nullable)bytes;
but I can click that green "Minimize" button in the top right corner to hide those errors and carry on working anyway.
who's Uncle Bob? (he's listed as one of the Code Model's configurations :-)
Rgrds Henry
_______________________________________________
Qt-creator mailing list
http://lists.qt-project.org/mailman/listinfo/qt-creator
--
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
***@qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
Henry Skoglund
2018-03-06 05:18:56 UTC
Permalink
Post by Eike Ziller
Hi, great that you were able to use Qt Creator for that!
QMake has a separate variable for Objective-C/++ sources called OBJECTIVE_SOURCES. Not sure if it makes a difference in Qt Creator though (or if we only care about the file extension).
I checked, seems OBJECTIVE_SOURCES or SOURCES work the same in my .pro
file for the purpose of Qt Creator's syntax highlighting and code
completion/IntelliSense.
Post by Eike Ziller
I suppose you can get rid of your INCLUDEPATH and links if you set the Sysroot in your kit to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
Yes I could get rid of them! But the answer was actually much simpler, I
had forgot to install Qt 5.10.1 for iOS, only had it for "Desktop" on my
desktop Mac. Once I've installed iOS support, removed the old .pro.user
file and started anew with "Qt 5.10.1 for iOS Simulator",
#importing <UIKit/UIKit.h> works like a charm without any ln -s helper
links :-)


One more question: for all the Xcode bashing, I find the Analyze compile
command in Xcode more powerful/finding more stuff than the Analyze/Clang
Static Analyzer in Qt Creator. For example, if I have this simple
function in my .mm file:

void xyzzy()
{
int i = 42;
int i2 = i + i;
i = i2;
}

Qt Creator's Analyze is happy with it but Xcode's Analyze says "Value
stored to 'i' is never read" for the "i = i2;" source line. Would be
nice if Qt Creator could have the same power :-)

Rgrds Henry
Christian Kandeler
2018-03-06 08:55:50 UTC
Permalink
On Tue, 6 Mar 2018 06:18:56 +0100
Post by Henry Skoglund
One more question: for all the Xcode bashing, I find the Analyze compile
command in Xcode more powerful/finding more stuff than the Analyze/Clang
Static Analyzer in Qt Creator. For example, if I have this simple
void xyzzy()
{
int i = 42;
int i2 = i + i;
i = i2;
}
Qt Creator's Analyze is happy with it but Xcode's Analyze says "Value
stored to 'i' is never read" for the "i = i2;" source line. Would be
nice if Qt Creator could have the same power :-)
I'm pretty sure both IDEs just forward clang's findings to you. When I put the above function in my (C++) project, Creator's clang static analyzer showed me the exact same message you pasted above.


Christian

Loading...