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 initinproj.ios_macfolder to create aPodfile. [Gif] -
Add the following dependencies for iOS:
pod 'SecureNSUserDefaults'pod 'Fabric' # Fabricpod 'Crashlytics' # Fabricpod 'FBSDKCoreKit' # Facebookpod 'FBSDKShareKit' # Facebookpod 'FBSDKShareKit' # Facebookpod 'Bolts' # Facebookpod 'Google-Mobile-Ads-SDK' # AdMobpod 'Mixpanel' # MixPanel
- Add the following dependencies for OS X:
pod 'SecureNSUserDefaults'pod 'Fabric' # Fabricpod 'Crashlytics' # Fabric
- Open Xcode project and locate
Build Settingstab of iOS target: [Gif] - Look for
GCC_PREPROCESSOR_DEFINITIONSand prepend$(inherited)for release and debug build. - Look for
LIBRARY_SEARCH_PATHS, prepend$(inherited)and append$(PROJECT_DIR)/../Classes/MawKit/Apple/iOSfor release and debug build. - Look for
OTHER_LDFLAGSand prepend$(inherited)for release and debug build. - Open Xcode project and locate
Build Settingstab of OS X target: - Look for
GCC_PREPROCESSOR_DEFINITIONSand prepend$(inherited)for release and debug build. - Look for
LIBRARY_SEARCH_PATHSand prepend$(inherited)for release and debug build. - Look for
OTHER_LDFLAGSand prepend$(inherited)for release and debug build. - Run
pod installto install pods. - Add
Game CenterandIn-App Purchasecapabilities on both iOS and OS X. [Gif] - Import
MawKitfolder in Xcode. - Remove
MawKit/AndroidandMawKit/Examplefolders from Xcode project. [Gif] - Check files
.mmand.afiles inMawKit/Apple/iOSso they are only build on iOS target. - Check files
.mmfiles inMawKit/Apple/OS Xso they are only build on OS X target. - Add
Examples/ios_ids.plistandExamples/mac_ids.plisttoResourcesfolder. Don't forget to add it in Xcode so it gets bundled. [Gif] - Add
Examples/MKConstants.handExamples/MKUtils.cppto project.MKUtils.cppshould be added to iOS and OS X targets. [Gif] - Set up and fix Fabric for iOS and OS X. This is required as
Fabric.frameworkis 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.frameworkfolder insideproj.ios_mac. You'll have to move it toproj.ios_mac/iOSsubfolder 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.frameworkfolder insideproj.ios_mac. You'll have to move it toproj.ios_mac/osxsubfolder 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.mmand add in the header#import "Mixpanel.h"to import MixPanel. - Open
proj.ios_mac/ios/AppDelegate.mmand add in the header#define MIXPANEL_TOKEN @"YOUR_MIXPANEL_TOKEN_HERE"to set up MixPanel's token. - Open
proj.ios_mac/ios/AppDelegate.mmand 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
_windowivar 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()
);

