Skip to content

Add support for Swift version independence#18637

Merged
alalek merged 2 commits intoopencv:masterfrom
komakai:build-for-distribution
Oct 23, 2020
Merged

Add support for Swift version independence#18637
alalek merged 2 commits intoopencv:masterfrom
komakai:build-for-distribution

Conversation

@komakai
Copy link
Copy Markdown
Contributor

@komakai komakai commented Oct 21, 2020

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch

This PR addresses #18489

  • when building with CMake 3.19 or greater and Xcode 12 or greater generate swiftinterface files
  • improvements to the autogenerated Xcode project for Xcode New Build system
  • add support for standard module properties VersionNumber and VersionString
  • when build with older versions of CMake and/or Xcode continue to build as before (without generating swiftinterface files)
force_builders=Custom Mac
build_image:Custom Mac=osx_framework

@komakai komakai changed the title Add support for Swift "ABI Stability" Add support for Swift version independence Oct 21, 2020
@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 22, 2020

@AlvarHHM Could you please check this patch in your configuration?

@AlvarHHM
Copy link
Copy Markdown

It will certainly work if I compile it myself with my own Xcode 12. The question should be does this patch solve the forward compatibility issue, i.e. can I import the binary compiled with Xcode 11 in Xcode 12.

@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 22, 2020

@AlvarHHM I have scheduled iOS package build for PR on our CI with Xcode 11.

Artifacts should be available in 60-90 minutes (link is provided by step 7 "upload artifacts", but please expect that network external bandwidth of CI is limited)

@komakai
Copy link
Copy Markdown
Contributor Author

komakai commented Oct 22, 2020

@AlvarHHM @alalek as per the explanation above - you will only get a version independent build when building with Xcode 12 (or greater) together with CMake 3.19 (or greater). This is due to the required functionality (support for Xcode new build system) not being available in earlier CMake versions due to bugs in Xcode that have only now been fixed in Xcode 12

@AlvarHHM
Copy link
Copy Markdown

I just tried, this does not work.

It shows the same error Module compiled with Swift 5.1.2 cannot be imported by the Swift 5.3 compiler

@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 22, 2020

@AlvarHHM Thank you for the checking!

Unfortunately there is no CMake 3.19 on our Mac OS X machines yet. This is critical for this patch as @komakai mentioned above.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you 👍

@alalek alalek merged commit 72dfd48 into opencv:master Oct 23, 2020
@sjang42
Copy link
Copy Markdown

sjang42 commented Nov 20, 2020

Is this tested? I just built master branch with Xcode12.1 and run it with Xcode12.2 but it does not work.
Below is the error message. CMake version is 3.19.20201115-g75ced70 (master branch also)
Failed to build module 'OpenCV' from its module interface; the compiler that produced it, 'Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)', may have used features that aren't supported by this compiler, 'Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)'

@sjang42 sjang42 mentioned this pull request Nov 20, 2020
4 tasks
@alalek alalek mentioned this pull request Nov 27, 2020
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
Add support for Swift version independence

* Build for distribution (Swift version independence) when new Xcode build system is available

* Add module map and set "Defines Modules" flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants