Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24163] Hyperloop: iOS - Metabase generation fails for Swift-only classes from system frameworks

GitHub Issuen/a
TypeBug
PriorityHigh
StatusOpen
ResolutionUnresolved
Affected Version/sHyperloop 2.0.0
Fix Version/sn/a
ComponentsHyperloop, iOS
Labelsn/a
ReporterJan Vennemann
AssigneeJan Vennemann
Created2016-11-22T21:06:50.000+0000
Updated2017-11-10T17:08:46.000+0000

Description

Classes from system frameworks that are Swift exclusive can not be used in custom Swift code in Hyperloop. Example class: https://developer.apple.com/reference/foundation/url *Steps to reproduce the behavior* 1. Create a new Hyperloop enabled project 2. Add the following sample code under src/MySwift.swift:
import Foundation

public class MySwift {
  public func getUrl() -> URL {
    return URL(string: "http://appcelerator.com")!;
  }
}
3. Add a appc.js to the project root with the following content:
module.exports = {
	type: 'app',
	group: 'titanium',
	hyperloop: {
		ios: {
			thirdparty: {
				'MyFramework': {
					source: ['src'],
					header: 'src',
					resource: 'src'
				}
			}
		}
	}
};
4. Add var MySwift = require('MyFramework/MySwift'); to app/controller/index.js to trigger Hyperloop's metabase generation 5. Build the project with appc run -p ios *Actual behavior* The build fails with the following error: Swift Generation failed with unknown or unsupported type (URL) found while compiling /Users/jvennemann/Development/appc/swift-url/src/MySwift.swift *Expected behavior* The build succeeds and the metabase for Swift-only classes will be generated *Additional notes* The reason why this fails is because the import Foundation statement in the Swift source will be mapped to the Objective-C equivalent import <Foundation/Foundation.h>. Due to URL being Swift-only the metabase generator can not properly determine a type and fails. SourceKit may be a possible solution and needs some more investigation. See also: https://github.com/apple/swift-evolution/blob/master/proposals/0086-drop-foundation-ns.md

Comments

No comments

JSON Source