NativeScript / ios-jsc

NativeScript for iOS using JavaScriptCore
http://docs.nativescript.org/runtimes/ios
Apache License 2.0
298 stars 59 forks source link

Generating TSC declarations fails due to Metadata generator error w/specific imports #1233

Closed NickIliev closed 4 years ago

NickIliev commented 4 years ago

mobile platform: iOS platform version : iOS 13, xCode 11.2.1 Desktop OS: macOS 10.14.6 NativeScript CLI version: 6.1.2 Framework used : Angular with TypeScript Dependency: We are using the SDK PhotoEditor provided by Img.ly and available on cocoapods The code source of their iOS native example is available here: https://github.com/imgly/pesdk-ios-examples

Summary: When adding the cocoapod PhotoEditorSDK and running the the command $ TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios, the typings files generated don't contain inheritance for the class PESDKPhotoEditViewController. When using the same cocoapod in a Native iOS example, the class PhotoEditoViewController inherits from ImglyKit.MediaEditViewController.

Steps to reproduce:

target 'SwiftExample' do use_frameworks! pod 'PhotoEditorSDK', '~> 10.6.0' end

* Execute the command to generate the TypeScripts typings file

$ TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios

Open the generated file `typings/i386/objc!PhotoEditorSDK.d.ts`

**Expected:** the class `PESDKPhotoEditViewController` inherits from `PESDKMediaEditViewController` (delcared in `typings/i386/objc!ImglyKit.d.ts`)

**Actual:** the class inherits from nothing

**Description of the expected result**
If you create an iOS native project with Xcode and add the same Podfile, you will see that the class PhotoEditViewController is described like this in the PhotoEditorSDK:

/// A PhotoEditViewController is the main starting point for the SDK. It displays the rendered /// photo and a menu. It can present PhotoEditToolController objects and react to changes. It /// can be presented on its own (thus displaying a toolbar for navigation at the bottom) or be /// embedded into a UINavigationController (thus using the navigation controller's navigation bar /// for navigation). @available(iOS 9.0, iOS 9.0, *) @objcMembers @objc(PESDKPhotoEditViewController) open class PhotoEditViewController : ImglyKit.MediaEditViewController, ImglyKit.BrandedView { ..... }


**Why it's an issue**
We need to display a `PESDKPhotoEditViewController` in the view, and therefore it must inherit from `UIViewController`.

`MediaEditViewController` inherits `UIViewController`.
NickIliev commented 4 years ago

Related to t1445393

mbektchiev commented 4 years ago

The reason for the partially missing metadata (and respectively typescript definitions) is that the PhotoEditorSDK pod relies on Clang's modules feature. The metadata generator however, didn't support that, so we had to make it possible to turn modules on with #1236. After we merge the fix and release a version with it, you will just have to add the following line to your build.xcconfig file to correctly generate the metadata:

CLANG_ENABLE_MODULES = YES