Skip to content

Commit

Permalink
Release version 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyorbin committed Feb 14, 2023
1 parent f739ed0 commit 0fc7425
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 11 deletions.
2 changes: 1 addition & 1 deletion BrazeProject/ios/BrazeProject/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#import "BrazeReactUtils.h"
#import "BrazeReactBridge.h"

@import BrazeKit;
#import <BrazeKit/BrazeKit-Swift.h>

@implementation AppDelegate

Expand Down
4 changes: 2 additions & 2 deletions BrazeProject/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- boost (1.76.0)
- braze-react-native-sdk (2.0.1):
- braze-react-native-sdk (2.0.2):
- BrazeKit (~> 5.9.1)
- BrazeLocation (~> 5.9.1)
- BrazeUI (~> 5.9.1)
Expand Down Expand Up @@ -590,7 +590,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
braze-react-native-sdk: fde05eb5f01efa0291de5aad88574434df80f30d
braze-react-native-sdk: c61760392f8554a6835d9cff34952e53c45f8ae6
BrazeKit: 7c8ab19c996bb6447d44a242c14778ad48c9e020
BrazeLocation: ba8da78df3221b627c56c4b2ad20df2e0795dfb4
BrazeUI: 39d905f9ded70b6ab9d8ab08d6cfdbbfed4cc282
Expand Down
4 changes: 2 additions & 2 deletions BrazeProject/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1063,8 +1063,8 @@
resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@braze/react-native-sdk@../react-sdk/public":
version "2.0.0"
"@braze/react-native-sdk@../":
version "2.1.0"

"@eslint/eslintrc@^1.4.1":
version "1.4.1"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.0.2

##### Fixed
- Removes the usage of Objective-C modules when importing the Braze Swift SDK for improved compatibility with Objective-C++.
- When importing `BrazeKit` or `BrazeLocation`, you must use the `#import <Module/Module-Swift.h>` syntax:
- `@import BrazeKit;``#import <BrazeKit/BrazeKit-Swift.h>`
- `@import BrazeLocation;``#import <BrazeLocation/BrazeLocation-Swift.h>`

# 2.0.1

##### Fixed
Expand Down
9 changes: 6 additions & 3 deletions braze-react-native-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.platform = :ios, '11.0'

s.preserve_paths = 'LICENSE.md', 'README.md', 'package.json', 'index.js'
s.preserve_paths = 'LICENSE.md', 'README.md', 'package.json', 'index.js', 'iOS/replace-at-import-statements.sh'
s.source_files = 'iOS/**/*.{h,m}'

s.dependency 'BrazeKit', '~> 5.9.1'
Expand All @@ -24,6 +24,9 @@ Pod::Spec.new do |s|

s.dependency 'React-Core'

# For compatibility with Objective-C++
s.user_target_xcconfig = { 'OTHER_CPLUSPLUSFLAGS' => '-fmodules -fcxx-modules' }
s.script_phase = {
:name => "Replace Braze SDK @import statements",
:script => "bash ${PODS_TARGET_SRCROOT}/iOS/replace-at-import-statements.sh",
:execution_position => :before_compile
}
end
2 changes: 1 addition & 1 deletion iOS/BrazeReactBridge/BrazeReactBridge/BrazeReactBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import <React/RCTEventEmitter.h>
#import <React/RCTBridgeModule.h>

@import BrazeKit;
#import <BrazeKit/BrazeKit-Swift.h>

@interface BrazeReactBridge : RCTEventEmitter <RCTBridgeModule, RCTBridgeDelegate>

Expand Down
33 changes: 33 additions & 0 deletions iOS/replace-at-import-statements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /bin/bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS=$'\n\t'

# This script replaces the `@import`` statements in the `.h` files in the various
# Braze SDK frameworks.
# This change is needed because `@import` statements are not directly supported
# in ObjC++ and adding the compiler flags to add support lead to other
# compilation issues in Expo.

# This script has access to the whole Xcode build environment, so it can use
# environment variables to find the Braze SDK frameworks.

# Find Braze SDK headers in PODS_XCFRAMEWORKS_BUILD_DIR
headers=()
while IFS= read -r -d $'\0'; do
headers+=("$REPLY")
done < <(find "$PODS_XCFRAMEWORKS_BUILD_DIR" -type f -name 'Braze*Swift.h' -print0)

# Replace @import module statements with #import statements
for header in "${headers[@]}"; do

# Remove `@import` statements (not strictly necessary)
perl -0777 -i -pe 's/(?:^\@import.*;\n)+/\n/gm' "$header"

# BrazeKit
if [[ $header == *"BrazeKit"* ]]; then
# Add the required imports
perl -0777 -i -pe 's/^\@class NSString;/#import <Foundation\/Foundation.h>\n#import <UIKit\/UIKit.h>\n#import <WebKit\/WebKit.h>\n\n\@class NSString;/gm' "$header"
fi

done
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@braze/react-native-sdk",
"version": "2.0.1",
"version": "2.0.2",
"description": "Braze SDK for React Native.",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down Expand Up @@ -59,4 +59,4 @@
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
}
}
}
}

0 comments on commit 0fc7425

Please sign in to comment.