UIMenuBuilder not called (Catalyst) - ios

I have an iOS app (create feb 2019) which is now also available for MacOS by using Mac Catalyst.
The app works fine. I added menu functionality to the File menu with
override func validate(_ command: UICommand) {
}
Now I want to remove the Help menu.
For this I used, buildmenu in AppDelegate.
override func buildMenu(with builder: UIMenuBuilder)
{
super.buildMenu(with: builder)
builder.remove(menu: .help)
}
In a newer app (Dec 2019) for Catalyst this works fine, and the code removes the menu.
In my older app, buildMenu is not called.
AppDelegate is setup as a UIResponder...
I have no idea how to make this work.
Any idea what I can try?
Best regards.

Turns out it was my mistake.
Once you add a Menu (UiMenuRoot) to the project, you can not use UIMenubuilder to modify the menu.

Related

How to override method not available in target platform, but available in Base SDK

I'm trying to add support for newer iOS devices while maintaining compatibility with older ones. Using Xcode 11.1, I've set the target iOS platform to 9.3, in General -> Deployment Info -> Target.
In Build Settings, the Base SDK just says iOS, so I'm assuming it's always the latest that Xcode supports.
I'm trying to make the Home Indicator disappear in iPhoneX and 11, but for that you have to override this method,
override func prefersHomeIndicatorAutoHidden() -> Bool
{
return true
}
However, I get this build error:
Method does not override any method from its superclass
I tried using the #available syntax like this,
#available(iOS 11.0, *)
override func prefersHomeIndicatorAutoHidden() -> Bool
{
return true
}
But I get the same build error. If I check the Quick Help on that method, it doesn't point to Apple's documentation, whereas on another game where the target is set to iOS 11, the Quick Help does point to the right place.
I don't want to change the target to a newer one because that would break compatibility with older phones. Is this a matter of hard-coding the Base SDK or something?
Edit:
I accepted the first answer as valid, but I thought I would write down some clarifications, just in case someone else gets stuck in something similar:
If you have updated your project to the latest Swift, the Base SDK should be the latest by default.
If you haven't, your old code will still compile. That's why func prefersHomeIndicatorAutoHidden() still works in my other project, since it used to be a function (https://stackoverflow.com/a/52387441/1765629) and I haven't updated that project to Swift 5.
The above is independent of the deployment target, so it seems I don't even need the #available in this case. I assume the value will be ignored in older iOS targets.
as #Starsky points out,
#available(iOS 11.0, *)
override var prefersHomeIndicatorAutoHidden: Bool {
return true
}

How to load WebAssembly in iOS app via WKWebVIew or JSC

I'm trying to load and execute a WebAssembly .wasm from within a Swift-based, iOS app. I first attempted to use the JavaScriptCore Framework but the WebAssembly.* module wasn't available in the Context when I tried to evaluate a trivial script. I was able to confirm the WebAssembly isn't defined via the Safari Debugger Console.
I then attempted to use WKWebView because I'm led to believe that the lack of WebAssembly is due to JSC not supporting JIT, which WKWebView should. I got the same result.
Here's a trivial app running on an iPhone X 12.4 emulator, Xcode 10.3 and the WebKit Framework manually added to the project. Make sure to open Safari and Select "Developer>Simulator" for WKWebView debugger.
import UIKit
import WebKit
class ViewController: UIViewController {
#IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
}
#IBAction func onClick(_ sender: UIButton) {
let testWasm = """
if(typeof WebAssembly !== 'undefined') {
console.log("Hello, Wasm.");
} else {
console.log("No Wasm for you!");
}
"""
webView.evaluateJavaScript(testWasm)
}
}
Does iOS actually have a way to load WebAssembly into a Swift-based app?
I wanted to run some benchmarks with JSC to compare it with Wasm3.
Basically I run into the same situation and wasn't able to fix so far.
Wasm3 runs perfectly fine on iOS, and may suite your needs at the moment.
Currently you can't run WebAssembly with JSC on the simulator according to this comment.
It appears that JavaScriptCore now has a WebAssembly interpreter, as of Feb 2020.

Unity - IOS application.openUrl didn't work after build

I need help, i use application.OpenUrl for link in my app, (c# code), in unity, everythings work perfectly, but when i build it on my iphone, or ipad, the link didn't work..
Sorry for my english.
Here is the code :
public void onClick(Button btn)
{
string nombtn = btn.name;
if (infosNomUrl.ContainsKey(nombtn)) {
url = infosNomUrl[nombtn];
Application.OpenURL(url);
}
}
on iOS only the last link work.
But on Unity preview all links are working, is there a compatibility problem of OpenURL function on iOS ?
Thanks for the answer.

Could not install Xamarin.Mobile in PCL iOS Project

I'm trying to install Xamarin.Mobile in a PCL iOS project by NuGet and i'm gotting this error!
Could not install package 'xamstore-xamarin.mobile 0.7.1'. You are
trying to install this package into a project that targets
'Xamarin.iOS,Version=v1.0', but the package does not contain any
assembly references or content files that are compatible with that
framework. For more information, contact the package author.
This is my AppDelegate
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
Xamarin.FormsMaps.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
My SDK version is 10.1.
Xamarin.Mobile is working fine in Android Project.
Any idea how to fix this ?
Use the Microsoft Resolution of problems.
Clean your Solution and Rebuild again.
The Xamarin.Mobile NuGet package is not compatible with a PCL, hence the error. This DLL is meant to be installed into an iOS/Android/Windows app project. There is no cross-platform API for PCL use.
You could use this with a Shared Library instead. Or, you'll need to work in each platform project.
Instead of add the package of Xamarin.Mobile with NuGet, you can try adding Xamarin.Mobile as a component.
Right click the Components folder:
Search and select Xamarin.Mobile on Xamarin Components window:
It might work!

Why my iOS app fails / closes when I open it from iOS simulator?

I am developing a small Swift application. In Xcode, when I press run button or use cmd + R keyboard shortcut, simulator and my app runs as I expected. But in simulator, when I click my installed app's icon to run it my app appears for one second and crashes / fails with no error message or no log.
I'm new to iOS development and don't know is this a common issue or where I do wrong.
I've reset simulator content and settings by iOS Simulator Menu -> Reset Content and Settings... option.
I've restarted iOS simulator, Xcode and operating system (OS X) but the problem still existing.
I basically want to click my installed app's icon in simulator and run it. How can I fix this issue?
--
Edit due comments:
I don't touch AppDelegate.swift file. It is same as first generated. And I have only one ViewController class, ViewController.swift and methods are:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
login()
}
/// Login method
func login() {
// login methos's body
}
Ok, I've got solution. Thanks to #Phillip Mills for his comment. That comment helps me to find solution.
In System Log Queries, I found the report crash, like as follow:
Dyld Error Message:
Library not loaded: #rpath/Alamofire.framework/Alamofire
Referenced from: /Users/USER/Library/Developer/CoreSimulator/Devices/79ECB6DD-8AF9-42F7-8543-AF9F689258C0/data/Containers/Bundle/Application/126E829F-A5D3-48CE-B65A-C06CE811A679/MyAwesoneApp.app/MyAwesoneApp
Reason: image not found
And googled it, than found this issue from github: dyld: Library not loaded: #rpath/Alamofire.framework/Alamofire on my iPhone(iOS8) while debuging #101
I tried that I saw from screen shot and it works!
I forgot to add Alamofire framework to Link Binary With Libraries part.

Resources