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

Switch to Swift Package Manager #527

Merged
merged 11 commits into from
Jun 11, 2021
Merged

Switch to Swift Package Manager #527

merged 11 commits into from
Jun 11, 2021

Conversation

taquitos
Copy link
Contributor

Supporting M1/X86_64 plus Xcode 12.5 for development has been a challenge with the current setup.

  • Removes carthage for testing dependencies and relies on SPM now
  • Added some helper functions since Nimble doesn't support expectAssertion() when built with SPM
  • Throw errors for bit manipulation instead of fatal()
  • Update Fastfile and CircleCI config

@taquitos
Copy link
Contributor Author

I tried to separate out some of these commits into individual PRs, but you can see the error of my ways. It was much easier to do 1 large-ish PR to fix the build issues.

Sorry!

@aboedo
Copy link
Member

aboedo commented Jun 11, 2021

@taquitos is this ready for review? if so feel free to request a review from the SDK team

@taquitos taquitos requested a review from a team June 11, 2021 16:11
@taquitos
Copy link
Contributor Author

Just force-pushed for a rebase on the swiftlint updates.

Copy link
Member

@aboedo aboedo left a comment

Choose a reason for hiding this comment

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

🎉🎉🎉🎉
looks great! left a few comments

carthage.sh Show resolved Hide resolved
Comment on lines 290 to 319

integration-tests-carthage:
macos:
xcode: "12.5.0"
working_directory: ~/purchases-ios/
shell: /bin/bash --login -o pipefail
steps:
- checkout
- trust-github-key
- update-carthage-integration-commit
# Carthage
- restore_cache:
keys:
- carthage-cache-{{ checksum "Cartfile.resolved" }}
- run:
name: Carthage Update
working_directory: IntegrationTests/CarthageIntegration/
# install without building, then remove the tests and build, so that carthage
# doesn't try to build the other integration tests
command: |
./carthage.sh update --no-build
rm -rf Carthage/Checkouts/purchases-root/IntegrationTests/
./carthage.sh build
- save_cache:
key: carthage-cache-{{ checksum "Cartfile.resolved" }}
paths:
- Carthage

- install-gems-scan-and-archive:
directory: IntegrationTests/CarthageIntegration/
Copy link
Member

Choose a reason for hiding this comment

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

these tests are to test that you can integrate our sdk using carthage, we should keep them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just making sure you were paying attention 👀

😄

@@ -2372,6 +2357,63 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
B3D5CFBB267282630056FA67 /* XCRemoteSwiftPackageReference "Nimble" */ = {
Copy link
Member

Choose a reason for hiding this comment

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

just double-checking:
since we have these dependencies at the target level, but not in Package.swift, clients of the SDK using SPM won't actually download them, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's my understanding, it's a dependency to build the test targets. Xcode might download them automatically because it could assume you want to make sure the tests pass, but I'm not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just tested with a new project, I pointed SPM to this branch and it only checked out the SDK 🎉

Screen Shot 2021-06-11 at 2 32 37 PM

Copy link
Member

Choose a reason for hiding this comment

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

:chefskiss:

Comment on lines 11 to 18
enum BitShiftError: Error {

case invalidIndex(_ index: UInt8)
case rangeFlipped(from: UInt8, to: UInt8)
case rangeLargerThanByte
case unhandledRange

}
Copy link
Member

Choose a reason for hiding this comment

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

👏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🕺

@@ -1,50 +1,52 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#include <Purchases/RCPurchases.h>
Copy link
Member

Choose a reason for hiding this comment

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

glad to see these alphabetized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It made my eye twitch when I read it. Sorry, I had to do it 😄


@interface RCObjC : NSObject

+ (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error;
Copy link
Member

Choose a reason for hiding this comment

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

should this method name reference its first param? we can always use NS_SWIFT_NAME to skip its name in swift

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not strongly opposed to either way, I'll update and see what you think about it!

@@ -99,7 +99,6 @@ platform :ios do
version_number = current_version_number
check_no_git_tag_exists(version_number)
check_pods
carthage_archive
Copy link
Member

Choose a reason for hiding this comment

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

this one is here to make sure that we can create a carthage archive. The contents get deployed with releases, so that carthage can use it by default instead of re-compiling whenever someone does carthage update Purchases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -123,7 +122,6 @@ platform :ios do
lane :deploy do |options|
version_number = current_version_number
push_pods
carthage_archive
Copy link
Member

Choose a reason for hiding this comment

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

we should keep the carthage_archive, since we're not removing compatibility with carthage, we're just not using it for development anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 210 to 214
# can't use fastlane carthage integration directly because of Carthage/Xcode 12 compatibility issues:
# https://github.com/Carthage/Carthage/issues/3019
Dir.chdir("..") do
sh("./carthage.sh", "build", "--no-skip-current")
sh("./carthage.sh", "archive", "Purchases")
Copy link
Member

Choose a reason for hiding this comment

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

with carthage 0.38 this is no longer true, so we should be able to do
carthage build --no-skip-current && carthage archive Purchases. So I'd update this but not remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -353,7 +297,6 @@ workflows:
- deployment-checks: *release-branches
- integration-tests-cocoapods: *release-tags-and-branches
- integration-tests-swift-package-manager: *release-tags-and-branches
- integration-tests-carthage: *release-tags-and-branches
Copy link
Member

Choose a reason for hiding this comment

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

we actually should probably run all of these tests on the branch since it makes structural changes, just to make sure that everything still works afterwards on all package managers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aboedo
Copy link
Member

aboedo commented Jun 11, 2021

@taquitos lmk when you'd like me to do another pass

@taquitos taquitos requested a review from aboedo June 11, 2021 21:03
@taquitos
Copy link
Contributor Author

@aboedo all ready for another pass 😃

Copy link
Member

@aboedo aboedo left a comment

Choose a reason for hiding this comment

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

thanks for doing this!! I left a couple of minor comments and it's ready to go

Comment on lines -1555 to -1557
/* Begin PBXShellScriptBuildPhase section */
2D49B31D253F7D1B003CBC8B /* Copy Carthage Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Copy link
Member

Choose a reason for hiding this comment

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

tears of joy

@@ -0,0 +1,84 @@
//
// ObjCThrowExceptionMatcher.swift
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should add a note here, pointing to the line in Nimble that specifies that their matcher doesn't work with SPM, so that future devs understand why we have our own matcher specifically for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ayyy makes sense.

}
}

func messageForError(error: NSError?, named: String?) -> ExpectationMessage {
Copy link
Member

Choose a reason for hiding this comment

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

let's make these private, since they're only meant to be inside this file but they're global

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@taquitos taquitos merged commit 79008f5 into main Jun 11, 2021
@taquitos taquitos deleted the fatalToError branch June 11, 2021 22:21
@aboedo aboedo mentioned this pull request Jul 13, 2021
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.

2 participants