Open victormihaita opened 3 years ago
Hi @victormihaita, we don't have an estimated time for when we'll support this. We will try to work on this as soon as we can but I don't have that information right now.
There is already a Package.swift
file. doesn't that mean it is supported in SPM?
@mcmurrym I've tried it out, it's not working properly.
@diegoserranoa Any updates on this issue?
I've got a SPM fork building, but I'm having issues getting the survey to actually show. The delegate method willPresentSurvey
is getting called but the survey never appears. Still trying to figure out why...
@victormihaita I was able to get an updated Package.swift
working for version 0.17.0 but for some reason it doesn't work on version 0.19.1. The big issues with 0.17.0 was the fact that the font wasn't being found since we were looking in the wrong bundle. Checking the auto generated SPM bundle, it was presenting the survey fine. I'm guessing somethings changed between version 0.17.0 and version 0.19.1 that's causing it to not work. Here's the Package.swift for those who'd like to continue tweaking with it. I'd create a MR, but since it doesn't work with the most current master I'd rather just post it here:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "WootricSDK",
products: [
.library(name: "WootricSDK", targets: ["WootricSDK"])
],
targets: [
.target(
name: "WootricSDK",
path: "WootricSDK/WootricSDK",
exclude: ["Info.plist"],
resources: [.process("fontawesome-webfont.ttf")],
publicHeadersPath: "."
)
]
)
Here's the other snippet for the changes needed in UIItems.m. I needed make a change in the dynamicallyAddFont method to look for thee SPM bundle::
+ (void)dynamicallyAddFont {
NSString *fontPath = [[NSBundle bundleForClass:[UIItems class]] pathForResource:@"fontawesome-webfont" ofType:@"ttf"];
if ([fontPath length] == 0) {
// Try to find the font in the SPM bundle
fontPath = [SWIFTPM_MODULE_BUNDLE pathForResource:@"fontawesome-webfont" ofType:@"ttf"];
}
CFErrorRef error;
NSURL *url = [NSURL fileURLWithPath:fontPath isDirectory:NO];
if (!CTFontManagerRegisterFontsForURL((__bridge CFURLRef)url, kCTFontManagerScopeNone, &error)) {
if (CFErrorGetCode(error) == kCTFontManagerErrorAlreadyRegistered) {
CFRelease(error);
return;
}
CFStringRef errorDescription = CFErrorCopyDescription(error);
NSLog(@"WootricSDK: Failed to load font: %@", errorDescription);
CFRelease(errorDescription);
CFRelease(error);
}
}
Stil fails on version 0.20.0
Still failing in version 0.21 with this error:
The same issue here :/
Same issue here as well
there is a PR to fix it if someone can have a look at it 👁️
@diegoserranoa, please review https://github.com/Wootric/WootricSDK-iOS/pull/96
When you think we can have the SPM integration in the project?