Progress?I added this search path to my project's TARGETs:myApp:Header Search Paths/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/The "file not found errors" are gone but I'm getting a blizzard of other errors such asUnknown type name "namepace"Unknown type name "template"Expected ';' after top level declarator...and many more.Kinda lost.
Post
Replies
Boosts
Views
Activity
Xcode supports creation of .cpp files. Is that just a cruel hoax?
I've found an answer but I don't understand it!https://stackoverflow.com/questions/32541268/can-i-have-swift-objective-c-c-and-c-files-in-the-same-xcode-project/32546879#32546879
For the benefit of anyone following, here is some additional background. The solution I need may be hiding in these excellent links but I just can't see it. I feel like I've tried all the permutations of these that I can think of.Can I have Swift, Objective-C, C and C++ files in the same Xcode project?Can I mix Swift with C++? Like the Objective-C .mm fileshttps://www.youtube.com/watch?v=0x6JbiphNS4https://github.com/SwiftArchitect/SO-32541268I'm trying to implement the C++ code from the following project into my Xcode project. I've had success adding a different project in C, but this one in C++ is stumping me.https://github.com/CoolProp/IF97One issue was all the #include files in that project. I added the following search path to my Xcode build settings and this seems to fix the "file not found" errors./Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/How do I cobble this together?
FWIW, I'm encountering the same error using Xcode 11.3.1. It's one of many problems I'm having trying to use C++ code in an iOS app project. See here:https://forums.developer.apple.com/thread/130084I've placed links in my last reply there and that put it into moderation. Not sure you can see it. People have succeeded in using C++ code but so far I am not among them.
"None of your examples use a private, Objective-C header. For that reason, they aren't ever going to work in a real-world project."Can you elaborate on that? I'm specifically working on the Xcode project offered in the fourth, GitHub link. Does your comment apply to that as well? I've contacted the author of that project but no reply yet.I’m sad to say that your reply is over my head. I have never used anything but Swift and so all this hierarchy stuff, headers and includes, is magic to me. I stumbled through adding some C code but I haven't been so lucky with C++.
"My advice would be to just rename "IF97.cpp" to "IF97.Swift" and then fix the code. You'll have 10,000 errors until it stops counting, but just go through it and fix them one by one."I though of that. Brute force I understand! My reluctance is from not understanding C++ well enough to accomplish the tranlation but I suppose their are resources I can find to help.How to deal with all those includes?#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip> // std::setprecision
#include <stdexcept>
#include <stdio.h>
What do you think of the following approach?Use a Java version of the source code instead ==> sourceforge.net /projects/if97/Use Google's tool to port to Obj-C ==> developers.google.com /j2objcMight be easier than manually porting 5,000 lines of C++ code?[edit] altered the links to get this post out of moderation
It was a steep uphill curve, but it worked! I'm flabbergasted that such a tool exists. It converted java source code to Obj-C, which was then relatively easy to incorporate into my Swift app.As a relative noob to all this, I would have had zero chance of success without step-by-step guidance from Tom Ball, the lead of that project. Things like headers, linked librairies and all make my head swim but Tom led me through it all. He must have the patience of a saint. Kudos.
"So it is normal, order is not fixed in a dictionary and may change each time you invoke the dictionary."That's the part that was unexpected, to me at least. Now I know.
"If you want to iterate through the dictionary in the order defined by its keys, here’s a good way to do that:"Thanks for that but unfortunately my "real" table isn't sorted in any systematic way. It may make perfect sense to the user but not to a sort algorithm. I need to come up with a clever workaround to preserve the order.
"What orginal order do you want to "preserve" ?"Imagine the list above without the leading integers which I used to emphasize the effect. I'd like the order of the animals to remain unchanged. They're in no sorted order except for the unknown user preference.I think I'll just put the list of keys into a separate array at the same time the dictionary is initialized. The user never really sees the dictionary and I can use the list of keys to retain control over the order.I've been reminded by all this that dictionaries are unordered. I remember reading that but now it has hit home. Is there a good reason for that? I mean, it seems like it would always be more useful to have an ordered list than not.
"What is the problem with the solution I propose (of course giving the right original order) ?"Unless I'm mistaken that would sort the keys alphabetically and thus change the original, unsorted order. Remember to drop the leading integer.
That's exactly what I was doing when the problem was uncovered. I was mapping out how to validate that user inputs are in the proper range, so I could catch them all in Swift and never trigger the exception. The java code documentation describes a range of parameter values but I encountered this problem well inside that range. I've contacted the author.
No surprise, this works perfectly. Thanks!