FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(tns-platform-declarations): Generate iOS typings from iOS 12.1 S… · NativeScript/NativeScript@1c0218e · GitHub

Commit 1c0218e

Browse files
authored andcommitted
feat(tns-platform-declarations): Generate iOS typings from iOS 12.1 SDK (#6693)
* feat(tns-platform-declarations): Generate iOS typings from iOS 12.1 SDK * Instructions for generating iOS typescript definitions * Refactor `typings-gen.sh` to use {N} CLI and generate fuller metadata for the system libraries * Automatically generate `ios.d.ts` wrapper * Add interop pointers and references as alternatives to `string` for `char*` args (implemented in NativeScript/ios-jsc#1022) BREAKING CHANGE: Several enum values have changed because they have been wrongly generated. To migrate your app or plugin code use the new names of the following: * enum NSUnderlineStyle: - `StyleNone` -> `None` - `StyleSingle` -> `Single` - `StyleThick` -> `Thick` - `StyleDouble` -> `Double` * enum AVAudioSessionErrorCode: - `CodeNone` -> `None` - `CodeMediaServicesFailed` -> `MediaServicesFailed` - `CodeIsBusy` -> `IsBusy` - `CodeIncompatibleCategory` -> `IncompatibleCategory` - `CodeCannotInterruptOthers` -> `CannotInterruptOthers` - `CodeMissingEntitlement` -> `MissingEntitlement` - `CodeSiriIsRecording` -> `SiriIsRecording` - `CodeCannotStartPlaying` -> `CannotStartPlaying` - `CodeCannotStartRecording` -> `CannotStartRecording` - `CodeBadParam` -> `BadParam` - `CodeResourceNotAvailable` -> `ResourceNotAvailable` - `CodeUnspecified` -> `Unspecified` * fix(ui/text-base): Update NSUnderlineStyle.StyleSingle constant After the typings regeneration its and several others' names have changed to the expected `NSUnderlineStyle.Single`. * fix(tns-platform-declarations): Restore deprecated enum values In order to not introduce a breaking change in a patch version, we are keeping `Style...` and `Code...` values that have been wrongly generated till now. In the next major/minor release of the package when the typings are regenerated we can safely remove them. Revert to using the deprecated one's in `text-base.ios.ts` so that the introduction of this breaking change doesn't slip in undetected. * fix(application.ios): Directly call presetnNativeScriptApp We've been using `performSelectorWithObject` but it's declaration has been manually added. Moreover it's more convenient to directly call the method.
1 parent 562628f commit 1c0218e

85 files changed

Lines changed: 16114 additions & 540 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎tns-core-modules/application/application.ios.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class IOSApplication implements IOSApplicationDefinition {
150150
this.setWindowContent(args.root);
151151
} else {
152152
this._window = UIApplication.sharedApplication.delegate.window;
153-
}
153+
}
154154
}
155155

156156
@profile
@@ -294,7 +294,7 @@ export function start(entry?: string | NavigationEntry) {
294294
started = true;
295295

296296
if (!iosApp.nativeApp) {
297-
// Normal NativeScript app will need UIApplicationMain.
297+
// Normal NativeScript app will need UIApplicationMain.
298298
UIApplicationMain(0, null, null, iosApp && iosApp.delegate ? NSStringFromClass(<any>iosApp.delegate) : NSStringFromClass(Responder));
299299
} else {
300300
// TODO: this rootView should be held alive until rootController dismissViewController is called.
@@ -309,7 +309,7 @@ export function start(entry?: string | NavigationEntry) {
309309
rootView._setupAsRootView({});
310310
let embedderDelegate = NativeScriptEmbedder.sharedInstance().delegate;
311311
if (embedderDelegate) {
312-
embedderDelegate.performSelectorWithObject("presentNativeScriptApp:", controller);
312+
embedderDelegate.presentNativeScriptApp(controller);
313313
} else {
314314
let visibleVC = utils.ios.getVisibleViewController(rootController);
315315
visibleVC.presentViewControllerAnimatedCompletion(controller, true, null);
@@ -368,4 +368,4 @@ global.__onLiveSync = function () {
368368
}
369369

370370
livesync();
371-
}
371+
}

‎tns-core-modules/tns-core-modules.d.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,3 @@ interface Array<T> {
160160
//Dialogs
161161
declare function alert(message?: any): void;
162162
declare function confirm(message?: string): boolean;
163-
164-
// Embedding
165-
declare interface NativeScriptEmbedderDelegate /* NSObject */ {
166-
presentNativeScriptApp(any/* UIViewController*/): any;
167-
performSelectorWithObject(string, any): any;
168-
}
169-
170-
declare class NativeScriptEmbedder {
171-
public static sharedInstance(): NativeScriptEmbedder;
172-
public delegate: NativeScriptEmbedderDelegate;
173-
}

‎tns-core-modules/ui/text-base/text-base.ios.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,15 @@ export class TextBase extends TextBaseCommon {
154154
case "none":
155155
break;
156156
case "underline":
157+
// TODO: Replace deprecated `StyleSingle` with `Single` after the next typings update
157158
dict.set(NSUnderlineStyleAttributeName, NSUnderlineStyle.StyleSingle);
158159
break;
159160
case "line-through":
161+
// TODO: Replace deprecated `StyleSingle` with `Single` after the next typings update
160162
dict.set(NSStrikethroughStyleAttributeName, NSUnderlineStyle.StyleSingle);
161163
break;
162164
case "underline line-through":
165+
// TODO: Replace deprecated `StyleSingle` with `Single` after the next typings update
163166
dict.set(NSUnderlineStyleAttributeName, NSUnderlineStyle.StyleSingle);
164167
dict.set(NSStrikethroughStyleAttributeName, NSUnderlineStyle.StyleSingle);
165168
break;
@@ -196,7 +199,7 @@ export class TextBase extends TextBaseCommon {
196199
// UITextView's font seems to change inside.
197200
dict.set(NSFontAttributeName, this.nativeTextViewProtected.font);
198201
}
199-
202+
200203
const result = NSMutableAttributedString.alloc().initWithString(source);
201204
result.setAttributesRange(<any>dict, { location: 0, length: source.length });
202205
if (this.nativeTextViewProtected instanceof UIButton) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ios-typings-prj

‎tns-platform-declarations/README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ d.ts files require a lot of memory and CPU. Consider adding skipLibCheck option
3737
* To generate android dependencies use [android-dts-generator](https://github.com/NativeScript/android-dts-generator) with the appropriate android version and android support jars
3838
* To regenerate android-*.d.ts file use the **android-dts-generator** passing the corresponding android jar (described [here](https://github.com/NativeScript/android-dts-generator/blob/master/README.md#generate-definitons-for-android-sdk))
3939
* More details for using the **android-dts-generator** can be found in [this article](https://docs.nativescript.org/core-concepts/android-runtime/metadata/generating-typescript-declarations).
40+
41+
## Generate ios .d.ts files
42+
43+
The `.d.ts` files for iOS are generated using iOS Runtime's metadata generator. You can use the [typings-gen.sh](./typings-gen.sh) script like this:
44+
45+
```BASH
46+
./typings-gen.sh rc [<path-to-medatadata-generator-binary>]
47+
```
48+
Where `rc` can be an NPM tag/version of `tns-ios` that will be used for generating the typings. If the metadata generator to be used has not been released in NPM, you can optionally specify its path as a 2nd argument.
Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
/// <reference path="interop.d.ts" />
2+
/// <reference path="objc-x86_64/objc!ARKit.d.ts" />
3+
/// <reference path="objc-x86_64/objc!AVFoundation.d.ts" />
4+
/// <reference path="objc-x86_64/objc!AVKit.d.ts" />
25
/// <reference path="objc-x86_64/objc!Accelerate.d.ts" />
36
/// <reference path="objc-x86_64/objc!Accounts.d.ts" />
7+
/// <reference path="objc-x86_64/objc!AdSupport.d.ts" />
48
/// <reference path="objc-x86_64/objc!AddressBook.d.ts" />
59
/// <reference path="objc-x86_64/objc!AddressBookUI.d.ts" />
6-
/// <reference path="objc-x86_64/objc!AdSupport.d.ts" />
710
/// <reference path="objc-x86_64/objc!AppleTextureEncoder.d.ts" />
8-
/// <reference path="objc-x86_64/objc!ARKit.d.ts" />
9-
/// <reference path="objc-x86_64/objc!asl.d.ts" />
1011
/// <reference path="objc-x86_64/objc!AssetsLibrary.d.ts" />
1112
/// <reference path="objc-x86_64/objc!AudioToolbox.d.ts" />
12-
/// <reference path="objc-x86_64/objc!AVFoundation.d.ts" />
13-
/// <reference path="objc-x86_64/objc!AVKit.d.ts" />
14-
/// <reference path="objc-x86_64/objc!CallKit.d.ts" />
13+
/// <reference path="objc-x86_64/objc!AuthenticationServices.d.ts" />
14+
/// <reference path="objc-x86_64/objc!BusinessChat.d.ts" />
1515
/// <reference path="objc-x86_64/objc!CFNetwork.d.ts" />
16+
/// <reference path="objc-x86_64/objc!CallKit.d.ts" />
17+
/// <reference path="objc-x86_64/objc!CarPlay.d.ts" />
18+
/// <reference path="objc-x86_64/objc!ClassKit.d.ts" />
1619
/// <reference path="objc-x86_64/objc!CloudKit.d.ts" />
20+
/// <reference path="objc-x86_64/objc!CommonCrypto.d.ts" />
1721
/// <reference path="objc-x86_64/objc!Compression.d.ts" />
1822
/// <reference path="objc-x86_64/objc!Contacts.d.ts" />
1923
/// <reference path="objc-x86_64/objc!ContactsUI.d.ts" />
@@ -25,11 +29,12 @@
2529
/// <reference path="objc-x86_64/objc!CoreGraphics.d.ts" />
2630
/// <reference path="objc-x86_64/objc!CoreImage.d.ts" />
2731
/// <reference path="objc-x86_64/objc!CoreLocation.d.ts" />
28-
/// <reference path="objc-x86_64/objc!CoreMedia.d.ts" />
2932
/// <reference path="objc-x86_64/objc!CoreMIDI.d.ts" />
3033
/// <reference path="objc-x86_64/objc!CoreML.d.ts" />
34+
/// <reference path="objc-x86_64/objc!CoreMedia.d.ts" />
3135
/// <reference path="objc-x86_64/objc!CoreMotion.d.ts" />
3236
/// <reference path="objc-x86_64/objc!CoreNFC.d.ts" />
37+
/// <reference path="objc-x86_64/objc!CoreServices.d.ts" />
3338
/// <reference path="objc-x86_64/objc!CoreSpotlight.d.ts" />
3439
/// <reference path="objc-x86_64/objc!CoreTelephony.d.ts" />
3540
/// <reference path="objc-x86_64/objc!CoreText.d.ts" />
@@ -38,70 +43,67 @@
3843
/// <reference path="objc-x86_64/objc!DeviceCheck.d.ts" />
3944
/// <reference path="objc-x86_64/objc!Dispatch.d.ts" />
4045
/// <reference path="objc-x86_64/objc!DispatchIntrospection.d.ts" />
41-
/// <reference path="objc-x86_64/objc!dnssd.d.ts" />
4246
/// <reference path="objc-x86_64/objc!EventKit.d.ts" />
4347
/// <reference path="objc-x86_64/objc!EventKitUI.d.ts" />
4448
/// <reference path="objc-x86_64/objc!ExternalAccessory.d.ts" />
4549
/// <reference path="objc-x86_64/objc!FileProvider.d.ts" />
4650
/// <reference path="objc-x86_64/objc!FileProviderUI.d.ts" />
4751
/// <reference path="objc-x86_64/objc!Foundation.d.ts" />
52+
/// <reference path="objc-x86_64/objc!GLKit.d.ts" />
53+
/// <reference path="objc-x86_64/objc!GSS.d.ts" />
4854
/// <reference path="objc-x86_64/objc!GameController.d.ts" />
4955
/// <reference path="objc-x86_64/objc!GameKit.d.ts" />
5056
/// <reference path="objc-x86_64/objc!GameplayKit.d.ts" />
51-
/// <reference path="objc-x86_64/objc!GLKit.d.ts" />
52-
/// <reference path="objc-x86_64/objc!GSS.d.ts" />
5357
/// <reference path="objc-x86_64/objc!HealthKit.d.ts" />
5458
/// <reference path="objc-x86_64/objc!HealthKitUI.d.ts" />
5559
/// <reference path="objc-x86_64/objc!HomeKit.d.ts" />
56-
/// <reference path="objc-x86_64/objc!iAd.d.ts" />
60+
/// <reference path="objc-x86_64/objc!ICU.d.ts" />
61+
/// <reference path="objc-x86_64/objc!IOSurface.d.ts" />
5762
/// <reference path="objc-x86_64/objc!IdentityLookup.d.ts" />
63+
/// <reference path="objc-x86_64/objc!IdentityLookupUI.d.ts" />
5864
/// <reference path="objc-x86_64/objc!ImageIO.d.ts" />
5965
/// <reference path="objc-x86_64/objc!Intents.d.ts" />
6066
/// <reference path="objc-x86_64/objc!IntentsUI.d.ts" />
61-
/// <reference path="objc-x86_64/objc!IOSurface.d.ts" />
6267
/// <reference path="objc-x86_64/objc!JavaScriptCore.d.ts" />
63-
/// <reference path="objc-x86_64/objc!libkern.d.ts" />
6468
/// <reference path="objc-x86_64/objc!LocalAuthentication.d.ts" />
6569
/// <reference path="objc-x86_64/objc!MachO.d.ts" />
6670
/// <reference path="objc-x86_64/objc!MapKit.d.ts" />
6771
/// <reference path="objc-x86_64/objc!MediaAccessibility.d.ts" />
6872
/// <reference path="objc-x86_64/objc!MediaPlayer.d.ts" />
6973
/// <reference path="objc-x86_64/objc!MediaToolbox.d.ts" />
70-
/// <reference path="objc-x86_64/objc!Messages.d.ts" />
7174
/// <reference path="objc-x86_64/objc!MessageUI.d.ts" />
75+
/// <reference path="objc-x86_64/objc!Messages.d.ts" />
7276
/// <reference path="objc-x86_64/objc!Metal.d.ts" />
7377
/// <reference path="objc-x86_64/objc!MetalKit.d.ts" />
7478
/// <reference path="objc-x86_64/objc!MetalPerformanceShaders.d.ts" />
75-
/// <reference path="objc-x86_64/objc!MobileCoreServices.d.ts" />
7679
/// <reference path="objc-x86_64/objc!ModelIO.d.ts" />
7780
/// <reference path="objc-x86_64/objc!MultipeerConnectivity.d.ts" />
81+
/// <reference path="objc-x86_64/objc!NativeScriptEmbedder.d.ts" />
82+
/// <reference path="objc-x86_64/objc!NaturalLanguage.d.ts" />
83+
/// <reference path="objc-x86_64/objc!Network.d.ts" />
7884
/// <reference path="objc-x86_64/objc!NetworkExtension.d.ts" />
7985
/// <reference path="objc-x86_64/objc!NewsstandKit.d.ts" />
8086
/// <reference path="objc-x86_64/objc!NotificationCenter.d.ts" />
8187
/// <reference path="objc-x86_64/objc!ObjectiveC.d.ts" />
8288
/// <reference path="objc-x86_64/objc!OpenAL.d.ts" />
8389
/// <reference path="objc-x86_64/objc!OpenGLES.d.ts" />
84-
/// <reference path="objc-x86_64/objc!os_object.d.ts" />
85-
/// <reference path="objc-x86_64/objc!os.d.ts" />
86-
/// <reference path="objc-x86_64/objc!PassKit.d.ts" />
8790
/// <reference path="objc-x86_64/objc!PDFKit.d.ts" />
91+
/// <reference path="objc-x86_64/objc!PassKit.d.ts" />
8892
/// <reference path="objc-x86_64/objc!Photos.d.ts" />
8993
/// <reference path="objc-x86_64/objc!PhotosUI.d.ts" />
9094
/// <reference path="objc-x86_64/objc!PushKit.d.ts" />
9195
/// <reference path="objc-x86_64/objc!QuartzCore.d.ts" />
9296
/// <reference path="objc-x86_64/objc!QuickLook.d.ts" />
9397
/// <reference path="objc-x86_64/objc!ReplayKit.d.ts" />
98+
/// <reference path="objc-x86_64/objc!SQLite3.d.ts" />
9499
/// <reference path="objc-x86_64/objc!SafariServices.d.ts" />
95100
/// <reference path="objc-x86_64/objc!SceneKit.d.ts" />
96101
/// <reference path="objc-x86_64/objc!Security.d.ts" />
97-
/// <reference path="objc-x86_64/objc!simd.d.ts" />
98102
/// <reference path="objc-x86_64/objc!Social.d.ts" />
99103
/// <reference path="objc-x86_64/objc!Speech.d.ts" />
100104
/// <reference path="objc-x86_64/objc!SpriteKit.d.ts" />
101-
/// <reference path="objc-x86_64/objc!SQLite3.d.ts" />
102105
/// <reference path="objc-x86_64/objc!StoreKit.d.ts" />
103106
/// <reference path="objc-x86_64/objc!SystemConfiguration.d.ts" />
104-
/// <reference path="objc-x86_64/objc!TKLiveSync.d.ts" />
105107
/// <reference path="objc-x86_64/objc!TNSWidgets.d.ts" />
106108
/// <reference path="objc-x86_64/objc!Twitter.d.ts" />
107109
/// <reference path="objc-x86_64/objc!UIKit.d.ts" />
@@ -113,6 +115,15 @@
113115
/// <reference path="objc-x86_64/objc!WatchConnectivity.d.ts" />
114116
/// <reference path="objc-x86_64/objc!WatchKit.d.ts" />
115117
/// <reference path="objc-x86_64/objc!WebKit.d.ts" />
118+
/// <reference path="objc-x86_64/objc!_Builtin_intrinsics.d.ts" />
119+
/// <reference path="objc-x86_64/objc!asl.d.ts" />
120+
/// <reference path="objc-x86_64/objc!dnssd.d.ts" />
121+
/// <reference path="objc-x86_64/objc!iAd.d.ts" />
122+
/// <reference path="objc-x86_64/objc!libkern.d.ts" />
123+
/// <reference path="objc-x86_64/objc!libxml2.d.ts" />
124+
/// <reference path="objc-x86_64/objc!libxslt.d.ts" />
125+
/// <reference path="objc-x86_64/objc!os.d.ts" />
126+
/// <reference path="objc-x86_64/objc!os_object.d.ts" />
127+
/// <reference path="objc-x86_64/objc!simd.d.ts" />
116128
/// <reference path="objc-x86_64/objc!zlib.d.ts" />
117-
118129
declare function __collect(): void;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL