-
Notifications
You must be signed in to change notification settings - Fork 316
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
Conversation
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! |
@taquitos is this ready for review? if so feel free to request a review from the SDK team |
Nimble doesn't support raiseException() when built with SPM - paves way for SPM support and M1 support
Specify specific BitShiftError cases in test
Just force-pushed for a rebase on the swiftlint updates. |
There was a problem hiding this 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
.circleci/config.yml
Outdated
|
||
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/ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" */ = { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:chefskiss:
enum BitShiftError: Error { | ||
|
||
case invalidIndex(_ index: UInt8) | ||
case rangeFlipped(from: UInt8, to: UInt8) | ||
case rangeLargerThanByte | ||
case unhandledRange | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 😄
PurchasesTests/TestHelpers/RCObjC.h
Outdated
|
||
@interface RCObjC : NSObject | ||
|
||
+ (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
fastlane/Fastfile
Outdated
@@ -99,7 +99,6 @@ platform :ios do | |||
version_number = current_version_number | |||
check_no_git_tag_exists(version_number) | |||
check_pods | |||
carthage_archive |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
fastlane/Fastfile
Outdated
@@ -123,7 +122,6 @@ platform :ios do | |||
lane :deploy do |options| | |||
version_number = current_version_number | |||
push_pods | |||
carthage_archive |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
fastlane/Fastfile
Outdated
# 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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
.circleci/config.yml
Outdated
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
@taquitos lmk when you'd like me to do another pass |
@aboedo all ready for another pass 😃 |
There was a problem hiding this 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
/* Begin PBXShellScriptBuildPhase section */ | ||
2D49B31D253F7D1B003CBC8B /* Copy Carthage Frameworks */ = { | ||
isa = PBXShellScriptBuildPhase; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
Supporting M1/X86_64 plus Xcode 12.5 for development has been a challenge with the current setup.
expectAssertion()
when built with SPMfatal()