Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SDK API more Swift-friendly #2201

Merged
merged 41 commits into from
Oct 28, 2020
Merged

Make SDK API more Swift-friendly #2201

merged 41 commits into from
Oct 28, 2020

Conversation

DmitriyKirakosyan
Copy link
Contributor

@DmitriyKirakosyan DmitriyKirakosyan commented Oct 21, 2020

Things to consider before you submit the PR:

  • Has CHANGELOG.md been updated?
  • Are tests passing locally?
  • Are the files formatted correctly?
  • [ ] Did you add unit tests?
  • [ ] Did you check UI tests on the sample app? They are not executed on CI.
  • Did you test your change with either the sample apps that are included in the repository or with a blank app that uses your change?

Description

Updates SDK Swift API to make it more swifty.

NOTE: I's a breaking change!

Related PRs or issues

AB#83267

Dmitrii Chichuk and others added 13 commits October 20, 2020 12:26
* Changes in core module headers

* Make properties of class

* Make property out of enabled; Add swift class name

* Change logLevel to property

* Rearrange methods (to keep properties together)

* Fix format

* Add swift-friendly names

* Add property for logUrl

* Address PR feedbacks

* Add swift-friendly overloads

* Change swift signatures

* Convert the sets methods to properties.

* Reverted setCustomProperties changes

* Remove setters definition from properties

Co-authored-by: Anastasia Kubova <v-ankubo@microsoft.com>
Co-authored-by: Dima <v-dmkira@microsoft.com>
* Swiftify class names in Distribute module

* Swiftify methods in Distribute module

* Swiftify some properties

* [Distribute] Convert public setters to properties

* Remove redundant NS_SWIFT_NAME

* Addressed PR notes

Co-authored-by: Ivan Matkov <v-ivmatk@microsoft.com>
* Changes in core module headers

* Make properties of class

* Make property out of enabled; Add swift class name

* Change logLevel to property

* Rearrange methods (to keep properties together)

* Fix format

* Add swift-friendly names

* Add property for logUrl

* Add swifty names to Crashes module

* Address PR feedbacks

* Add swift-friendly overloads

* Add missing changes

* Resolve feedbacks

* Formatting the property

* Fix naming

* Resolve feedbacks

* Fix test

Co-authored-by: Dmitrii Chichuk <v-dmchic@microsoft.com>
* Changes in core module headers

* Make properties of class

* Make property out of enabled; Add swift class name

* Change logLevel to property

* Rearrange methods (to keep properties together)

* Fix format

* Add swift-friendly names

* Swiftify Analytics module

* Swiftify setters in Analytics

* Remove setters definition from properties

Co-authored-by: Dmitrii Chichuk <v-dmchic@microsoft.com>
Co-authored-by: Anastasia Kubova <v-ankubo@microsoft.com>
Co-authored-by: Ivan Matkov <v-ivmatk@microsoft.com>
* Update iOS apps

Co-authored-by: Anastasia Kubova <v-ankubo@microsoft.com>
Co-authored-by: Dmitriy Kirakosyan <v-dmkira@microsoft.com>
Co-authored-by: Dmitrii Chichuk <v-dmchic@microsoft.com>

* Update macOS apps

Co-authored-by: Anastasia Kubova <v-ankubo@microsoft.com>
Co-authored-by: Dmitriy Kirakosyan <v-dmkira@microsoft.com>
Co-authored-by: Dmitrii Chichuk <v-dmchic@microsoft.com>

* Update tvOS apps

Co-authored-by: Anastasia Kubova <v-ankubo@microsoft.com>
Co-authored-by: Dmitriy Kirakosyan <v-dmkira@microsoft.com>
Co-authored-by: Dmitrii Chichuk <v-dmchic@microsoft.com>

* Update comments in test apps

* Update some used API for core and crashes modules

Co-authored-by: Dmitriy Kirakosyan <v-dmkira@microsoft.com>
Co-authored-by: Dmitrii Chichuk <v-dmchic@microsoft.com>
@codecov-io

This comment has been minimized.

# Conflicts:
#	Sasquatch/SasquatchSwift/AppCenterDelegateSwift.swift
#	Sasquatch/SasquatchSwift/AppDelegate.swift
#	SasquatchMac/SasquatchMacSwift/AppCenterDelegateSwift.swift
#	SasquatchMac/SasquatchMacSwift/AppDelegate.swift
* Fixed property typo and removed redundant setter
* Added getCrashHandlerSetupDelegate back and marked deprecated
Jamminroot
Jamminroot previously approved these changes Oct 22, 2020
Copy link
Contributor

@iamclement iamclement left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is not easy thanks for looking at this :). I'll take another look couldn't get to the end.

AppCenter/AppCenter/MSACCustomProperties.h Outdated Show resolved Hide resolved
AppCenter/AppCenter/MSACEnable.h Show resolved Hide resolved
AppCenter/AppCenter/MSACAppCenter.h Outdated Show resolved Hide resolved
AppCenter/AppCenter/MSACAppCenter.h Outdated Show resolved Hide resolved
AppCenter/AppCenter/MSACAppCenter.h Show resolved Hide resolved
AppCenter/AppCenter/MSACAppCenter.h Outdated Show resolved Hide resolved
AppCenter/AppCenter/MSACAppCenter.h Outdated Show resolved Hide resolved
vvechkanov
vvechkanov previously approved these changes Oct 22, 2020
Co-authored-by: Clement Polet <clpolet@microsoft.com>
@DmitriyKirakosyan
Copy link
Contributor Author

The public delegates (e.g. MSACCrashesDelegate) have more complicated API names I feel like we should do a pass on them. Particularly paying attention to omit words that merely repeat type information.
Other than that I have seen all the files I wanted to review :).

Regarding the delegates, I think swift api already looks fine. Eg:

- (void)crashes:(MSACCrashes *)crashes didFailSendingErrorReport:(MSACErrorReport *)errorReport withError:(NSError *)error;

Resolves to swift as

func crashes(_ crashes: Crashes, didFailSending errorReport: ErrorReport, withError error: Error) {
}

Here is the place in swift code https://github.com/microsoft/appcenter-sdk-apple/blob/develop/Sasquatch/SasquatchSwift/AppDelegate.swift#L217

Do you think there still should be some additional swiftify changes applied?

@iamclement
Copy link
Contributor

iamclement commented Oct 27, 2020

The public delegates (e.g. MSACCrashesDelegate) have more complicated API names I feel like we should do a pass on them. Particularly paying attention to omit words that merely repeat type information.
Other than that I have seen all the files I wanted to review :).

Regarding the delegates, I think swift api already looks fine. Eg:

- (void)crashes:(MSACCrashes *)crashes didFailSendingErrorReport:(MSACErrorReport *)errorReport withError:(NSError *)error;

Resolves to swift as

func crashes(_ crashes: Crashes, didFailSending errorReport: ErrorReport, withError error: Error) {
}

Here is the place in swift code https://github.com/microsoft/appcenter-sdk-apple/blob/develop/Sasquatch/SasquatchSwift/AppDelegate.swift#L217

Do you think there still should be some additional swiftify changes applied?

This one should be fine but have you checked them all? I saw one yesterday that explicitly labeled ErrorReport. I'll double check.
Ah this one: func crashes(_ crashes: Crashes!, shouldProcessErrorReport errorReport: ErrorReport!) -> Bool

Co-authored-by: Ivan Matkov <v-ivmatk@microsoft.com>
MatkovIvan
MatkovIvan previously approved these changes Oct 28, 2020
Copy link
Contributor

@iamclement iamclement left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing, probably the last :). error or withError somehow is always explicitly labeled (e.g. NSApplicationdelegate, NSURLSessionDelegate)

@DmitriyKirakosyan
Copy link
Contributor Author

One thing, probably the last :). error or withError somehow is always explicitly labeled (e.g. NSApplicationdelegate, NSURLSessionDelegate)

Reverted the previous state for these methods, coz swift default conversion did it correctly. The only method that didn't translate automatically was func crashes(_ crashes: Crashes!, shouldProcessErrorReport errorReport: ErrorReport!) -> Bool, so I fixed it. Now all delegate method signatures are converted correctly in swift : https://github.com/microsoft/appcenter-sdk-apple/blob/develop/Sasquatch/SasquatchSwift/AppDelegate.swift#L211-L220

Also removed warning in sasquatch apps.

And converted MSACLogHandler and MSACLogMessageProvider to the short versions for swift.


NS_ASSUME_NONNULL_END

@end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move before NS_ASSUME_NONNULL_END

iamclement
iamclement previously approved these changes Oct 28, 2020
Copy link
Contributor

@iamclement iamclement left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MatkovIvan MatkovIvan merged commit 36d98b9 into develop Oct 28, 2020
@MatkovIvan MatkovIvan deleted the feature/swiftify-api branch October 28, 2020 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants