-
Notifications
You must be signed in to change notification settings - Fork 610
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
Swift Package Manager support is incomplete #500
Comments
This might be related to #496. To be honest, I haven't had a chance to look into that yet, but hopefully I can spend some time on OCMock next week. |
As mentioned in the other issue, this took a while but now there's a version (3.9.0) that should support Swift Package Manager. |
Versions 3.9.x can now be resolved by Swift Package Manager. Unfortunately, this still doesn't mean you can use OCMock as a dependency that way. The problem first mentioned in the following comment over a year ago still exists: #379 (comment) In summary:
In a different issue @paulb777 mentioned that it is possible to use dependencies with unsafe flags by referencing the commit hash, and there seems to be code for that, but I wasn't able to get this to work. Even when I add OCMock by commit hash I get the error message that "the package product 'OCMock' cannot be used as a dependency of this target because it uses unsafe build flags." It might be an option to distribute OCMock as a binary framework, but given the amount of time I've already invested in trying to support Swift Package Manager, this is nowhere near the top of my list of things to work on. |
I'll shorten the title of this issue (because it's not only about resolution any more), and pin it. |
Problem is that OCMock can't really work with SPM. See #500 for details.
About this issue, this works when you use the revision in the swiftpm. .package(name: "OCMock", url: "https://github.com/erikdoe/ocmock.git", .revision("afd2c6924e8a36cb872bc475248b978f743c6050")) |
I can confirm this works as @MapaX says. To use OCMock in an Xcode project, create e.g. an // swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "OCMockWrapper",
products: [
.library(name: "OCMockWrapper", targets: ["OCMockWrapper"])
],
dependencies: [
.package(name: "OCMock", url: "https://github.com/erikdoe/ocmock.git", .revision("afd2c6924e8a36cb872bc475248b978f743c6050"))
],
targets: [
.target(name: "OCMockWrapper", dependencies: [
.product(name: "OCMock", package: "OCMock")
])
]
) You’ll need a dummy source file in We’ve been using it this way for a while and it works well. The only downside is that if you use OCMock from other packages of your own in addition to the wrapper, they have to agree on the commit hash, but that hasn’t been a problem for us to ensure. |
## Summary - Fixes StripeConnect and StripeCardScan to compile on Xcode 16 - Adds Bitrise tests for Xcode 16 to ensure it compiles - Updates OCMock to an Xcode 16 compatible version Note: OCMock doesn't work with SPM unless you add the dependency via commit hash as opposed to release version. We're using the commit hash that corresponds to v3.9.4: - https://github.com/erikdoe/ocmock/releases/tag/v3.9.4 - erikdoe/ocmock#500 (comment) ## Motivation https://jira.corp.stripe.com/browse/MXMOBILE-2808 ## Testing - Verified this branch passes tests - Created a branch without the Connect fixes and verified it fails on CI: #4065 Manually tested CardScan example app: https://github.com/user-attachments/assets/cd9448d1-ca23-4396-82f4-05baa5430ffa
Hello. I am trying to use OCMock via Swift Package Manager. I am on XCode Version 13.0 beta (13A5154h).
At first, SPM is able to recognize the URL
https://github.com/erikdoe/ocmock.git
as an available Swift Package. But once I clickAdd Package
I get aPackage Resolution Failed
error message, preventing me from properly importing OCMock into my project.Here is the full screenshot. I highlighted the parts pertaining to OCMock, and not my project.
The text was updated successfully, but these errors were encountered: