MawKit is a library built on top of Cocos2d-x offering useful cross-platform utilities to implement platform-specific features like leaderboards, achievements, or in-app purchases quickly.
- Leaderboards and achievements: Game Center (iOS, OS X) / Google Play Games (Android).
- In-app purchases: App Store (iOS, OS X), Google Play (Android).
- Ads: AdMob and AdColony (iOS, Android, not supported on OS X).
- Analytics: Fabric (iOS, Android, OS X) and MixPanel (iOS).
- Mathematical utilities: ranges, random number generator.
- CocoaPods (iOS).
### Android
To do...
-
Run
pod init
inproj.ios_mac
folder to create aPodfile
. [Gif] -
Add the following dependencies for iOS:
pod 'SecureNSUserDefaults'
pod 'Fabric' # Fabric
pod 'Crashlytics' # Fabric
pod 'FBSDKCoreKit' # Facebook
pod 'FBSDKShareKit' # Facebook
pod 'FBSDKShareKit' # Facebook
pod 'Bolts' # Facebook
pod 'Google-Mobile-Ads-SDK' # AdMob
pod 'Mixpanel' # MixPanel
- Add the following dependencies for OS X:
pod 'SecureNSUserDefaults'
pod 'Fabric' # Fabric
pod 'Crashlytics' # Fabric
- Open Xcode project and locate
Build Settings
tab of iOS target: [Gif] - Look for
GCC_PREPROCESSOR_DEFINITIONS
and prepend$(inherited)
for release and debug build. - Look for
LIBRARY_SEARCH_PATHS
, prepend$(inherited)
and append$(PROJECT_DIR)/../Classes/MawKit/Apple/iOS
for release and debug build. - Look for
OTHER_LDFLAGS
and prepend$(inherited)
for release and debug build. - Open Xcode project and locate
Build Settings
tab of OS X target: - Look for
GCC_PREPROCESSOR_DEFINITIONS
and prepend$(inherited)
for release and debug build. - Look for
LIBRARY_SEARCH_PATHS
and prepend$(inherited)
for release and debug build. - Look for
OTHER_LDFLAGS
and prepend$(inherited)
for release and debug build. - Run
pod install
to install pods. - Add
Game Center
andIn-App Purchase
capabilities on both iOS and OS X. [Gif] - Import
MawKit
folder in Xcode. - Remove
MawKit/Android
andMawKit/Example
folders from Xcode project. [Gif] - Check files
.mm
and.a
files inMawKit/Apple/iOS
so they are only build on iOS target. - Check files
.mm
files inMawKit/Apple/OS X
so they are only build on OS X target. - Add
Examples/ios_ids.plist
andExamples/mac_ids.plist
toResources
folder. Don't forget to add it in Xcode so it gets bundled. [Gif] - Add
Examples/MKConstants.h
andExamples/MKUtils.cpp
to project.MKUtils.cpp
should be added to iOS and OS X targets. [Gif] - Set up and fix Fabric for iOS and OS X. This is required as
Fabric.framework
is different for iOS and OS X and Fabric's app does not support multiplatform targets by default. Fix is as easy as getting both versions and storing them at different paths. This can be done with the two following steps: - Follow Fabric instructions to set up Fabric for iOS target. When finished you'll have a
Fabric.framework
folder insideproj.ios_mac
. You'll have to move it toproj.ios_mac/iOS
subfolder and update Xcode project to reflect the change. - Follow Fabric instructions again to set up Fabric for OS X target. When finished you'll have a
Fabric.framework
folder insideproj.ios_mac
. You'll have to move it toproj.ios_mac/osx
subfolder and update Xcode project to reflect the change. - Set up MixPanel for iOS (MixPanel is not supported on OS X):
- Open
proj.ios_mac/ios/AppDelegate.mm
and add in the header#import "Mixpanel.h"
to import MixPanel. - Open
proj.ios_mac/ios/AppDelegate.mm
and add in the header#define MIXPANEL_TOKEN @"YOUR_MIXPANEL_TOKEN_HERE"
to set up MixPanel's token. - Open
proj.ios_mac/ios/AppDelegate.mm
and add this line to- (BOOL)application:didFinishLaunchingWithOptions:
method:[Mixpanel sharedInstanceWithToken:MIXPANEL_TOKEN];
to init MixPanel analytics on startup. - To support Game Center on iOS, convert
_window
ivar into a property inproj.ios_mac/ios/AppDelegate.h
:@property ( nonatomic, strong ) UIWindow *window;
(nothing is required on OS X).
Everything defined and implemented by MawKit can be found on MK
namespace.
### GameKit
To do...
To do...
To do...
auto range = MK::Range<int>(10, 20);
MK::Log::debug(
"Random number in [%d, %d] range: %d",
range.first(),
range.last(),
range.randomInteger()
);