I had programmed and used a software for a year without problems but after updating to Monterey and updating XCode, the following, simplified Playground example of the process always fails and I cannot figure out why. Please note this project is specifically written for macOS and I cannot use the iOS libraries for PDF generation.
import WebKit
import PDFKit
import SwiftUI
import CoreGraphics
let webView: WKWebView = WKWebView(frame: CGRect(x: 0, y: 0, width: 595.0, height: 842.0), configuration: WKWebViewConfiguration())
let htmlString = "<html><body><h1>Hello</h1></body></html>"
webView.loadHTMLString(htmlString, baseURL: nil)
webView.createPDF(completionHandler: compHandler)
func compHandler(res: Result<Data, Error>) -> Void {
print(res)
}
This always results in an error:
failure(Error Domain=WKErrorDomain Code=1 "An unknown error occurred" UserInfo={NSLocalizedDescription=An unknown error occurred})
I cannot find anything in the documentation regarding this and most examples and questions are old and not applicable (many still using Objective-C).
Debugging seems to suggest that the loadHTMLString itself fails, not even necessarily the PDF itself.
Any pointers would be appreciated.
Thanks
Related
I am using html to PDF conversion using syncfusion webkit rendering on MAC os. It works fine until I notarize my app. When I tried to notarize my app, I got errors like QtMacBinaries are not signed.
I signed all QtMacBinaries using my developer id certificates. Now notarization got success but html to PDF conversion is failing.
I am getting below error:
Syncfusion.Pdf.PdfException: dyld: Library not loaded: #rpath/libQt5Core.5.dylib
Referenced from: /Users/sangapankaj/Projects/TestConverter/bin/Release/TestConverter.app/Contents/Resources/QtBinariesMac/Syncfusion.WebKitWrapper
Reason: image not found
,'Html conversion failed
Syncfusion version: Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core.18.2.0.44,
OS: MAC 10.14,
Compiler: Visual Studio 2019,
Language: dot net
I am not sure what I am missing? Main culprit is Syncfusion.WebkitWrapper binary. It is not able to load QT libraries if I have signed it with my developer id certificates. If I use it without signing, it works fine.
Code
HtmlToPdfConverter htmlToPdfConverter;
WebKitConverterSettings webKitConverterSettings;
PdfDocument pdfDocument = null;
try
{
htmlToPdfConverter = new HtmlToPdfConverter();
webKitConverterSettings = new WebKitConverterSettings();
webKitConverterSettings.WebKitPath = "/Applications/MacUncle OLM Converter.app/Contents/Resources /QtBinariesMac";
htmlToPdfConverter.ConverterSettings = webKitConverterSettings;
string strTempPath = Path.GetTempPath();
pdfDocument = htmlToPdfConverter.Convert(bdy, strTempPath);
}
catch(Exception e)
{
string exp = string.Format("{0} exception caught", e);
Log.WriteErrorLog(exp);
}
We have checked the reported issue in our end, but we did not face this error in Mac with our WebKit converter. We internally make use of the QtWebKit rendering engine for converting HTML to PDF We have to provide the WebKitPath as folder location of QtBinariesMac path in your machine.
We have analyzed about the reported issue, we suspect the issue occurs due to the signed binaries not loaded properly in your application. After the notarization, If the binaries are compressed in any format (.pkg), please extract it and try the conversion. However, please make sure that you are running the latest XCode version where the conversion take place. Please try the below suggestions in your end and let us know the result.
https://developer.apple.com/forums/thread/124810
https://developer.apple.com/forums/thread/128435
https://github.com/Alamofire/Alamofire/issues/3051#issuecomment-580003683
Note : I work for Syncfusion.
I am doing a small project on Nativescript, using the ML kit for face recognition
My task is to take a photograph after a face has been recognized. On Android, this function works fine and the image is saved, but on iOS, an error occurs.
Tell me, what could be the problem and how to solve it?
const bmp = event.object.lastVisionImage.getBitmap();
const source = new ImageSource();
source.setNativeSource(bmp);
var imageData = source.toBase64String("jpeg");
'NativeScript encountered a fatal error: TypeError:
event.object.lastVisionImage.getBitmap is not a function. (In
'event.object.lastVisionImage.getBitmap()',
'event.object.lastVisionImage.getBitmap' is undefined)
Does this come from this unofficial plug-in?
https://market.nativescript.org/plugins/nativescript-plugin-firebase-mlkit-unofficial
I'm afraid MLKit team doesn't officially support the NativeScript plugin, posting the question in the community of the plugin provider might get an answer more efficiently. Thanks!
I'm trying to use Hyperloop in order to use a third-party open source library. The library I want to use is Sweet Alert iOS.
The library has a swift file. I have put this file inside an src directory inside my project's main folder (does it have to be inside src folder? can I use other folder in my project? what about sub-directories?).
According to the Titanium documentation:
Any *.swift files found in your src directories will automatically be compiled
In my app when I do something like this:
var UIView = require('UIKit/UIView');
Ti.API.info('UIView => ' + UIView);
It works. But if I try to require any of the classes in the swift file I get an error that it can't find architecture x86_64 module.
var sweetAlert = require('SweetAlert');
var cancelAnimatedView = require('CancelAnimatedView');
When looking at the SweetAlert source code, I also notice that SweetAlert class is open while other classes are just regular classes:
open class SweetAlert
I'm not a swift developer so I don't really know what it means.
What am I missing here?
EDIT
Some progress... So I found that I need to have an appc.js file that's defining the src frame work and a name for MyFramework. And that the require I do should match the filename of the swift file. Now when I compile I see some more interesting output about the swift compilation, but getting an error:
[INFO] Generating metabase for swift MyFramework /Users/ophir/Documents/Appcelerator_Studio_Workspace/HyperloopTest1/src/SweetAlert.swift
2017-06-29T14:43:44.061Z | ERROR | An uncaught exception was thrown!
Cannot read property '1' of null
2017-06-29T14:43:44.064Z | ERROR | Cannot read property '1' of null
EDIT 2
I've cleared all the script in the swift file, and narrowed it down to the following failing script:
import Foundation
import UIKit
import QuartzCore
public enum AlertStyle {
case success,error,warning,none
case customImag(imageFile:String)
}
class SweetAlert: UIViewController {
}
class AnimatableView: UIView {
func animate(){
}
}
If I remove the func animate() { } it will not fail. Even if this function is inside that one SweetAlert class then it will fail. And from what I've read this is a pretty standard swift code.
So this makes me wonder - is Hyperloop 2.0.0(!) ready for production apps?
I receive a similar error when creating a simple Swift class and including it in a Titanium/Appcelerator project with the appc.js file set up just how they show in the sparse documentation. The project will compile with no issues and run in the Xcode Simulator, as long as I don't reference the class from the Swift file. If I reference that class in the project, the error arises. Based on the compile log, Swift files do compile into the project, but the classes don't seem to properly link in the end for "require"-ing into the JavaScript code.
When I search online for solutions, this same issue shows up all over, and the Titanium/Appcelerator team never presents a solution. I've tried Titanium SDK 6.0.1, 6.1.2, and 6.2.0, with all the same results; I've tried adding Swift code to existing projects and to new ones; I've also uninstalled and reinstalled Titanium/Appcelerator. (I've even tried running their sample app with no luck!)
Hyperloop does work when I use native frameworks, like UIKit, but it doesn't seem ready for production apps for 3rd party frameworks and classes.
I hope my discoveries help you and others to debug projects, but, unfortunately, I don't think I will be able to offer much help outside that.
I want to start off saying that I have reviewed the many posts about iOS app crashing only for Apple Review Team and I did not find a solution and also did find one with my crash log information.
This is a Xamarin.Forms project. I have a PCL with Droid and iOS projects. My Droid project works great. I have no issues there. My iOS project is where I am having issues. I can debug this without any hiccups. I have tested this on the various simulators via XCode and also multiple real devices. I constantly get my app rejected by Apple saying the app crashes when it does a certain action. I have tried numerous times to duplicate the crash but I cannot.
I have symbolicated the crash log from Apple and it can be viewed with this link. I do not see anywhere in the crash log that shows my code and what I did wrong. I think it has something to do with me doing async/await stuff but I cannot confirm this.
If it helps, I am using version 2.2.0.31 of Xamarin.
I am new to Apple crash logs and I find them very hard to decipher. Can someone please assist with helping figure out what I am doing wrong.
UPDATE
Included is the code that was requested.
iOS project -- Main.cs
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
}
}
iOS project -- AppDelegate.cs
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
App.ScreenWidth = (int)UIScreen.MainScreen.Bounds.Width;
App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height;
UINavigationBar.Appearance.TintColor = UIColor.FromRGB(40, 51, 65);
FormsMaps.Init();
AdvancedTimerImplementation.Init();
CachedImageRenderer.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
Shared project -- App.cs
public App()
{
//do the initial setup
var nav = new NavigationService();
if (!SimpleIoc.Default.IsRegistered<INavigationServiceEx>())
SimpleIoc.Default.Register<INavigationServiceEx>(() => nav);
var apiMgr = new ApiManager();
if (!SimpleIoc.Default.IsRegistered<ApiManager>())
SimpleIoc.Default.Register<ApiManager>(() => apiMgr);
var storageMgr = new StorageManager();
if (!SimpleIoc.Default.IsRegistered<StorageManager>())
SimpleIoc.Default.Register<StorageManager>(() => storageMgr);
var externalMaps = DependencyService.Get<IExternalMaps>();
if (!SimpleIoc.Default.IsRegistered<IExternalMaps>())
SimpleIoc.Default.Register<IExternalMaps>(() => externalMaps);
var mediaService = DependencyService.Get<IMedia>();
mediaService.Initialize();
if (!SimpleIoc.Default.IsRegistered<IMedia>())
SimpleIoc.Default.Register<IMedia>(() => mediaService);
var geolocationService = DependencyService.Get<IGeolocator>();
if (!SimpleIoc.Default.IsRegistered<IGeolocator>())
SimpleIoc.Default.Register<IGeolocator>(() => geolocationService);
nav.Configure(ViewModelLocator.StartupPage, typeof(StartupView));
nav.Configure(ViewModelLocator.LoginPage, typeof(LoginView));
nav.Configure(ViewModelLocator.RegisterPage, typeof(RegisterView));
nav.Configure(ViewModelLocator.QouponsPage, typeof(QouponsView));
nav.Configure(ViewModelLocator.UserProfilePage, typeof(UserProfileView));
nav.Configure(ViewModelLocator.EditUserProfilePage, typeof(EditUserProfileView));
nav.Configure(ViewModelLocator.CompanyPage, typeof(CompanyView));
nav.Configure(ViewModelLocator.RedeemPage, typeof(RedeemView));
nav.Configure(ViewModelLocator.SettingsPage, typeof(SettingsView));
nav.Configure(ViewModelLocator.HelpPage, typeof(HelpView));
var startupView = new StartupView();
var startupPage = new NavigationPage(startupView);
startupPage.BarBackgroundColor = Color.FromHex("#FF8A07");
nav.Initialize(startupPage);
startupView.Start();
MainPage = startupPage;
}
Something in your async code threw an exception, and there doesn't seem to be an exception handler for that exception (an exception without an exception handler will crash the process).
This is from your main thread where it shows the async runtime logic throwing the exception on the main thread:
13 QneoiOS 0x000000010023039c System_Runtime_ExceptionServices_ExceptionDispatchInfo_Throw + 44
14 QneoiOS 0x000000010022eea0 System_Runtime_CompilerServices_AsyncMethodBuilderCore__ThrowAsyncm__0_object + 80
15 QneoiOS 0x0000000100b3b798 UIKit_UIKitSynchronizationContext__Postc__AnonStorey0__m__0 (UIKitSynchronizationContext.cs:24)
16 QneoiOS 0x0000000100b55fd4 Foundation_NSAsyncActionDispatcher_Apply (NSAction.cs:163)
You need more details about this exception, the crash report doesn't contain enough information to diagnose further.
My suggestion would be to add a crash-reporting solution (such as Xamarin Insights), resubmit, and then you should get information about the exception in Xamarin Insights when the crash occurs during Apple's review.
I had a similar problem. Moved to Xamarin in Microsoft Studio and it worked on devices & simulator in debug and on simulator in release mode but was crashing in testflight and review. My solution was two things: I changed the linker setting to Link SDKs rather than Link All. I revoked by release certificate and recreated that with a new distribution provisioning profile. This fixed the problem for me. Hope it helps someone else.
I'm trying to get a Live View to work in a Swift Playground. Whenever I import the XCPlayground framework to execute the XCPShowView function i get this error:
Playground execution failed: error: Couldn't lookup symbols:_CGPointMake
The error changes for a few other "symbols" as well, including CGRectMake. I've tried clearing my Xcode beta 5 cache directory as well as re-installing Xcode.
Try with this:
instead of using
CGSizeMake(200, 200)
use this (without the "Make")
CGSize(width: 200, height: 200)
The same with CGPointMake / CGPoint, CGRectMake/CGRect...
I'm experimenting with sprite kit in a playground, and I had the same problem.
For me it helped with NSPoint(x:y:) and NSRect(x:y:)