Skip to content

Commit

Permalink
Merge pull request #18 from bugsnag/release-2.0.0
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
kstenerud authored Feb 23, 2022
2 parents 9e8b31f + 1980a92 commit 9143591
Show file tree
Hide file tree
Showing 55 changed files with 626 additions and 2,500 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
agents:
queue: opensource-mac-cocoa-10.15
queue: opensource-arm-mac-cocoa-12

steps:
- name: 'Run macOS unit tests'
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 2.0.0 (2022-02-23)

This release bumps the native Bugsnag Android and iOS/macOS libraries to their latest major versions (`bugsnag-android` [v5.19.1](https://github.com/bugsnag/bugsnag-android/releases/tag/v5.19.1) and `bugsnag-cocoa` [v6.16.1](https://github.com/bugsnag/bugsnag-cocoa/releases/tag/v6.16.1)) to take advantage of the latest enhancements and bug fixes.

**Please note**, this release contains a breaking change to the setup instructions of the library: it is now initialized as a plugin in the Bugsnag configuration object. For example, in Android:

```diff
- BugsnagCocos2dxPlugin.register();
- Bugsnag.init(this.getApplicationContext());
+ Configuration config = Configuration.load(this);
+ config.addPlugin(new BugsnagCocos2dxPlugin());
+ Bugsnag.start(this, config);
```

In addition, the iOS/macOS library is now distributed as an `xcframework` so it is no longer necessary to have custom header search paths. The distributed `.zip` file now keeps everything inside a top-level "bugsnag" folder.

For more information, please see the updated docs at https://docs.bugsnag.com/platforms/cocos2dx/

## 1.1.0 (2021-12-06)

### Enhancements
Expand Down
12 changes: 4 additions & 8 deletions examples/example-cpp-app/Classes/AppDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include "AppDelegate.h"
#include "HelloWorldScene.h"
#include <BugsnagCocos2dx/Bugsnag.hpp>

// #define USE_AUDIO_ENGINE 1
// #define USE_SIMPLE_AUDIO_ENGINE 1
Expand All @@ -43,12 +42,10 @@ using namespace CocosDenshion;

USING_NS_CC;

using namespace bugsnag;

static cocos2d::Size designResolutionSize = cocos2d::Size(480, 320);
static cocos2d::Size smallResolutionSize = cocos2d::Size(480, 320);
static cocos2d::Size mediumResolutionSize = cocos2d::Size(1024, 768);
static cocos2d::Size largeResolutionSize = cocos2d::Size(2048, 1536);
static cocos2d::Size designResolutionSize = cocos2d::Size(320, 480);
static cocos2d::Size smallResolutionSize = cocos2d::Size(320, 480);
static cocos2d::Size mediumResolutionSize = cocos2d::Size(768, 1024);
static cocos2d::Size largeResolutionSize = cocos2d::Size(1536, 2048);

AppDelegate::AppDelegate()
{
Expand Down Expand Up @@ -81,7 +78,6 @@ static int register_all_packages()
}

bool AppDelegate::applicationDidFinishLaunching() {
Bugsnag::leaveBreadcrumb("finished launching", State, {{"foo", "bar"}});
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
Expand Down
107 changes: 71 additions & 36 deletions examples/example-cpp-app/Classes/HelloWorldScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@

#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
#include <BugsnagCocos2dx/Bugsnag.hpp>

USING_NS_CC;

using namespace bugsnag;

Scene* HelloWorld::createScene()
{
return HelloWorld::create();
Expand Down Expand Up @@ -75,60 +78,92 @@ bool HelloWorld::init()
closeItem->setPosition(Vec2(x,y));
}

// create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);

/////////////////////////////
// 3. add your codes below...

// add a label shows "Hello World"
// create and initialize a label
// Bugsnag test code

auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
if (label == nullptr)
{
problemLoading("'fonts/Marker Felt.ttf'");
}
else
{
// position the label on the center of the screen
label->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
menu = Menu::create(closeItem, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);

// add the label as a child to this layer
this->addChild(label, 1);
}
topMid = Vec2(visibleSize.width/2 + origin.x, visibleSize.height + origin.y - 20);

// add "HelloWorld" splash screen"
auto sprite = Sprite::create("HelloWorld.png");
if (sprite == nullptr)
{
problemLoading("'HelloWorld.png'");
}
else
{
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
addMenuItem("Close", CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
addMenuItem("Unhandled", CC_CALLBACK_1(HelloWorld::unhandledCallback, this));
addMenuItem("Handled", CC_CALLBACK_1(HelloWorld::handledCallback, this));
addMenuItem("Metadata (Single)", CC_CALLBACK_1(HelloWorld::addMetadataSingleCallback, this));
addMenuItem("Metadata (Section)", CC_CALLBACK_1(HelloWorld::addMetadataSectionCallback, this));
addMenuItem("Leave Breadcrumb", CC_CALLBACK_1(HelloWorld::leaveBreadcrumbCallback, this));
addMenuItem("Set User", CC_CALLBACK_1(HelloWorld::setUserCallback, this));
addMenuItem("Start Session", CC_CALLBACK_1(HelloWorld::startSessionCallback, this));
addMenuItem("Pause Session", CC_CALLBACK_1(HelloWorld::pauseSessionCallback, this));
addMenuItem("Resume Session", CC_CALLBACK_1(HelloWorld::resumeSessionCallback, this));

// add the sprite as a child to this layer
this->addChild(sprite, 0);
}
return true;
}


void HelloWorld::menuCloseCallback(Ref* pSender)
{
abort(); // Crash the app
printf("HelloWorld::menuCloseCallback\n");

//Close the cocos2d-x game scene and quit the application
Director::getInstance()->end();

/*To navigate back to native iOS screen(if present) without quitting the application ,do not use Director::getInstance()->end() as given above,instead trigger a custom event created in RootViewController.mm as below*/

//EventCustom customEndEvent("game_scene_close_event");
//_eventDispatcher->dispatchEvent(&customEndEvent);
}

void HelloWorld::addMenuItem(const string text, const ccMenuCallback& callback) {
auto mi = MenuItemLabel::create(Label::createWithTTF(text, "fonts/arial.ttf", fontSize), callback);
mi->setAnchorPoint(Vec2(0.5, 1));
mi->setPosition(Vec2(topMid.x, topMid.y - menuItemHeight * menuIndex));
menu->addChild(mi);
menuIndex++;
}

void HelloWorld::unhandledCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::unhandledCallback\n");
*badPointer = 1;
}

void HelloWorld::handledCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::handledCallback\n");
Bugsnag::notify("A handled error", "Something broke!");
}

void HelloWorld::addMetadataSingleCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::addMetadataSingleCallback\n");
Bugsnag::addMetadata("single", "a section", "a value");
}

void HelloWorld::addMetadataSectionCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::addMetadataSectionCallback\n");
Bugsnag::addMetadata("multi", {{"a", "1"}, {"b", "2"}});
}

void HelloWorld::leaveBreadcrumbCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::leaveBreadcrumbCallback\n");
Bugsnag::leaveBreadcrumb("Leaving breadcrumb", State, {{"foo", "bar"}});
}

void HelloWorld::setUserCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::setUserCallback\n");
Bugsnag::setUser("myuser", "[email protected]", "My User");
}

void HelloWorld::startSessionCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::startSessionCallback\n");
Bugsnag::startSession();
}

void HelloWorld::pauseSessionCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::pauseSessionCallback\n");
Bugsnag::pauseSession();
}

void HelloWorld::resumeSessionCallback(cocos2d::Ref* pSender) {
printf("HelloWorld::resumeSessionCallback\n");
printf("Bugsnag::resumeSession: %d\n", Bugsnag::resumeSession());
}
28 changes: 24 additions & 4 deletions examples/example-cpp-app/Classes/HelloWorldScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,36 @@

class HelloWorld : public cocos2d::Scene
{
private:
const int fontSize = 22;
const int menuItemHeight = 26;

cocos2d::Menu *menu;
cocos2d::Vec2 topMid;
int menuIndex = 0;

void addMenuItem(const std::string text, const cocos2d::ccMenuCallback& callback);

void menuCloseCallback(cocos2d::Ref* pSender);
void unhandledCallback(cocos2d::Ref* pSender);
void handledCallback(cocos2d::Ref* pSender);
void addMetadataSingleCallback(cocos2d::Ref* pSender);
void addMetadataSectionCallback(cocos2d::Ref* pSender);
void leaveBreadcrumbCallback(cocos2d::Ref* pSender);
void setUserCallback(cocos2d::Ref* pSender);
void startSessionCallback(cocos2d::Ref* pSender);
void pauseSessionCallback(cocos2d::Ref* pSender);
void resumeSessionCallback(cocos2d::Ref* pSender);

public:
static cocos2d::Scene* createScene();

virtual bool init();

// a selector callback
void menuCloseCallback(cocos2d::Ref* pSender);


// implement the "static create()" method manually
CREATE_FUNC(HelloWorld);

char *badPointer = NULL;
};

#endif // __HELLOWORLD_SCENE_H__
8 changes: 8 additions & 0 deletions examples/example-cpp-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugsnag Cocos2d-x Example Project
=================================

This is a standard cocos2d-x project built under cocos2d-x 3.17.2 using the command line `cocos new -l cpp example-cpp-app`, and then following the [bugsnag installation instructions](https://docs.bugsnag.com/platforms/cocos2dx/).

**Note**: The `bugsnag` directory is actually a symlink, and so you must first run `./scripts/export-package.sh` from the root of bugsnag-cocos2dx to generate the files needed to compile the example project (so that you're always building the example app using the current commit of bugsnag-cocos2dx). These files are what you'd normally download as a zip archive from the [releases page](https://github.com/bugsnag/bugsnag-cocos2dx/releases/latest).

Projects in `proj.android` and `proj.ios_mac` can be opened, built, and run in their respective IDEs.
1 change: 1 addition & 0 deletions examples/example-cpp-app/bugsnag
38 changes: 0 additions & 38 deletions examples/example-cpp-app/bugsnag/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 9143591

Please sign in to comment.