Skip to content

Commit 3e9b232

Browse files
release: SDK 2.1.2
1 parent 832194f commit 3e9b232

File tree

7 files changed

+64
-33
lines changed

7 files changed

+64
-33
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let package = Package(
1818
targets: [
1919
.binaryTarget(
2020
name: "Batch",
21-
url: "https://download.batch.com/sdk/ios/spm/BatchSDK-ios_spm-xcframework-2.1.1.zip",
22-
checksum: "459e9f6b8653bd6e8f872e991829e4ac3d2522f3859704b9a5915b84fe0d9190"
21+
url: "https://download.batch.com/sdk/ios/spm/BatchSDK-ios_spm-xcframework-2.1.2.zip",
22+
checksum: "a0171e252595c61b58c3640b1066010cff2c594ce7cd5fd154b08ce25a5d2be0"
2323
)
2424
]
2525
)

Sources/Batch.xcodeproj/project.pbxproj

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,7 +3248,7 @@
32483248
);
32493249
runOnlyForDeploymentPostprocessing = 0;
32503250
shellPath = /bin/sh;
3251-
shellScript = "# workaround for bitcode generation problem with Xcode 7.3\nunset TOOLCHAINS\n\nexport CONFIGURATION=Release\n\n# define output folder environment variable\nARCHIVES_OUTPUTFOLDER=${PROJECT_DIR}/universal/Archives\nDSYMS_OUTPUTFOLDER=${PROJECT_DIR}/universal/dSYMs\nXCFRAMEWORK_OUTPUT=${PROJECT_DIR}/universal/Batch.xcframework\n\n# Create the output folders\nmkdir -p \"${ARCHIVES_OUTPUTFOLDER}\"\nmkdir -p \"${DSYMS_OUTPUTFOLDER}\"\nrm -f \"${DSYMS_OUTPUTFOLDER}/*.dSYM\"\n\n# Step 1. Build Device, Simulator, macOS and visionOS versions\nxcodebuild archive -scheme Batch -destination \"generic/platform=iOS\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphoneos.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO ARCHS=\"arm64 arm64e\" VALID_ARCHS=\"arm64 arm64e\"\nxcodebuild archive -scheme Batch -destination \"generic/platform=iOS Simulator\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphonesimulator.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO\nxcodebuild archive -scheme Batch -destination \"platform=macOS\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-macos.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO\n\n# We need a xcconfig to override SDKROOT to fix an issue with visionOS SDK being\n# required to build xros frameworks https://forums.developer.apple.com/forums/thread/743246\n# Setting SDKROOT or even making a new configuration does not work\ncp \"${PROJECT_DIR}/Batch/ReleaseConfig-visionos-workaround-vision.xcconfig\" \"${PROJECT_DIR}/Batch/ReleaseConfig.xcconfig\"\nxcodebuild archive -scheme Batch -destination \"generic/platform=visionOS\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-xros.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO SDKROOT=xros\nxcodebuild archive -scheme Batch -destination \"generic/platform=visionOS Simulator\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-xrossimulator.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO\ncp \"${PROJECT_DIR}/Batch/ReleaseConfig-visionos-workaround-initial.xcconfig\" \"${PROJECT_DIR}/Batch/ReleaseConfig.xcconfig\"\n\n# Step 2. Copy the dSYMs\n\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphoneos.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_iphoneos.framework.dSYM\"\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphonesimulator.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_iphonesimulator.framework.dSYM\"\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-macos.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_macos.framework.dSYM\"\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-xros.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_xros.framework.dSYM\"\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-xrossimulator.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_xrossimulator.framework.dSYM\"\n\n# Step 3. Clean up the frameworks\n\npushd .\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphoneos.xcarchive/Products/Library/Frameworks/Batch.framework/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphonesimulator.xcarchive/Products/Library/Frameworks/Batch.framework/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-macos.xcarchive/Products/Library/Frameworks/Batch.framework/Versions/A/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-xros.xcarchive/Products/Library/Frameworks/Batch.framework/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-xrossimulator.xcarchive/Products/Library/Frameworks/Batch.framework/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\n## 3.1: Fix Xcode not creating the \"PrivateHeaders\" folder, which can break Azure Pipelines\n## https://github.com/bamlab/react-native-batch-push/issues/67\nmkdir \"PrivateHeaders\"\n\npopd\n\n# Step 4. Make the xcframework\n# Remove the old xcframework\nrm -rf \"${XCFRAMEWORK_OUTPUT}\"\n\n# Build the xcframework\n\npushd .\ncd \"${PROJECT_DIR}/universal\"\nxcodebuild -create-xcframework \\\n -framework \"Archives/Batch-iphoneos.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -framework \"Archives/Batch-iphonesimulator.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -framework \"Archives/Batch-macos.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -framework \"Archives/Batch-xros.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -framework \"Archives/Batch-xrossimulator.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -output \"Batch.xcframework\"\n\n# Sign it for distribution\n# (Apple Enterprise Account)\n\nif [ \"$BATCHSDK_SIGN_XCFRAMEWORK\" == \"1\" ]\nthen\n echo \"Signing Batch.xcframework\"\n codesign --timestamp -v --sign \"iPhone Distribution: IMEDIAPP\" \"${XCFRAMEWORK_OUTPUT}\"\nfi\n";
3251+
shellScript = "# workaround for bitcode generation problem with Xcode 7.3\nunset TOOLCHAINS\n\nexport CONFIGURATION=Release\n\n# define output folder environment variable\nARCHIVES_OUTPUTFOLDER=${PROJECT_DIR}/universal/Archives\nDSYMS_OUTPUTFOLDER=${PROJECT_DIR}/universal/dSYMs\nXCFRAMEWORK_OUTPUT=${PROJECT_DIR}/universal/Batch.xcframework\n\n# Create the output folders\nmkdir -p \"${ARCHIVES_OUTPUTFOLDER}\"\nmkdir -p \"${DSYMS_OUTPUTFOLDER}\"\nrm -f \"${DSYMS_OUTPUTFOLDER}/*.dSYM\"\n\n# Step 1. Build Device, Simulator, macOS and visionOS versions\nxcodebuild archive -scheme Batch -destination \"generic/platform=iOS\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphoneos.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO ARCHS=\"arm64\" VALID_ARCHS=\"arm64\"\nxcodebuild archive -scheme Batch -destination \"generic/platform=iOS Simulator\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphonesimulator.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO\nxcodebuild archive -scheme Batch -destination \"platform=macOS\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-macos.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO\n\n# We need a xcconfig to override SDKROOT to fix an issue with visionOS SDK being\n# required to build xros frameworks https://forums.developer.apple.com/forums/thread/743246\n# Setting SDKROOT or even making a new configuration does not work\ncp \"${PROJECT_DIR}/Batch/ReleaseConfig-visionos-workaround-vision.xcconfig\" \"${PROJECT_DIR}/Batch/ReleaseConfig.xcconfig\"\nxcodebuild archive -scheme Batch -destination \"generic/platform=visionOS\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-xros.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO SDKROOT=xros\nxcodebuild archive -scheme Batch -destination \"generic/platform=visionOS Simulator\" -configuration ${CONFIGURATION} -archivePath \"${ARCHIVES_OUTPUTFOLDER}/Batch-xrossimulator.xcarchive\" SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO\ncp \"${PROJECT_DIR}/Batch/ReleaseConfig-visionos-workaround-initial.xcconfig\" \"${PROJECT_DIR}/Batch/ReleaseConfig.xcconfig\"\n\n# Step 2. Copy the dSYMs\n\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphoneos.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_iphoneos.framework.dSYM\"\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphonesimulator.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_iphonesimulator.framework.dSYM\"\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-macos.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_macos.framework.dSYM\"\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-xros.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_xros.framework.dSYM\"\ncp -a \"${ARCHIVES_OUTPUTFOLDER}/Batch-xrossimulator.xcarchive/dSYMs/Batch.framework.dSYM\" \"${DSYMS_OUTPUTFOLDER}/Batch_xrossimulator.framework.dSYM\"\n\n# Step 3. Clean up the frameworks\n\npushd .\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphoneos.xcarchive/Products/Library/Frameworks/Batch.framework/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-iphonesimulator.xcarchive/Products/Library/Frameworks/Batch.framework/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-macos.xcarchive/Products/Library/Frameworks/Batch.framework/Versions/A/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-xros.xcarchive/Products/Library/Frameworks/Batch.framework/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\ncd \"${ARCHIVES_OUTPUTFOLDER}/Batch-xrossimulator.xcarchive/Products/Library/Frameworks/Batch.framework/\"\nsh ${PROJECT_DIR}/../Tools/Scripts/strip_public_swift_framework.sh\n\n## 3.1: Fix Xcode not creating the \"PrivateHeaders\" folder, which can break Azure Pipelines\n## https://github.com/bamlab/react-native-batch-push/issues/67\nmkdir \"PrivateHeaders\"\n\npopd\n\n# Step 4. Make the xcframework\n# Remove the old xcframework\nrm -rf \"${XCFRAMEWORK_OUTPUT}\"\n\n# Build the xcframework\n\npushd .\ncd \"${PROJECT_DIR}/universal\"\nxcodebuild -create-xcframework \\\n -framework \"Archives/Batch-iphoneos.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -framework \"Archives/Batch-iphonesimulator.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -framework \"Archives/Batch-macos.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -framework \"Archives/Batch-xros.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -framework \"Archives/Batch-xrossimulator.xcarchive/Products/Library/Frameworks/Batch.framework\" \\\n -output \"Batch.xcframework\"\n\n# Sign it for distribution\n# (Apple Enterprise Account)\n\nif [ \"$BATCHSDK_SIGN_XCFRAMEWORK\" == \"1\" ]\nthen\n echo \"Signing Batch.xcframework\"\n codesign --timestamp -v --sign \"iPhone Distribution: IMEDIAPP\" \"${XCFRAMEWORK_OUTPUT}\"\nfi\n";
32523252
};
32533253
516C406723D9FD63000C11CF /* ShellScript */ = {
32543254
isa = PBXShellScriptBuildPhase;
@@ -4012,14 +4012,8 @@
40124012
517D701F22BBC34A00E374FB /* Release */ = {
40134013
isa = XCBuildConfiguration;
40144014
buildSettings = {
4015-
"ARCHS[sdk=iphoneos*]" = (
4016-
"$(ARCHS_STANDARD)",
4017-
arm64e,
4018-
);
4019-
"ARCHS[sdk=xros*]" = (
4020-
"$(ARCHS_STANDARD)",
4021-
arm64e,
4022-
);
4015+
"ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)";
4016+
"ARCHS[sdk=xros*]" = "$(ARCHS_STANDARD)";
40234017
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
40244018
CLANG_ANALYZER_NONNULL = YES;
40254019
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;

Sources/Batch/Kernel/Helpers/BADelegatedApplicationDelegate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ NS_ASSUME_NONNULL_BEGIN
3636
+ (instancetype)sharedInstance;
3737

3838
/*!
39-
@method swizzleAppDelegate:
39+
@method findAndSwizzleAppDelegate:
4040
@abstract Swizzle the current [UIApplication sharedApplication].delegate class. Note that calling this method multiple
4141
times is an error. Make sure to set a `batchDelegate` on this object to be informed of the calls.
4242
@return Whether the operation succeeded
4343
*/
44-
- (BOOL)swizzleAppDelegate;
44+
- (BOOL)findAndSwizzleAppDelegate;
4545

4646
@end
4747

Sources/Batch/Kernel/Helpers/BADelegatedApplicationDelegate.m

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#import <Batch/BAPushCenter.h>
1212
#import <objc/runtime.h>
1313

14-
#define DEBUG_SWIZZLE NO
14+
#define DEBUG_SWIZZLE 0
1515

1616
@implementation BADelegatedApplicationDelegate
1717

@@ -34,7 +34,7 @@ - (instancetype)init {
3434
return self;
3535
}
3636

37-
- (BOOL)swizzleAppDelegate {
37+
- (BOOL)findAndSwizzleAppDelegate {
3838
if (!_batchDelegate) {
3939
return false;
4040
}
@@ -50,6 +50,43 @@ - (BOOL)swizzleAppDelegate {
5050
return false;
5151
}
5252

53+
if ([[NSString stringWithFormat:@"SwiftUI.%@", @"AppDelegate"]
54+
isEqualToString:NSStringFromClass(appDelegate.class)]) {
55+
[BALogger debugForDomain:nil message:@"SwiftUI AppDelegate detected, adjusting swizzling"];
56+
// On a SwiftUI lifecycle app, SwiftUI.AppDelegate is always the application delegate
57+
// The SwiftUI class does not respond to the selectors, but implements
58+
// "forwardingTargetForSelector"
59+
// https://developer.apple.com/documentation/objectivec/nsobject-swift.class/forwardingtarget(for:) and returns
60+
// the instance set using @UIApplicationDelegateAdaptor In theory, this is never nil, but you never know how
61+
// Batch is implemented. So, the plan is:
62+
// - If it is nil, swizzle SwiftUI.AppDelegate
63+
// - If it is not nil, swizzle the developer's implementation
64+
if ([appDelegate respondsToSelector:@selector(forwardingTargetForSelector:)]) {
65+
id developerDelegate = [(NSObject *)appDelegate
66+
forwardingTargetForSelector:@selector(application:didRegisterForRemoteNotificationsWithDeviceToken:)];
67+
if (developerDelegate != nil) {
68+
[BALogger
69+
debugForDomain:nil
70+
message:
71+
@"SwiftUI AppDelegate has a UIApplicationDelegateAdaptor, switching swizzling target"];
72+
appDelegate = developerDelegate;
73+
}
74+
} else {
75+
[BALogger debugForDomain:nil
76+
message:@"SwiftUI AppDelegate does not respond to forwardingTargetForSelector. Swizzling "
77+
@"system delegate"];
78+
}
79+
}
80+
81+
if ([self swizzleAppDelegate:appDelegate]) {
82+
_didSwizzle = true;
83+
return true;
84+
} else {
85+
return false;
86+
}
87+
}
88+
89+
- (BOOL)swizzleAppDelegate:(nonnull id<UIApplicationDelegate>)appDelegate {
5390
Class appDelegateClass = [appDelegate class];
5491

5592
if (appDelegateClass == [_batchDelegate class]) {
@@ -70,8 +107,6 @@ - (BOOL)swizzleAppDelegate {
70107
}
71108

72109
[self swizzleMethodsOfDelegate:appDelegate];
73-
74-
_didSwizzle = true;
75110
return true;
76111
}
77112

@@ -92,6 +127,8 @@ - (nullable IMP)swizzleMethod:(nonnull SEL)selector
92127

93128
#if DEBUG_SWIZZLE
94129
NSLog(@"Swizzling %@", selectorString);
130+
NSLog(@"Swizzled class responds to selector %@ ? %@", NSStringFromSelector(selector),
131+
[targetClass instancesRespondToSelector:selector] ? @"YES" : @"NO");
95132
#endif
96133

97134
// If the class instance doesn't implement a selector and
@@ -165,4 +202,4 @@ - (void)swizzle_didFailToRegisterForRemoteNotificationsWithError:(Class)class {
165202
[self swizzleMethod:selector withBlock:block onClass:class skipIfTargetDoesntImplement:false];
166203
}
167204

168-
@end
205+
@end

Sources/Batch/Modules/Push/BAPushCenter.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ - (void)registerProxy {
240240
BADelegatedApplicationDelegate *delegatedApplicationDelegate = [BADelegatedApplicationDelegate sharedInstance];
241241
delegatedApplicationDelegate.batchDelegate = self;
242242

243-
BOOL swizzleSuccess = [delegatedApplicationDelegate swizzleAppDelegate];
243+
BOOL swizzleSuccess = [delegatedApplicationDelegate findAndSwizzleAppDelegate];
244244
[BALogger debugForDomain:NSStringFromClass([self class])
245-
message:swizzleSuccess ? @"Swizzing successful" : @"Swizzling errored"];
245+
message:swizzleSuccess ? @"Swizzling successful" : @"Swizzling errored"];
246246

247247
self.swizzled = true;
248248

Sources/Batch/Versions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
Comments should not use the // form, as the plist preprocessor will include them
1212
*/
1313

14-
#define BASDKVersion 2.1.1
15-
#define BAAPILevel 211
14+
#define BASDKVersion 2.1.2
15+
#define BAAPILevel 212
1616
#define BAMessagingAPILevel 12

0 commit comments

Comments
 (0)