Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 0 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ jobs:
with:
ruby-version: 3.2.2
bundler-cache: true
- name: Setup CocoaPods
run: gem install cocoapods
- name: Publish to CocoaPods Trunk
uses: ./.github/.release/actions/actions/services/cocoapods
with:
token: ${{ secrets.GH_TOKEN }}
cocoapods-token: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
- name: Create Release
uses: ./.github/.release/actions/actions/services/github-release
with:
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/run-live-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Live Integration Tests

on:
workflow_dispatch:
schedule:
# Run every two weeks on Saturday at midnight UTC (1st and 3rd Saturday of each month)
- cron: '0 0 1-7 * 6'
- cron: '0 0 15-21 * 6'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
TESTS_PAM_SUBSCRIBE_KEY: ${{ secrets.SDK_PAM_SUB_KEY }}
TESTS_PAM_PUBLISH_KEY: ${{ secrets.SDK_PAM_PUB_KEY }}
TESTS_SUBSCRIBE_KEY: ${{ secrets.SDK_SUB_KEY }}
TESTS_PUBLISH_KEY: ${{ secrets.SDK_PUB_KEY }}
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
LC_ALL: en_US.UTF-8
LC_CTYPE: en_US.UTF-8

jobs:
live-tests:
name: Live integration tests
runs-on:
group: organization/macos-gh
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Checkout actions
uses: actions/checkout@v4
with:
repository: pubnub/client-engineering-deployment-tools
ref: v1
token: ${{ secrets.GH_TOKEN }}
path: .github/.release/actions
- name: Setup Ruby 3.2.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: false
- name: Setup CocoaPods
run: gem install cocoapods
- name: Cache installed Pods
uses: actions/cache@v4
with:
path: Tests/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Tests/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Pre-load simulators list
run: xcrun simctl list -j
- name: Install dependencies
run: |
gem install xcpretty -v 0.3.0
cd ./Tests && pod install && cd ..
- name: Configure test environment
run: |
./Tests/Support\ Files/Scripts/create-configuration.sh
- name: Run iOS live integration tests
run: |
./Tests/Support\ Files/Scripts/tests-runner.sh ios integration 1
- name: Cancel workflow runs for commit on error
if: failure()
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
3 changes: 3 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
- name: Configure test environment
run: |
./Tests/Support\ Files/Scripts/create-configuration.sh
- name: Run ${{ matrix.environment }} unit tests
run: |
./Tests/Support\ Files/Scripts/tests-runner.sh $(echo ${{ matrix.environment }} | tr '[:upper:]' '[:lower:]') unit 1
- name: Run ${{ matrix.environment }} integration tests
run: |
./Tests/Support\ Files/Scripts/tests-runner.sh $(echo ${{ matrix.environment }} | tr '[:upper:]' '[:lower:]') mocked 1
Expand Down
56 changes: 17 additions & 39 deletions Framework/scripts/export_for_spm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
WORKING_DIRECTORY="$(pwd)"
SOURCES_FOLDER="$1"
[[ "$2" == public-only ]] && PUBLIC_ONLY=1 || PUBLIC_ONLY=0
UMBRELLA_HEADER="${3:-$SOURCES_FOLDER/PubNub.h}"
PRIVATE_HEADERS=()
PUBLIC_HEADERS=()
ALL_HEADERS=()
Expand Down Expand Up @@ -62,35 +63,28 @@ gather_imported_headers_in_file() {
}


regex=".*Private.h"
# Retrieve list of all headers.
while IFS='' read -r HEADER_PATH; do
RELATIVE_PATH="${HEADER_PATH#"$WORKING_DIRECTORY/$SOURCES_FOLDER/"}"
FILENAME="$(echo "$RELATIVE_PATH" | rev | cut -d/ -f1 | rev)"
FILES+=( "$FILENAME:$RELATIVE_PATH" )
ALL_HEADERS+=("$RELATIVE_PATH")
[[ "$RELATIVE_PATH" =~ $regex ]] && PRIVATE_HEADERS+=("$RELATIVE_PATH")
done <<< "$(find "$WORKING_DIRECTORY/$SOURCES_FOLDER" -path "*/include" -prune -o -type f ! \( -name "*.m" -o -name ".DS_Store" \) -print)"

if [[ $PUBLIC_ONLY == 1 ]]; then
regex=".*Private.h"
# Retrieve list of potentially public headers.
while IFS='' read -r HEADER_PATH; do
RELATIVE_PATH="${HEADER_PATH#"$WORKING_DIRECTORY/$SOURCES_FOLDER/"}"
FILENAME="$(echo "$RELATIVE_PATH" | rev | cut -d/ -f1 | rev)"
FILES+=( "$FILENAME:$RELATIVE_PATH" )
ALL_HEADERS+=("$RELATIVE_PATH")
[[ "$RELATIVE_PATH" =~ $regex ]] && PRIVATE_HEADERS+=("$RELATIVE_PATH")
done <<< "$(find "$WORKING_DIRECTORY/$SOURCES_FOLDER" -type f ! \( -name "*.m" -o -name ".DS_Store" -o -name "*Private.h" \))"

# Scan for public headers
gather_imported_headers_in_file "$SOURCES_FOLDER/PubNub.h"
else
regex=".*Private.h"
# Retrieve list of all headers.
while IFS='' read -r HEADER_PATH; do
RELATIVE_PATH="${HEADER_PATH#"$WORKING_DIRECTORY/$SOURCES_FOLDER/"}"
FILENAME="$(echo "$RELATIVE_PATH" | rev | cut -d/ -f1 | rev)"
FILES+=( "$FILENAME:$RELATIVE_PATH" )
ALL_HEADERS+=("$RELATIVE_PATH")
[[ "$RELATIVE_PATH" =~ $regex ]] && PRIVATE_HEADERS+=("$RELATIVE_PATH")
done <<< "$(find "$WORKING_DIRECTORY/$SOURCES_FOLDER" -type f ! \( -name "*.m" -o -name ".DS_Store" \))"
# Scan umbrella header to discover public headers.
gather_imported_headers_in_file "$UMBRELLA_HEADER"
fi


# Clean up previous include directory if it exists.
[[ -d "$1/include" ]] && rm -rf "$1/include"

# Create required folders structure.
! [[ -d "$WORKING_DIRECTORY/Sources" ]] && mkdir -p "$WORKING_DIRECTORY/Sources"
! [[ -d "$1/include" ]] && mkdir -p "$1/include/PubNub"
mkdir -p "$1/include/PubNub"


# Create symbolic link to Objective-C SDK source files.
Expand All @@ -114,20 +108,4 @@ else
done
fi

[[ -e "PubNub.h" ]] && rm "PubNub.h"

cd "../"

if [[ $PUBLIC_ONLY == 1 ]]; then
for HEADER_PATH in "${PUBLIC_HEADERS[@]}"; do
FILENAME="$(echo "$HEADER_PATH" | rev | cut -d/ -f1 | rev)"
! [[ -e "$FILENAME" ]] && ln -s "../$HEADER_PATH"
done
else
for HEADER_PATH in "${ALL_HEADERS[@]}"; do
FILENAME="$(echo "$HEADER_PATH" | rev | cut -d/ -f1 | rev)"
! [[ -e "$FILENAME" ]] && ln -s "../$HEADER_PATH" "$FILENAME"
done
fi

[[ -e "PubNub.h" ]] && rm "PubNub.h"
93 changes: 92 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,98 @@ let package = Package(
name: "PubNub",
dependencies: [],
path: "Sources/PubNub",
resources: [.copy("../../Framework/PubNub/PrivacyInfo.xcprivacy")]
resources: [.copy("../../Framework/PubNub/PrivacyInfo.xcprivacy")],
cSettings: [
.headerSearchPath("."),
.headerSearchPath("Core"),
.headerSearchPath("Data"),
.headerSearchPath("Data/Builders"),
.headerSearchPath("Data/Builders/API Call/APNS"),
.headerSearchPath("Data/Builders/API Call/Actions/Message"),
.headerSearchPath("Data/Builders/API Call/Files"),
.headerSearchPath("Data/Builders/API Call/History"),
.headerSearchPath("Data/Builders/API Call/Objects"),
.headerSearchPath("Data/Builders/API Call/Objects/Channel"),
.headerSearchPath("Data/Builders/API Call/Objects/Membership"),
.headerSearchPath("Data/Builders/API Call/Objects/UUID"),
.headerSearchPath("Data/Builders/API Call/Presence"),
.headerSearchPath("Data/Builders/API Call/Publish"),
.headerSearchPath("Data/Builders/API Call/State"),
.headerSearchPath("Data/Builders/API Call/Stream"),
.headerSearchPath("Data/Builders/API Call/Subscribe"),
.headerSearchPath("Data/Builders/API Call/Time"),
.headerSearchPath("Data/Managers"),
.headerSearchPath("Data/Models"),
.headerSearchPath("Data/Service Objects"),
.headerSearchPath("Data/Service Objects/App Context"),
.headerSearchPath("Data/Service Objects/Channel Groups"),
.headerSearchPath("Data/Service Objects/Error"),
.headerSearchPath("Data/Service Objects/File Sharing"),
.headerSearchPath("Data/Service Objects/Message Persistence"),
.headerSearchPath("Data/Service Objects/Message Reaction"),
.headerSearchPath("Data/Service Objects/Presence"),
.headerSearchPath("Data/Service Objects/Publish"),
.headerSearchPath("Data/Service Objects/Push Notification"),
.headerSearchPath("Data/Service Objects/Signal"),
.headerSearchPath("Data/Service Objects/Subscribe"),
.headerSearchPath("Data/Service Objects/Time"),
.headerSearchPath("Data/Transport"),
.headerSearchPath("Misc"),
.headerSearchPath("Misc/Categories"),
.headerSearchPath("Misc/Helpers"),
.headerSearchPath("Misc/Helpers/Notifications Payload"),
.headerSearchPath("Misc/Helpers/Notifications Payload/APNS"),
.headerSearchPath("Misc/Logger/Additional/Console"),
.headerSearchPath("Misc/Logger/Additional/File"),
.headerSearchPath("Misc/Logger/Core"),
.headerSearchPath("Misc/Logger/Data"),
.headerSearchPath("Misc/Protocols"),
.headerSearchPath("Misc/Protocols/Serializer/JSON"),
.headerSearchPath("Misc/Protocols/Serializer/Object"),
.headerSearchPath("Modules/Crypto"),
.headerSearchPath("Modules/Crypto/Cryptors/AES"),
.headerSearchPath("Modules/Crypto/Data"),
.headerSearchPath("Modules/Crypto/Header"),
.headerSearchPath("Modules/Serializer/JSON"),
.headerSearchPath("Modules/Serializer/Object"),
.headerSearchPath("Modules/Serializer/Object/Categories"),
.headerSearchPath("Modules/Serializer/Object/Models"),
.headerSearchPath("Modules/Transport"),
.headerSearchPath("Modules/Transport/Categories"),
.headerSearchPath("Network"),
.headerSearchPath("Network/Parsers"),
.headerSearchPath("Network/Requests"),
.headerSearchPath("Network/Requests/Channel Groups"),
.headerSearchPath("Network/Requests/Files"),
.headerSearchPath("Network/Requests/Message Persistence"),
.headerSearchPath("Network/Requests/Message Reaction/Message"),
.headerSearchPath("Network/Requests/Objects"),
.headerSearchPath("Network/Requests/Objects/Channel"),
.headerSearchPath("Network/Requests/Objects/Membership"),
.headerSearchPath("Network/Requests/Objects/UUID"),
.headerSearchPath("Network/Requests/Presence"),
.headerSearchPath("Network/Requests/Publish"),
.headerSearchPath("Network/Requests/Push Notifications"),
.headerSearchPath("Network/Requests/Signal"),
.headerSearchPath("Network/Requests/Subscribe"),
.headerSearchPath("Network/Requests/Time"),
.headerSearchPath("Network/Responses"),
.headerSearchPath("Network/Responses/App Context"),
.headerSearchPath("Network/Responses/Channel Groups"),
.headerSearchPath("Network/Responses/Error"),
.headerSearchPath("Network/Responses/File Sharing"),
.headerSearchPath("Network/Responses/Message Persistence"),
.headerSearchPath("Network/Responses/Message Reaction"),
.headerSearchPath("Network/Responses/Presence"),
.headerSearchPath("Network/Responses/Publish"),
.headerSearchPath("Network/Responses/Push Notification"),
.headerSearchPath("Network/Responses/Signal"),
.headerSearchPath("Network/Responses/Subscribe"),
.headerSearchPath("Network/Responses/Time"),
.headerSearchPath("Network/Streams"),
.headerSearchPath("Protocols/Transport"),
],
linkerSettings: [.linkedLibrary("z")]
)
],
swiftLanguageVersions: [.v5]
Expand Down
2 changes: 2 additions & 0 deletions PubNub/Core/PubNub+Core.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#import "PNDictionaryLogEntry+Private.h"
#import "PNStringLogEntry+Private.h"
#import "PubNub+CorePrivate.h"
#define PN_CORE_PROTOCOLS PNEventsListener

Expand Down
10 changes: 8 additions & 2 deletions PubNub/Core/PubNub+Subscribe.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,17 @@ - (void)removeListener:(id <PNEventsListener>)listener {
#pragma mark - Filtering

- (NSString *)filterExpression {
return self.configuration.filterExpression;
__block NSString *expression;
[self.lock readAccessWithBlock:^{
expression = self.configuration.filterExpression;
}];
return expression;
}

- (void)setFilterExpression:(NSString *)filterExpression {
self.configuration.filterExpression = filterExpression;
[self.lock syncWriteAccessWithBlock:^{
self.configuration.filterExpression = filterExpression;
}];

if ([self.subscriberManager allObjects].count) {
[self subscribeWithRequest:[PNSubscribeRequest requestWithChannels:@[] channelGroups:@[]]];
Expand Down
22 changes: 10 additions & 12 deletions PubNub/Data/Managers/PNHeartbeat.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ @interface PNHeartbeat ()
*
* @since 4.7.5
*/
@property (nonatomic, strong) NSMutableArray *presenceChannels;
@property (nonatomic, strong) NSMutableSet *presenceChannels;

/**
* @brief Stores reference on list of channel groups for which client's connected state has been set to \c YES.
*
* @since 4.7.5
*/
@property (nonatomic, strong) NSMutableArray *presenceChannelGroups;
@property (nonatomic, strong) NSMutableSet *presenceChannelGroups;

/**
* @brief Stores reference on timer used to trigger heartbeat requests.
Expand Down Expand Up @@ -104,8 +104,8 @@ + (instancetype)heartbeatForClient:(PubNub *)client {
- (instancetype)initForClient:(PubNub *)client {
if ((self = [super init])) {
_client = client;
_presenceChannels = [NSMutableArray array];
_presenceChannelGroups = [NSMutableArray array];
_presenceChannels = [NSMutableSet set];
_presenceChannelGroups = [NSMutableSet set];
_resourceAccessQueue = dispatch_queue_create("com.pubnub.heartbeat", DISPATCH_QUEUE_CONCURRENT);
}

Expand Down Expand Up @@ -135,8 +135,8 @@ - (void)setHeartbeatTimer:(dispatch_source_t)heartbeatTimer {
NSMutableArray<NSString *> *allObjects = [NSMutableArray array];

pn_safe_property_read(self.resourceAccessQueue, ^{
[allObjects addObjectsFromArray:self->_presenceChannels];
[allObjects addObjectsFromArray:self->_presenceChannelGroups];
[allObjects addObjectsFromArray:self->_presenceChannels.allObjects];
[allObjects addObjectsFromArray:self->_presenceChannelGroups.allObjects];
});

return allObjects;
Expand All @@ -146,7 +146,7 @@ - (void)setHeartbeatTimer:(dispatch_source_t)heartbeatTimer {
__block NSArray<NSString *> *channels = nil;

pn_safe_property_read(self.resourceAccessQueue, ^{
channels = self->_presenceChannels;
channels = self->_presenceChannels.allObjects;
});

return channels;
Expand All @@ -156,8 +156,7 @@ - (void)setHeartbeatTimer:(dispatch_source_t)heartbeatTimer {
__block NSArray<NSString *> *channelGroups = nil;

pn_safe_property_read(self.resourceAccessQueue, ^{
channelGroups = self->_presenceChannelGroups;

channelGroups = self->_presenceChannelGroups.allObjects;
});

return channelGroups;
Expand All @@ -169,7 +168,7 @@ - (void)setConnected:(BOOL)connected forChannels:(NSArray<NSString *> *)channels
if (connected) {
[self->_presenceChannels addObjectsFromArray:channels];
} else {
[self->_presenceChannels removeObjectsInArray:channels];
[self->_presenceChannels minusSet:[NSSet setWithArray:channels]];
}
});
}
Expand All @@ -181,8 +180,7 @@ - (void)setConnected:(BOOL)connected forChannelGroups:(NSArray<NSString *> *)cha
if (connected) {
[self->_presenceChannelGroups addObjectsFromArray:channelGroups];
} else {
[self->_presenceChannelGroups removeObjectsInArray:channelGroups];

[self->_presenceChannelGroups minusSet:[NSSet setWithArray:channelGroups]];
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import <PubNub/PNAcknowledgmentStatus.h>
#import <PubNub/PNFileGenerateUploadURLData.h>
#import "PNFileGenerateUploadURLData.h"


NS_ASSUME_NONNULL_BEGIN
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import "PNPresenceGlobalHereNowResult.h"
#import "PNPresenceHereNowResult.h"


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import <PubNub/PubNub.h>
#import <PubNub/PNOperationResult.h>
#import <PubNub/PNPresenceHereNowFetchData.h>


Expand Down
Loading