Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ably/ably-cocoa into 945-cocoa-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
tcard committed Feb 3, 2020
2 parents 1ae21f7 + 91f7891 commit 440b371
Show file tree
Hide file tree
Showing 34 changed files with 850 additions and 479 deletions.
4 changes: 2 additions & 2 deletions Ably.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Pod::Spec.new do |s|
s.private_header_files = 'Source/*+Private.h', 'Source/Private/*.h'
s.module_map = 'Source/Ably.modulemap'
s.dependency 'SocketRocketAblyFork', '0.5.2-ably-4'
s.dependency 'MsgPackAblyFork', '0.2.0-ably-1'
s.dependency 'KSCrashAblyFork', '1.15.20-ably-1'
s.dependency 'KSCrashAblyFork', '1.15.20-ably-5'
s.dependency 'msgpack', '0.3.1'
s.dependency 'ULID', '1.1.0'
s.dependency 'SAMKeychain', '1.5.3'
end
45 changes: 23 additions & 22 deletions Ably.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
# Change Log

## [1.1.18](https://github.com/ably/ably-cocoa/tree/HEAD)
[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.1.17...1.1.18)

**Fixed bugs:**

- Result of internet-up.ably-realtime.com is ignored [\#952](https://github.com/ably/ably-cocoa/issues/952)
- Realtime suspended connection retrial using wrong timeout [\#913](https://github.com/ably/ably-cocoa/issues/913)

**Closed issues:**

- Remove develop branch [\#969](https://github.com/ably/ably-cocoa/issues/969)
- Flaky test: RTP2f \(incoming LEAVE while SYNCing\) [\#938](https://github.com/ably/ably-cocoa/issues/938)
- Flaky test: RTN17\* \(fallback hosts\) [\#931](https://github.com/ably/ably-cocoa/issues/931)

**Merged pull requests:**

- Remove redundant direct calls to push delegate callbacks [\#975](https://github.com/ably/ably-cocoa/pull/975) ([tcard](https://github.com/tcard))
- Simplify hooks on RTP2f test [\#963](https://github.com/ably/ably-cocoa/pull/963) ([tcard](https://github.com/tcard))
- Fix internet-up.ably-realtime.com checks [\#961](https://github.com/ably/ably-cocoa/pull/961) ([tcard](https://github.com/tcard))
- Fix connection SUSPENDED timeout [\#917](https://github.com/ably/ably-cocoa/pull/917) ([ricardopereira](https://github.com/ricardopereira))

## [1.1.17](https://github.com/ably/ably-cocoa/tree/1.1.17)
[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.1.16...1.1.17)

**Merged pull requests:**

- Remove push state machine singleton [\#972](https://github.com/ably/ably-cocoa/pull/972) ([tcard](https://github.com/tcard))
- Add clarification to release process: document --since-tag effects [\#971](https://github.com/ably/ably-cocoa/pull/971) ([tcard](https://github.com/tcard))

## [1.1.16](https://github.com/ably/ably-cocoa/tree/1.1.16)
[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.1.15...1.1.16)

**Fixed bugs:**

- Cannot compile Objective-C++ file if Ably headers included [\#964](https://github.com/ably/ably-cocoa/issues/964)
- Realtime Channel endless loop: suspended \> attached \> suspended [\#881](https://github.com/ably/ably-cocoa/issues/881)

**Closed issues:**

- Flaky test: RTN5 \(basic operations should work simultaneously\) [\#934](https://github.com/ably/ably-cocoa/issues/934)

**Merged pull requests:**

- If waiting for push device details and got them persisted, re-emit them. [\#967](https://github.com/ably/ably-cocoa/pull/967) ([tcard](https://github.com/tcard))
- Update msgpack \(fix CocoaPod warnings\) [\#962](https://github.com/ably/ably-cocoa/pull/962) ([ricardopereira](https://github.com/ricardopereira))
- Alleviate RTN5 flakiness [\#957](https://github.com/ably/ably-cocoa/pull/957) ([tcard](https://github.com/tcard))
- Fix SUSPENDED channel reattach [\#909](https://github.com/ably/ably-cocoa/pull/909) ([ricardopereira](https://github.com/ricardopereira))

## [1.1.15](https://github.com/ably/ably-cocoa/tree/1.1.15) (2019-12-23)
[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.1.14...1.1.15)

**Merged pull requests:**

- KSCrash fork has been renamed to KSCrashAblyFork
[\#955](https://github.com/ably/ably-cocoa/pull/955) ([ricardopereira](https://github.com/ricardopereira))
- Update msgpack to v0.3 [\#951](https://github.com/ably/ably-cocoa/pull/951) ([ricardopereira](https://github.com/ricardopereira))
- Simplify random fallback host selection [\#953](https://github.com/ably/ably-cocoa/pull/953) ([tcard](https://github.com/tcard))

## [1.1.14](https://github.com/ably/ably-cocoa/tree/1.1.14) (2019-12-16)
[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.1.13...1.1.14)

Expand Down
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github "ably-forks/SocketRocket" == 0.5.2-ably-4
github "ably-forks/msgpack-objective-C" == 0.2.0-ably-1
github "ably-forks/KSCrash" == 1.15.20-ably-1
github "ably-forks/KSCrash" == 1.15.20-ably-5
github "rvi/msgpack-objective-C" == 0.3.1
github "whitesmith/ulid" == 1.1.0
github "soffes/SAMKeychain" == 1.5.3
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github "Quick/Nimble" "v8.0.1"
github "Quick/Quick" "v2.0.0"
github "SwiftyJSON/SwiftyJSON" "4.3.0"
github "ably-forks/KSCrash" "1.15.20-ably-1"
github "ably-forks/KSCrash" "1.15.20-ably-5"
github "ably-forks/SocketRocket" "0.5.2-ably-4"
github "ably-forks/msgpack-objective-C" "0.2.0-ably-1"
github "rvi/msgpack-objective-C" "0.3.1"
github "soffes/SAMKeychain" "v1.5.3"
github "whitesmith/Aspects" "1.4.2-ws1"
github "whitesmith/ulid" "1.1.0"
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ As of version `1.1.0` this library based on the 1.1 library specification. It im
- updated push API and push device authentication;
- support for enforcement of the `maxMessageSize` attribute

Other minor features and bugfixes are included, as listed in the [changelog](CHANGELOG.md#1113-2019-12-09).
Other minor features and bugfixes are included, as listed in the [changelog](CHANGELOG.md#1115-2019-12-23).

##### macOS & tvOS

Expand Down Expand Up @@ -96,6 +96,10 @@ This client library is currently *not compatible* with some of the Ably features
| [Remember fallback host during failures](https://ably.io/documentation/realtime/usage#client-options) |
| [ErrorInfo URLs to help debug issues](https://ably.io/documentation/realtime/types#error-info) |

### Concurrent push-receiving Ably instances

Only one instance of `ARTRest` or `ARTRealtime` at a time must be [activated for receiving push notifications](https://www.ably.io/documentation/general/push/activate-subscribe). Having more than one activated instance at a time may have unexpected consequences.

## Documentation

Visit [ably.io/documentation](https://www.ably.io/documentation) for a complete API reference and more examples.
Expand Down Expand Up @@ -130,7 +134,7 @@ If you see, for example, a `dyld: Library not loaded: @rpath/SocketRocketAblyFor

### Manual installation

1. Get the code from GitHub [from the release page](https://github.com/ably/ably-cocoa/releases/tag/1.1.14), or clone it to get the latest, unstable and possibly underdocumented version: `git clone [email protected]:ably/ably-cocoa.git`
1. Get the code from GitHub [from the release page](https://github.com/ably/ably-cocoa/releases/tag/1.1.18), or clone it to get the latest, unstable and possibly underdocumented version: `git clone [email protected]:ably/ably-cocoa.git`
2. Drag the directory `ably-cocoa/ably-cocoa` into your project as a group.
3. Ably depends on our [SocketRocket Fork](https://github.com/ably-forks/SocketRocket) 0.5.2; get it [from the releases page](https://github.com/ably-forks/SocketRocket/releases/tag/0.5.2-ably-2) and follow [its manual installation instructions](https://github.com/ably-forks/SocketRocket/#installing).
4. Ably also depends on our [MessagePack Fork](https://github.com/ably-forks/msgpack-objective-C) 0.2.0; get it [from the releases page](https://github.com/ably-forks/msgpack-objective-C/releases/tag/0.2.0-ably-1) and link it into your project.
Expand Down Expand Up @@ -638,16 +642,18 @@ You can also view the [community reported Github issues](https://github.com/ably

## Contributing

In this repo the `master` branch contains the latest stable version of the Ably SDK. Pushing changes to the `master` branch is locked. All the development (bug fixing, feature implementation, etc.) is done against the `develop` branch, which you should branch from whenever you'd like to make modifications. Here's the steps to follow when contributing to this repo.
In this repository the `master` branch contains the latest development version of the Ably SDK. All development (bug fixing, feature implementation, etc.) is done against the `master` branch, which you should branch from whenever you'd like to make modifications. Here's the steps to follow when contributing to this repository.

1. Fork it
2. Setup or update your machine by running `make setup|update`
3. Create your feature branch from `develop` (`git checkout develop && git checkout -b my-new-feature-branch`)
3. Create your feature branch from `master` (`git checkout master && git checkout -b my-new-feature-branch`)
4. Commit your changes (`git commit -am 'Add some feature'`)
5. Ensure you have added suitable tests and the test suite is passing
6. Push to the branch (`git push origin my-new-feature-branch`)
7. Create a new Pull Request

Releases of the Ably SDK built by the sources in this repository are tagged with their [semantic version](http://semver.org/) numbers.

## Running tests

To run tests use `make test_[iOS|tvOS|macOS]`.
Expand All @@ -656,21 +662,30 @@ Note: [Fastlane](https://fastlane.tools) should be installed.

## Release Process

This library uses [semantic versioning](http://semver.org/). For each release, the following needs to be done:
For each release, the following needs to be done:

* Create a new branch `release/x.x.x` (where `x.x.x` is the new version number) from the `develop` branch
* Run `make bump_[major|minor|patch]` to bump the new version number (creates a Git commit and tag)
* Create a new branch `release/x.x.x` (where `x.x.x` is the new version number) from the `master` branch
* Run `make bump_[major|minor|patch]` to bump the new version number (creates a Git commit)
* Run [`github_changelog_generator`](https://github.com/github-changelog-generator/github-changelog-generator) to automate the update of the [CHANGELOG](./CHANGELOG.md). This may require some manual intervention, both in terms of how the command is run and how the change log file is modified. Your mileage may vary:
* The command you will need to run will look something like this: `github_changelog_generator -u ably -p ably-cocoa --since-tag 1.1.14`
* The command you will need to run will look something like this: `github_changelog_generator -u ably -p ably-cocoa --since-tag 1.1.18`
- `--since-tag` will remove old releases from the `CHANGELOG.md`. You may need to add them back.
* Change the "Unreleased" heading and link with the current version number such as `v1.0.0`
* Also ensure that the "Full Changelog" link points to the new version tag instead of the `HEAD`
* Commit this change: `git add CHANGELOG.md && git commit -m "Update change log."`
* Push both commits to origin: `git push -u origin release/x.x.x`
<<<<<<< HEAD
* Push the tag created by the bump script earlier to origin: `git push origin x.x.x`
* Make a pull request against `develop` and await approval of reviewer(s).
* Once approved, merge the PR. If you do this from Github's web interface then use the "Rebase and merge" option to retain the relationship with the tag.
* Fast-forward the master branch: `git checkout master && git merge --ff-only develop && git push origin master`
* Add to [releases](https://github.com/ably/ably-cocoa/releases) - refer to previous releases for release notes format
=======
* Make a pull request against `master` and await approval of reviewer(s).
* Once approved and/or any additional commits have been added, merge the PR. If you do this from Github's web interface then use the "Rebase and merge" option to retain the relationship with the tag.
* Create a tag for this version number: `git checkout master && git pull && git tag x.x.x`
* Push the tag: `git push origin x.x.x`
* Add to [releases](https://github.com/ably/ably-ios/releases) - refer to previous releases for release notes format
>>>>>>> 91f7891d6a5fb06b15dfadb8e924bc1687a4f24e
* Release an update for CocoaPods: `pod trunk push Ably.podspec` (you can, optionally, first run `pod lib lint` to verify that the trunk push should succeed). Details on this command, as well as instructions for adding other contributors as maintainers, are at [Getting setup with Trunk](https://guides.cocoapods.org/making/getting-setup-with-trunk.html) in the [CocoaPods Guides](https://guides.cocoapods.org/).
* Generate the prebuilt framework for Carthage (`carthage build --no-skip-current --archive`) and attach the file generated by that step to the release: `Ably.framework.zip`
* Test the integration of the library in a Xcode project using Carthage and CocoaPods using the [installation guide](https://github.com/ably/ably-cocoa#installation-guide).
Expand Down
1 change: 0 additions & 1 deletion Scripts/set-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ git add README.md
git add Spec/RealtimeClientConnection.swift
git add Version.xcconfig
git commit -m "Bump version to $NEW_VERSION."
git tag "$NEW_VERSION"

2 changes: 1 addition & 1 deletion Source/ARTFallback+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

NS_ASSUME_NONNULL_BEGIN

extern int (^ARTFallback_getRandomHostIndex)(int count);
extern void (^ARTFallback_shuffleArray)(NSMutableArray *);

@interface ARTFallback ()

Expand Down
16 changes: 6 additions & 10 deletions Source/ARTFallback.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#import "ARTHttp.h"
#import "ARTClientOptions.h"

int (^ARTFallback_getRandomHostIndex)(int count) = ^int(int count) {
return arc4random() % count;
void (^ARTFallback_shuffleArray)(NSMutableArray *) = ^void(NSMutableArray *a) {
for (NSUInteger i = a.count; i > 1; i--) {
[a exchangeObjectAtIndex:i - 1 withObjectAtIndex:arc4random_uniform((u_int32_t)i)];
}
};

@interface ARTFallback ()
Expand All @@ -29,14 +31,8 @@ - (instancetype)initWithFallbackHosts:(nullable NSArray<NSString *> *)fallbackHo
if (fallbackHosts != nil && fallbackHosts.count == 0) {
return nil;
}
self.hosts = [NSMutableArray array];
NSMutableArray * hostArray = [[NSMutableArray alloc] initWithArray: fallbackHosts ? fallbackHosts : [ARTDefault fallbackHosts]];
size_t count = [hostArray count];
for (int i=0; i <count; i++) {
int randomIndex = ARTFallback_getRandomHostIndex((int)[hostArray count]);
[self.hosts addObject:[hostArray objectAtIndex:randomIndex]];
[hostArray removeObjectAtIndex:randomIndex];
}
self.hosts = [[NSMutableArray alloc] initWithArray: fallbackHosts ? fallbackHosts : [ARTDefault fallbackHosts]];
ARTFallback_shuffleArray(self.hosts);
}
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTHttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface ARTHttp : NSObject<ARTHTTPExecutor>

+ (void)setURLSessionClass:(Class)class;
+ (void)setURLSessionClass:(Class)urlSessionClass;

- (instancetype)init UNAVAILABLE_ATTRIBUTE;
- (instancetype)init:(dispatch_queue_t)queue logger:(ARTLog *)logger;
Expand Down
4 changes: 2 additions & 2 deletions Source/ARTHttp.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ @implementation ARTHttp {
_Nullable dispatch_queue_t _queue;
}

+ (void)setURLSessionClass:(Class)class {
configuredUrlSessionClass = class;
+ (void)setURLSessionClass:(const Class)urlSessionClass {
configuredUrlSessionClass = urlSessionClass;
}

- (instancetype)init:(dispatch_queue_t)queue logger:(ARTLog *)logger {
Expand Down
5 changes: 0 additions & 5 deletions Source/ARTMsgPackEncoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
//

#import "ARTMsgPackEncoder.h"
#if COCOAPODS && !TEST_SUITE
#import <MsgPackAblyFork/MessagePack.h>
#else
// Carthage
#import <msgpack/MessagePack.h>
#endif

@implementation ARTMsgPackEncoder

Expand Down
1 change: 1 addition & 0 deletions Source/ARTPresenceMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)onceSyncFails:(void (^)(ARTErrorInfo *))callback;

- (void)internalAdd:(ARTPresenceMessage *)message;
- (void)internalAdd:(ARTPresenceMessage *)message withSessionId:(NSUInteger)sessionId;

@end

Expand Down
1 change: 0 additions & 1 deletion Source/ARTPush+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ NS_ASSUME_NONNULL_BEGIN

#if TARGET_OS_IOS
- (ARTPushActivationStateMachine *)activationMachine;
- (void)resetActivationStateMachineSingleton;
#endif

@end
Expand Down
52 changes: 18 additions & 34 deletions Source/ARTPush.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ - (void)deactivate {
@implementation ARTPushInternal {
ARTRestInternal *_rest;
ARTLog *_logger;
ARTPushActivationStateMachine *_activationMachine;
}

- (instancetype)init:(ARTRestInternal *)rest {
if (self = [super init]) {
_rest = rest;
_logger = [rest logger];
_admin = [[ARTPushAdminInternal alloc] initWithRest:rest];
_activationMachine = nil;
}
return self;
}
Expand All @@ -98,21 +100,21 @@ - (dispatch_queue_t)queue {

#if TARGET_OS_IOS

// Store address of once_token to access it in debug function.
static dispatch_once_t *activationMachine_once_token;

- (ARTPushActivationStateMachine *)activationMachine {
static dispatch_once_t once;
activationMachine_once_token = &once;
static id activationMachineInstance;
dispatch_once(&once, ^{
activationMachineInstance = [[ARTPushActivationStateMachine alloc] init:self->_rest];
});
return activationMachineInstance;
}

- (void)resetActivationStateMachineSingleton {
if (activationMachine_once_token) *activationMachine_once_token = 0;
if (_activationMachine == nil) {
// -[UIApplication delegate] is an UI API call, so needs to be called from main thread.
__block id delegate = nil;
if ([NSThread isMainThread]) {
delegate = UIApplication.sharedApplication.delegate;
} else {
dispatch_sync(dispatch_get_main_queue(), ^{
delegate = UIApplication.sharedApplication.delegate;
});
}

_activationMachine = [[ARTPushActivationStateMachine alloc] init:self->_rest delegate:delegate];
}
return _activationMachine;
}

+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceTokenData restInternal:(ARTRestInternal *)rest {
Expand Down Expand Up @@ -169,29 +171,11 @@ + (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error rest:(
}

- (void)activate {
if (!self.activationMachine.delegate) {
dispatch_async(dispatch_get_main_queue(), ^{
// -[UIApplication delegate] is an UI API call
self.activationMachine.delegate = UIApplication.sharedApplication.delegate;
[self.activationMachine sendEvent:[ARTPushActivationEventCalledActivate new]];
});
}
else {
[self.activationMachine sendEvent:[ARTPushActivationEventCalledActivate new]];
}
[self.activationMachine sendEvent:[ARTPushActivationEventCalledActivate new]];
}

- (void)deactivate {
if (!self.activationMachine.delegate) {
dispatch_async(dispatch_get_main_queue(), ^{
// -[UIApplication delegate] is an UI API call
self.activationMachine.delegate = UIApplication.sharedApplication.delegate;
[self.activationMachine sendEvent:[ARTPushActivationEventCalledDeactivate new]];
});
}
else {
[self.activationMachine sendEvent:[ARTPushActivationEventCalledDeactivate new]];
}
[self.activationMachine sendEvent:[ARTPushActivationEventCalledDeactivate new]];
}

#endif
Expand Down
1 change: 1 addition & 0 deletions Source/ARTPushActivationStateMachine+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern NSString *const ARTPushActivationPendingEventsKey;

@property (nonatomic, strong) ARTRestInternal *rest;
- (instancetype)init:(ARTRestInternal *)rest;
- (instancetype)init:(ARTRestInternal *)rest delegate:(nullable id)delegate;

@property (weak, nonatomic) id delegate; // weak because delegates outlive their counterpart
@property (nonatomic, copy, nullable) void (^transitions)(ARTPushActivationEvent *event, ARTPushActivationState *from, ARTPushActivationState *to);
Expand Down
Loading

0 comments on commit 440b371

Please sign in to comment.