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

Parsing .swiftinterface form xcframework #1035

Conversation

rehsals
Copy link
Contributor

@rehsals rehsals commented Feb 28, 2022

Problem
Issue: #87
Our project is really big so we decided to use it's dependencies as binary XCFrameworks.
The problem is to mock types declared in modules from such binary frameworks which we manage with CocoaPods.
The idea to work this limitation around was to scan .swiftinterface file inside the xcframework.

Line of thought
At first I considered I could use sources key to set this up. But sources is mutually exclusive
with project which is an issue in our case. I gave it a try to make sources usable along with project
but it didn't work quite well. The thing is we need to use module name to namespace types in mocks. The case of matching
type names is not so rare. So sources was not entirely working. Another consideration was to scan .xcodeproj to find a path
to xcframework and add it to sources list. But CocoaPods makes target so placeholder-ish that there is no way that I could find
to extract that path.

Proposed solution
Finally I introduced optional key xcframework to configuration.

project:
  - file: "Pods/Pods.xcodeproj"
    target:
      - name: "Alamofire"
        xcframework: "Pods/Alamofire/Alamofire.xcframework"

This path is added to target and gets scaned. Some messy fiddling with paths inside .xcframework file could be avoided but
for now it just works. Also the xcframework key could be made an array (not done yet)

This Pull Request might not be the the right way to do it, but might as well be the starting point for a discussion.
I am sure there is a better way to achieve this.

@rehsals rehsals changed the title Feature/parsing swift interface Parsing .swiftinterface form xcframework Feb 28, 2022
@krzysztofzablocki
Copy link
Owner

this looks good to me, it solves the problem at hand and the code doesn't look bad or complicated.

Let's just add support for the array case 🔥

@rehsals
Copy link
Contributor Author

rehsals commented Mar 1, 2022

Great! Thanks. Then I'll spend some time making this PR mergeable

@rehsals rehsals marked this pull request as ready for review March 4, 2022 06:39
@rehsals
Copy link
Contributor Author

rehsals commented Mar 10, 2022

So I guess the PR is ready for review

@krzysztofzablocki krzysztofzablocki merged commit 75e91b5 into krzysztofzablocki:master Mar 21, 2022
@krzysztofzablocki
Copy link
Owner

thanks!

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

2 participants