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

Enable Module Stability #68

Open
rockbruno opened this issue Mar 26, 2021 · 5 comments
Open

Enable Module Stability #68

rockbruno opened this issue Mar 26, 2021 · 5 comments

Comments

@rockbruno
Copy link
Owner

https://twitter.com/rockbruno_/status/1375472185943470082

We can now enable module stability so new versions don't need to be built.

@andre-alves
Copy link
Contributor

I tried some things but couldn't make it work...

	@swift build \
		-c release \
		--disable-sandbox \
		--build-path "$(BUILDDIR)" \
		-Xswiftc \
		-emit-module-interface \
		-Xswiftc \
		-enable-library-evolution \
		-Xswiftc \
		-swift-version \
		-Xswiftc 5

Note: I had to force -swift-version, otherwise it prints a warning:

<unknown>:0: warning: module interfaces are only supported with Swift language version 5 or later (currently using -swift-version 4.2)

(probably because PathKit dependency is still using // swift-tools-version:4.2)

Then, I moved the generated .swiftinterface files inside swiftinfo/include and changed my Xcode version with xcode-select but got other errors:

./Infofile.swift:1:8: error: failed to build module 'SwiftInfoCore' from its module interface; the compiler that produced it, 'Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)', may have used features that aren't supported by this compiler, 'Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)'
import SwiftInfoCore

@rockbruno
Copy link
Owner Author

In the project where I used this (and it worked) I used -Xswiftc \"-emit-module-interface\" -Xswiftc \"-emit-module\" -Xswiftc \"-enable-library-evolution\"", maybe the emit-module makes the difference?

@andre-alves
Copy link
Contributor

andre-alves commented May 6, 2021

After more digging, I did manage to enable module stability successfuly and tested the same binary with Swift 5.3.2 and Swift 5.4.

Unfortunately, it was not clean. Here are the changes:
master...andre-alves:module-stability

  1. I added flags -emit-module-interface and -enable-library-evolution. Didn't need to include -emit-module;
  2. Also had to force -swift-version 5 because PathKit dependency is using Swift 4.2;
  3. Move *.swiftinterface files inside the package;
  4. Remove *.swiftmodules, otherwise, I would still get this error:
./Infofile.swift:1:8: error: failed to build module 'SwiftInfoCore' from its module interface; the compiler that produced it, 'Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)', may have used features that aren't supported by this compiler, 'Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)'
import SwiftInfoCore
  1. Edited XcodeProj.swiftinterface, removing XcodeProj. module references because there is a bug when a type has the same name as its module: https://forums.swift.org/t/frameworkname-is-not-a-member-type-of-frameworkname-errors-inside-swiftinterface/28962

It works but it's hacky. What do you think?

@rockbruno
Copy link
Owner Author

Holy crap, the XcodeProj one is unfortunate. My fear with that one is that they'll change something in Swift and we'll end up with broken interfaces. I think we can ask them to change the name of the library, I can do that. The other workarounds are fine, we aren't supposed to ship all the files (I started doing that because I thought it would fix the stability once)

@rowwingman
Copy link

@rockbruno do you have any plans on renaming the library or main swift file? Btw I install the 2.6 with brew, and it is still has an error: module map file '/usr/local/bin/../include/swiftinfo/Csourcekitd/include/module.modulemap' not found
./Infofile.swift:2:8: error: no such module 'SwiftInfoCore'
import SwiftInfoCore
^

Any ideas? Do you have the same with pods?

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

No branches or pull requests

3 participants