Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hyperloop unknown or unsupported type (UIAlertController)

I'm trying out Hyperloop. And I'm trying to run a custom swift script I have in my project (like shown in the exmaple).

Here's my swift code:

import UIKit

public class MySwiftCode : NSObject {
    func SayHello() {
        let alertController = UIAlertController(title: "iOScreator", message: "Hello, world!", preferredStyle: UIAlertControllerStyle.Alert)
        alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))
    }
}

when compiling I get the following error message:

[INFO]  Generating metabase for swift MyFramework /Users/ophir/Documents/Appcelerator_Studio_Workspace/HyperloopApp/src/MySwift.swift
Swift Generation failed with unknown or unsupported type (UIAlertController) found while compiling /Users/ophir/Documents/Appcelerator_Studio_Workspace/HyperloopApp/src/MySwift.swift
2016-01-26T16:40:22.195Z | ERROR  | ti run exited with error code 1

UIAlertController is part of UIKit (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/) and from my understanding native code ran with Hyperloop won't need to wait for Appcelerator to implement it. So I'm wondering why this code doesn't run.

like image 410
developer82 Avatar asked Apr 01 '26 16:04

developer82


1 Answers

First of all, please make sure to use the latest Hyperloop version (at least 1.2.6). The following example code works for me (tested in the hyperloop-examples repository):

import UIKit

public class MySwiftView : UIImageView {
    convenience init () {
        self.init(image: UIImage.init(named:"swift.png"))
    }

    func SayHello() {
        let alertController = UIAlertController(title: "iOScreator", message: "Hello, world!", preferredStyle: UIAlertControllerStyle.Alert)
        alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))
    }

}

Also make sure to run the app with iOS 8 and later. Since its a non-proxy API, you need to validate it on your own. To set the minimum target to iOS8, add the following key in the <ios> section of your tiapp.xml:

<min-ios-ver>8.0</min-ios-ver>

like image 68
Hans Knöchel Avatar answered Apr 03 '26 06:04

Hans Knöchel