I have an crossplatform implementation of own protocol, data-structures and logic written on Haxe. How I can build and use it in my enterprise-application (with native UI) for iOS and OSX?
With powerful developer tools like Swift and Xcode, every business can build amazing apps. Swift is a powerful, open source language that includes modern features developers love. And Xcode includes everything you need to create, build, and debug apps on iPhone, iPad, Mac, Apple Watch, and Apple TV.
You can learn how to develop apps for Apple platforms for free without enrolling. With just an Apple ID, you can access Xcode, software downloads, documentation, sample code, forums, and Feedback Assistant, as well as test your apps on devices. If you don't already have an Apple ID, you can create one now.
Swift is a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV and Apple Watch.
They are written using iOS Software Development Kit (SDK) and, often, combined with Xcode, using officially supported programming languages, including Swift and Objective-C. Other companies have also created tools that allow for the development of native iOS apps using their respective programming languages.
Actuality: 12.2014; HXCPP-ver.:
3.1.39
~git
.Dependency:
hxcpp
Create a new Haxe-project with main class named HxModule
.
class HxModule
{
public static function main()
{
Sys.println('Hello from HxModule: "${test()}"');
}
@:headerCode
public static function test():Int
{
return 101;
}
}
build.hxml
-main HxModule
-cp src
-lib hxcpp
# this is for Mac OS X:
-D HXCPP_M64
# this is required on Windows. the "d" stands for debug:
#-D ABI=-MTd
--each
# at this phase we create a binary for tests
-cpp out/cpp/module
--next
# at this phase we create a binary for tests
-cpp out/cpp/module
-D static_link
-D actuate
Build: $ haxe buid.hxml
out/cpp/module/include
- you have to fix it to full path;{your-haxelib-repo}/hxcpp/{version}/include
- {here-yours};/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
GNU++11 [-std=gnu++11]
libstdc++ (GNU C++ standard library)
HxModule.a
AppDelegate.m
-> AppDelegate.mm
AppDelegate.mm
:#import "AppDelegate.h"
#import "HxModule.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSLog(@"test: %d", ((int)HxModule_obj::test()));
}
@end
Additionally for autocomplete and better navigation you can add into Xcode-project the reference groups from directories:
include
from output of Haxe;include
from haxelib hxcpp
.At the time when this text was written only one possible issue. It can be solved by editing the file {haxelib:hxcpp}/include/hxcpp.h
. Simply add a few lines at the beginning of the file:
#ifndef HXCPP_H
#define HXCPP_H
// Standard headers ....
// Custom override by @suhinini
#define Class HxcppClass
// Basic mapping from haxe -> c++
typedef int Int;
typedef bool Bool;
// Windows hack
#define NOMINMAX
#ifdef _MSC_VER
#include <typeinfo.h>
namespace hx { typedef ::type_info type_info; }
...
see after // Standard headers ....
.
Example project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With