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

Swift Package usage: Unable to build iOS targets #124

Closed
yanniks opened this issue Jul 18, 2023 · 4 comments · Fixed by #126
Closed

Swift Package usage: Unable to build iOS targets #124

yanniks opened this issue Jul 18, 2023 · 4 comments · Fixed by #126
Assignees
Labels
area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.)

Comments

@yanniks
Copy link
Contributor

yanniks commented Jul 18, 2023

Hi,

we are currently trying to migrate to this OpenAPI generator plugin. However, we noticed that builds of our Swift Package are no longer possible if the plugin is added to the target and an iOS Simulator is selected as target environment.

The following snippet is used to declare the target in the Package.swift file:

.target(
    name: "MyOAPIExample",
    dependencies: [
        .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
        "MyNetworkingLibrary",
    ],
    plugins: [
        .plugin(
            name: "OpenAPIGenerator",
            package: "swift-openapi-generator"
        ),
    ]
),

As soon as the plugin is added to the target, the build fails with the following issue:

error: The package product 'OpenAPIGenerator' requires minimum platform version 99.0 for the iOS platform, but this target supports 15.0 (in target 'MyOAPIExample' from project 'MyNetworking')

Builds who target macOS work fine. Is there any workaround that enables iOS builds?

Thanks & best regards,
Yannik

@czechboy0 czechboy0 added the status/triage Collecting information required to triage the issue. label Jul 18, 2023
@czechboy0
Copy link
Contributor

Hi @yanniks – I have a suspicion we might have regressed this in 0.1.4. Can you try to explicitly use version 0.1.3 of the generator as your dependency, and confirm that it works there?

@yanniks
Copy link
Contributor Author

yanniks commented Jul 18, 2023

Hi @czechboy0 , thanks for the quick response! I can confirm that this issue is related to the 0.1.4 release.

@czechboy0 czechboy0 self-assigned this Jul 18, 2023
@czechboy0 czechboy0 added area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.) and removed status/triage Collecting information required to triage the issue. labels Jul 18, 2023
czechboy0 added a commit that referenced this issue Jul 18, 2023
Lower unsupported platform minimum versions

### Motivation

Reported in #124.

In 0.1.4 (in PR #87), we improved the build time errors emitted when an adopter tries to link the generator binary itself to a product that runs on iOS, tvOS, etc (non-macOS/Linux).

Unfortunately, that broke the ability to build multi-platform packages for iOS and friends, as the minimum platform check would fail (we claim we support iOS "99"). 

Some build systems and IDEs don't correctly separate platform checks for plugins (which run on the host platform) and the final binary (which runs on the destination platform). We should help report these issues, but at the same time, we should fix this regression in 0.1.4 to work at least as well as 0.1.3 did.

### Modifications

Lower the minimum platforms to match the runtime library. This doesn't actually make the generate build correctly on these platforms (as we still have `PlatformChecks.swift`, which contains a hard, descriptive error when building on iOS and friends), it just allows passing the (incorrect) platform check in some cases.

### Result

Fixes #124.

Now, adopters can build on the same platforms they could with 0.1.3, and we still don't build on the unsupported platforms.

### Test Plan

Tested by using a local workspace and verified that with this change, a simple package that uses the generator can build for iOS.


Reviewed by: simonjbeaumont

Builds:
     ✔︎ pull request validation (5.8) - Build finished. 
     ✔︎ pull request validation (5.9) - Build finished. 
     ✔︎ pull request validation (docc test) - Build finished. 
     ✔︎ pull request validation (integration test) - Build finished. 
     ✔︎ pull request validation (nightly) - Build finished. 
     ✔︎ pull request validation (soundness) - Build finished. 

#126
@czechboy0
Copy link
Contributor

Fixed in 0.1.5, please try it again and confirm that it's working for you, @yanniks! 🙏

@yanniks
Copy link
Contributor Author

yanniks commented Jul 18, 2023

@czechboy0 issue is resolved in 0.1.5. Thanks for the quick release! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants