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

CocoaPods and Swift 5.7 #56

Merged
merged 19 commits into from
Aug 16, 2023

Conversation

ypopovych
Copy link
Contributor

@ypopovych ypopovych commented Aug 11, 2023

  1. CocoaPods pod specs
  2. GA for tests
  3. GA for CocoaPods deployment

CocoaPods GitHub action workflow will need the COCOAPODS_TRUNK_TOKEN secret variable in the repository. How to obtain it: https://fuller.li/posts/automated-cocoapods-releases-with-ci/

@ypopovych ypopovych mentioned this pull request Aug 11, 2023
@oscbyspro
Copy link
Owner

Cool. I appreciate that you kept the import structure unchanged. I'll get around to it sometime next week or so.

Copy link
Owner

@oscbyspro oscbyspro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've read your pull request, and I appreciate the time took to support CocoaPods and add GitHub actions—that's great. It is a bit complicated, but only because #if available(...) does not exist. I took some notes for future reference:

Assumptions

  • modules and xcschemes
  • the version tag is prefixed by v
  • the podspec variable is called s
  • Package.swift contains let withStaticBigInt = true|false
  • COCOAPODS_TRUNK_TOKEN, SBI, NBK_FEATURE_StaticBigInt

Requirements

  • this repository needs a COCOAPODS_TRUNK_TOKEN secret

Files: pods/*

  • sets the SBI flag based on the NBK_FEATURE_StaticBigInt environment variable

Files: .github/workflows/test.yml

  • tests with or without NBK_FEATURE_StaticBigInt depending on Xcode version (macOS)
  • tests with or without NBK_FEATURE_StaticBigInt depending on Swift version (Linux)

Files: .github/workflows/deploy.yml

  • assigns podspec version based on GitHub release tag name
  • creates NBK_FEATURE_StaticBigInt from let withStaticBigInt = true|false in Package.swift
  • pushes 'Numberick', 'Numberick-CoreKit' and 'Numberick-DoubleWidthKit' to cocoapods.org

pods/Numberick-CoreKit.podspec Show resolved Hide resolved
@ypopovych
Copy link
Contributor Author

Files: .github/workflows/test.yml

* tests with or without NBK_FEATURE_StaticBigInt depending on `Xcode` version (`macOS`)

* tests with or without NBK_FEATURE_StaticBigInt depending on `Swift` version (`Linux`)

It also changes let withStaticBigInt = true|false in the Package.swift file

@oscbyspro oscbyspro changed the base branch from main to feature/cocoapods August 16, 2023 07:54
@oscbyspro oscbyspro merged commit 9880065 into oscbyspro:feature/cocoapods Aug 16, 2023
@oscbyspro
Copy link
Owner

I merged it into feature/cocoapods, where I'll play with it a bit prior to merging it into main.

@oscbyspro oscbyspro added the availability in an SDK near you label Aug 16, 2023
@oscbyspro oscbyspro added this to the Availability milestone Aug 16, 2023
@oscbyspro
Copy link
Owner

oscbyspro commented Aug 17, 2023

Do you know if you I can pass compiler flags to swift test? I'm trying to simplify the test.yml workflow. I like that it's testing the different configurations, but I think the Package.swift regex manipulation might be too complicated for this project. I've discovered that I can pass OTHER_SWIFT_FLAGS=-DSBI to xcodebuild test, but I haven't found a similar option for swift test (#60):

xcodebuild test -scheme "Numberick" -destination "platform=macOS" OTHER_SWIFT_FLAGS="-DSBI"

Edit: I think I found the solution:

swift test -Xswiftc -DSBI

@oscbyspro
Copy link
Owner

oscbyspro commented Aug 18, 2023

Never-mind, the SBI command-line flag only works when the correct platforms are added to Package.swift, otherwise the build fails because StaticBigInt requires macOS 13.3, etc. Hm. Is it even possible to do without regex? Package.swift does not respect command-line flags.  does not make this easy.


Edit: I can get it to work with 161 159 occurrences of:

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif

These make NBKDoubleWidth things unavailable prior to iOS 16.4, etc, when SBI is set.

oscbyspro added a commit that referenced this pull request Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
availability in an SDK near you
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants