-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Objective-C Promises crashes in SwiftUI previews #189
Comments
I'm attempting to use firebase analytics with (existing) bazel project - (not swiftui) firebase/firebase-ios-sdk#6115 My hacked categories to inform static library ... https://gist.github.com/wweevv-johndpope/fad4feb6f108c3df56033f28799d1d4c apple_dynamic_xcframework_import(
name = "FBLPromisesXCFramework",
library_identifiers = {
"ios_device": "ios-arm64",
"ios_simulator": "ios-arm64_x86_64-simulator",
},
xcframework_imports = glob(["FBLPromises.xcframework/**"] ),
) I have the categories - // FBLPromise+Extension.h
#if __has_include(<FBLPromises/FBLPromises.h>)
#import <FBLPromises/FBLPromises.h>
#else
#import "FBLPromises.h"
#endif
#import <Foundation/Foundation.h>
@interface FBLPromise (Extension)
@property(nonatomic, readonly) NSHTTPURLResponse *HTTPResponse;
@property(nonatomic, readonly) NSData *HTTPBody;
- (instancetype)initWithResponse:(NSHTTPURLResponse *)response HTTPBody:(NSData *)body;
@end
// FBLPromise+Extension.m
#import "FBLPromises.h"
#import <Foundation/Foundation.h>
@implementation FBLPromise (Extension)
+ (NSData *)HTTPBody {
return nil;
}
- (NSData *)HTTPBody {
return nil;
}
+ (void)setHTTPBody:(NSData *)data {
}
- (void)setHTTPBody:(NSData *)data {
}
+ (NSHTTPURLResponse *)HTTPResponse {
return nil;
}
- (NSHTTPURLResponse *)HTTPResponse {
return nil;
}
+ (void)setHTTPResponse:(NSHTTPURLResponse *)data {
}
- (void)setHTTPResponse:(NSHTTPURLResponse *)data {
}
+ (instancetype)initWithResponse:(NSHTTPURLResponse *)response HTTPBody:(nullable NSData *)body {
return nil;
}
- (instancetype)initWithResponse:(NSHTTPURLResponse *)response HTTPBody:(nullable NSData *)body {
return nil;
}
@end
but my attempts to inject these into the mix haven't been fruitful. objc_library(
name = "FBLPromises",
deps = ["FBLPromisesXCFramework"],
enable_modules = True,
module_name = "FBLPromises",
visibility = ["//visibility:public"],
srcs = glob([
"FBLPromises/Sources/*.m",
"FBLPromises/Sources/*.h",
]),
hdrs = glob([
"FBLPromises/PublicHeaders/*.h",
]),
includes = [
"FBLPromises/PublicHeaders",
],
)
|
I can confirm the behavior reported in this issue. Switching this over to be built as a framework instead of linked as a static lib resolves the issue and allows SwiftUI previews to work without crashing. |
Is there a resolution here? I am facing the same issue with Xcode 15.3 |
When statically linked, the Promises categories don't get linked and apps crash in Swift UI previews.
A workaround may be to add a symbol to the category implementation files that is referenced from a non-category file.
See firebase/firebase-ios-sdk#8005 and firebase/firebase-ios-sdk#9916
The text was updated successfully, but these errors were encountered: