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

[SR-11466] XCFramework requires to target iOS 13 for inter-framework dependencies with Objective-C compatibility (tested with Xcode 11 GM Seed) #53866

Open
swift-ci opened this issue Sep 13, 2019 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11466
Radar https://feedbackassistant.apple.com/feedback/7211660
Original Reporter brogrammer (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 314907ccaf24ff67564c388f1f8a3cfc

Issue Description:

There are two issues when using XCFramework for inter-framework dependencies with Objective-C compatibility which did not cause any problems when creating normal frameworks. It seems that the XCFramework issues can only be resolved when targeting iOS 13.0.

It would be quite convenient to have these issues resolved in order to distribute libraries compiled and bundled as XCFrameworks without sacrificing backwards compatibility for any iOS version older than iOS 13.

In order to demonstrate the two issues just build the DerivedFramework target with Xcode 11.0. The sample project can be found here: https://github.com/schiewe/XCFrameworkIssue 7

Issue 1) https://github.com/schiewe/XCFrameworkIssue/blob/f84ec25145f63f93badbe845a282bb21e18967eb/DerivedFramework/DerivedClass.swift#L8 2 causes a Method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C error.

Issue 2) https://github.com/schiewe/XCFrameworkIssue/blob/f84ec25145f63f93badbe845a282bb21e18967eb/DerivedFramework/DerivedClass.swift#L15 5 causes a '@objc' instance method in extension of subclass of 'BaseClass' requires iOS 13.0.0 error.

It seems like these issues are compiler bugs which will hopefully be fixed but it might also be a "feature".
What do you think?

@belkadan
Copy link
Contributor

Hm. It's specifically the combination of @objc and "Build Libraries for Distribution" (a prerequisite for XCFrameworks) that's causing the trouble here: the Swift implementation of ABI-stable classes is in some ways more flexible and in some ways more limited than Objective-C's, and so older Objective-C runtimes can't support them directly. @slavapestov, any insights to offer?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 5, 2019

Comment by Alex (JIRA)

Official answer from Apple in German:

Dies ist so erwartet. Die Verwendung von `@objc`-Methoden in Erweiterungen von `@objc`-Klassen beim Erstellen eines Framework für die Verteilung erforderte Änderungen an der Objective-C-Laufzeit, die nur in iOS 13 (und neuer) verfügbar sind. Du kannst entweder diese Methoden in die Klassendefinition selbst verschieben oder du verschiebst das `@objc`-Attribut.

In summary, yes, it is a confirmed limitation.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 7, 2019

Comment by Artem Loenko (JIRA)

@belkadan, can we mention this limitation somewhere in the documentation, please? Or update Swift 5.1 Release notes at least?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants