Is it possible to use some C source code in iPhone project? - iphone

I found a speech synthesizer that supports many languages (http://espeak.sourceforge.net/index.html). But the source code that is available is written in C.
What can i do to make it work on iPhone?

Objective-C is a strict super set of C. Which means you can use any C code in your Obj-C project.

Yes, as long as it's been ported to the LLVM C-compiler. You can create a statically linked framework out of it, and then link into your project.
Apple does not allow dynamically-loaded frameworks.

Related

How can Haxe convert flash content into objective c?

I went through many links like this,this and this, but not getting good direction to move with. I need to implement some flash content in my iPhone app. Can anybody help me with some good tutorials to move on with the conversion process. Thanks in advance.
Suppose I am having a flash air iOS app and I need to convert the whole app in objective c for say adding some features like APNS then I have to do some needful. I want to convert the air iOS based app in objective c for same thing and hence need a tool like Haxe. Kindly help me with some tutorial or any other tool available. Thank you.
I would recommend to check out http://www.haxenme.org/ to support iOS
Basically, Haxe is a new language (by new, I mean different than others, not recently developed). It's compiler can compile Haxe code to target different platforms like C++ / C#, Flash, NekoVM, PHP and JavaScript. That said, its syntax is similar to Flash ActionScript.
To conclude, Haxe does not convert one language to another. It is a language in itself, which can be compiled targetting different platforms. So if you can port your {insert language name here} code to Haxe, then you can compile it to any of the languages mentioned in http://haxe.org/doc/intro

Objective-C++ for iOS development

Is it possible to use Objective-C++ for iOS application (iPhone, iPad, iPod touch) development?
Are there any examples and source code on the Internet?
Using ObjC++ is quite easy.
You have to declare source files with extension .mm. It will make compiler treat them as ObjC++. The same with headers: use the .hh extension.
There is another option: go to target settings and set Compile Sources As to Objective-C++.
That's all. No additional work is necessary.
Some notes: if you want to develop a native iOS app, then use Objective C. It will save a lot of time.
But in some cases using C++ is more appropriate. E.g. for cross-platform development. So you use only a little bit of Objective C for iPhone or Java for Android just to glue your code with environment. Everything else in C++. I use this for my cross-platform game development.
Another case is performance: Objective C is principally slower then C++. However it is only noticeable during method calls (in ObjC it is called messaging).
Yes, you can. Take a look at the samples and new file templates that Apple provides.

Using c/c++ library that uses network for iphone app objective c

I am currently evaluating if a c/c++ library may be used for a specific iPhone project of mine. The original library makes heavy use of windows specific code (for example it includes windows.h and winsock.h). I am aware that I will have to rewrite the parts that use windows specific code and replace winsocks with for example bsd sockets. Or try to convert to objective-c++ and use IOS specific networking apis as it's recommended in Apple's documentation.
But as it turns out in Apple's documentation, in iOS only C and Objective-C code is allowed for networking. "iOS supports networking code written in C and Objective-C." ( https://developer.apple.com/library/ios/#referencelibrary/GettingStarted/GS_Networking_iPhone/ )
That sounds like I have to rewrite the whole library in objective-c to make it work on IOS. Or would it be sufficient to programm a wrapper class in objective-c and work with the original (adapted to bsd sockets api or objective-c++) library? -> Using C/C++ static libraries from iPhone ObjectiveC Apps
But the actual networking code still would be written c/c++ not objective-c.
Is there any chance this might work? I don't want to do all the work of adapting the library and then notice that this approach does not work.
Has anyone tried something similiar before?
Best regards,
Mike
You should be able to rewrite portions of your C++ library to used BSD sockets instead of the Windows sockets API without any problems.
Apple does not forbid C++ code from accessing the network, however the only networking APIs offered by iOS are in either C (BSD sockets, CoreFundation) or Objective-C (Foundation…), perhaps that's the source of your confusion. You can freely mix C, C++ and Objective-C code in your own code or in statically linked libraries.

Is TA-lib.org support on iOS on iphone?

I would like to add Technical analysis support to my financial project on iphone. And I found TA-lib on www.ta-lib.org, this library supports many indicators I need.
I would like to ask: Can I use ta-lib on my iphone development? And how I can do it, because this library is written in C language? I knew that Cocoa can compile C but how I can do it, import this library to iOS?
Any help would be appreciated.
Thanks
The iPhone SDK tools will compile most portable C code just fine (C is a pure subset of Objective C). There appears to be C source code available for the library in which you're interested. If so, you could try just including the source to the library in your iPhone Xcode project, and see if it all compiles, which it might if there are no dependency or collision problems. You may or may not need the entire library, which might help simplify things (or not).
You could also compile a separate static library, and then include that library, and the headers, in your iPhone app; but that technique may be a bit more complicated that your requirements might indicate.

Which is the most supported programming language for the iPhone?

I have decided to start programming some apps for the iPhone that eventually will get submitted to App Store. So I have to use a language the Apple supports.
However, from what I understand, there are some variety of languages I can choose from.
Ansi C
Objective C
C
C++
I started learning C++ in school back in 2001, so maybe I should use that. However, I would like to use the language that is most supported API and community wize. Which one is that?
Here's the low-down:
All iPhone SDK APIs are either Objective-C or pure (ANSI) C. The pure C APIs tend to be the lower-level APIs, so you could use just Objective-C.
However Objective-C is a strict superset of C, so you'll need a reasonable grounding in C in order to write Objective-C.
C++ is fully supported, but is not required (there are no C++ APIs). You can even mix Objective-C and C++ in the same source using Objective-C++. If you do this it's best to use C++ for pure computational components, pure Objective-C for the front-end, and Objective-C++ for the "glue" layer in the middle.
In summary: you'll need C and Objective-C. Use C++ for some parts if you particularly need it.
objective-c is the most supported - all the examples use it
Main language for iPhone platform is objective-c - almost all frameworks are objective-c based so you will have to use it for UI part at least. However as objective-c is a superset of c language you will be able to write some parts of your program using c/c++ as well.
There are C and Objective-C frameworks. Quartz2D is written in C but the Cocoa Touch framework is written in Objective-C, for instance. As Objective-C is a superset of C, if you choose Objective-C you will be able to use all available frameworks without problems.
Depending on what type of applications you're gonna to write, you could save yourself a lot of time & headache and use Appcelerator's Titanium Mobile (JavaScript) or Rhomobile (Ruby). All according to Apples latest TOU and therefore still submittable to the App Store.
The only languages that are officially allowed by Apple are
JavaScript
Objective-C
C++
C
All other languages are not allowed.
Whether or not this restriction is legal is a totally different question. (My gut feeling says that, at least in countries with somewhat sane anti-trust laws, it's illegal.)