Swiftpack.co -  ryanwilson/Repro-SwiftPMMinVersionBuild as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
ryanwilson/Repro-SwiftPMMinVersionBuild
A simplified repro showing building and archiving iOS apps with older iOS versions to solve https://github.com/firebase/firebase-ios-sdk/issues/7785
.package(url: "https://github.com/ryanwilson/Repro-SwiftPMMinVersionBuild.git", from: "1.0.0")

SwiftPM Min iOS Version Issue

This repo demonstrates an issue with Xcode linking against newer APIs (in this case, SwiftUI). Originally discovered in https://github.com/firebase/firebase-ios-sdk/issues/7785.

Use Case

This package wants to offer a new API for those users who are using SwiftUI, but still providing default functionality that is available for older iOS versions. All APIs are marked appropriately with @available checks.

Steps to Reproduce

  1. Create a new iOS project in Xcode (12.5 is the latest as of this writing).

  2. Click "File -> Swift Packages -> Add Package Dependency..."

  3. Enter the URL of this repo (https://github.com/ryanwilson/Repro-SwiftPMMinVersionBuild). Use the default version.

  4. Leave the default Package Product enabled and hit "Finish".

  5. Change the build target to "Any iOS Device (arm64)".

  6. Attempt to build.

Expected Behaviour

A successful build, since no APIs are being used outside of their iOS version availability.

Actual Behaviour

Swift compiler error with the following messages:

<LocalPath>/Sources/SwiftPMMinVersionIssue/ShinyAPI.swift:16:25: Cannot find type 'View' in scope
<LocalPath>/Sources/SwiftPMMinVersionIssue/ShinyAPI.swift:13:25: Cannot find type 'View' in scope

Even if the targeted iOS version in the Xcode project is 14.0, it still fails to compile.

Workarounds

Changing the minimum supported iOS version in this repo to .v11 resolves the issue. This can be observed by switching the SwiftPM checkout to the branch named fixed.

Thoughts

We ran into a similar error when building for an API available on iOS 11+ - perhaps it's a 32 bit transition issue?

GitHub

link
Stars: 0
Last commit: 2 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API