This document discusses cross-platform development for the iPhone. It outlines two main approaches: porting existing code and writing new code designed for cross-platform use. Porting involves overcoming challenges like incompatible languages and system APIs across platforms. Solutions proposed include runtime libraries like qobjc and frameworks like dCocoa that emulate Objective-C and provide portable APIs. Writing new code allows using languages and libraries like C++, Lua and Qt that are inherently cross-platform. The document provides examples of porting Objective-C code to dCocoa and discusses benefits of a cross-platform approach.
2. Plan
• What is cross-platform development
• Benefits & Expenses
• Implementation - 2 ways
• Use open source libraries
• A&Q
3. What does this mean “cross-platform”?
1. GUI 2. Business logic
4. GUI porting is very bag applicable from
iPhone to desktop platforms
-?
5. How we can distribute business logic?
1. Base logic - memory, containers, etc.
2. Logic of your application
3. Graphic output (OpenGL, convertors)
4. Audio output (OpenAL)
5. Databases
6. What applications we can create full
cross-platform and what can be created
particles?
1. (Full) Games - 60% at all iPhone applications
2. (Medium) Scientific applications which use graphic
output - medical, engineering, etc.
3. (Not applicable) Applications based on iPhone GUI
7. Expenses
1. If you write 2 applications = you pay x2 $
2. Or you can write 1 application for 2 markets = x1.1 - x1.7 $
8. Several paths for attainment cross-platform
• Porting existing code
• Write new code than will be oriented to
cross-platform
9. Porting
If you have already wrote project - use this method
Problems
1. Existing code wrote on language which not
compile on other platforms, often this is
Objective-C
2. On a project was used system depended api
(on iPhone this is POSIX)
3. GUI - which can’t be ported automatically to
other platforms
10. Solutions
• For problem with code we can use some
emulators of objective-c code - qobjc runtime,
cocotron library.
• For system api we can writes wrappers than will
be defined on concrete platform.
• GUI - for better case need redesign, for second
case you can write some automatic engine for
your dialogs.
11. Open Source libraries
• For code porting (objc) currently we don’t have
optimal solutions. Almost all libraries designed for
Windows <-> Mac OS but not for iPhone.
But we can use its for:
1. Learning and looking to its implementations
2. Improve this libraries for iPhone
12. Solutions for code porting
Lib name License Compiler
Cocotron MIT GCC
GNUStep GPL GCC
qobjc Author’s, GPL Visual Studio
13. qobjc (quick)
http://code.google.com/p/qobjc
Scientific project, this is worked, tested runtime of
Objective-C language
Problem: this is only runtime lib, but for full functionality
need code parser
14. Objective-C
@interface MyDecl : BaseClass <QMyProto2> {
int _someInt;
double _someDouble;
float _someFloat;
}
- (float)calculateArea:(float)v0 :(float)v1 :(double)v2 :(float)v3 :(float)v4;
- (void)dealloc; // in objective-c this method not need declare on header :)
Macro code on qobjc
Q_BEGIN_CLASS(MyDecl, BaseClass)
Q_INCLUDE_PROTOCOL_TO_CLASS(QMyProto2)
Q_BEGIN_IVAR_LIST
Q_DEF_IVAR(_someInt, i)
Q_DEF_IVAR(_someDouble, d)
Q_DEF_IVAR(_someFloat, f)
Q_END
Q_BEGIN_INSTANCE_METHOD_LIST
Q_DEF_METHOD(calculateArea:, _calcAreaXY, +f+f+f+d+f+f)
Q_DEF_METHOD(dealloc, _dealloc1, +v)
Q_END_INSTANCE_METHOD_LIST
Q_END_CLASS
15. New Code
What benefits?
We can write code on already portable
language as - C++, and some scripting
languages - LUA, PostScript
For implementing system API uses
libraries (mostly C++) which wraps this
work - example dCocoa, QT
17. dCocoa
http://code.google.com/p/dcocoa
LGPL license
Author’s library for cross-platform
implementation business logics for iPhone
and with possibility run or develop this logic
on Windows platform.
18. What give your dCocoa now?
1. Convenient Objective-C mechanisms
emulation. This library writes on C++ and
approximates to Foundation framework with
almost all objc-runtime features.
2. Cross-platform between iPhone <-> Windows
19. 1. Keep meta-information
2. Memory management (retain count,
autorelease pools)
3. Containers (array, set, dictionary) in 2 form
- for standard C++ types and dcocoa types
4. System dependent features (threads, TLS,
timer, run-loop, etc)
5. Other helper classes (such as invocation,
etc)