Skip to content

Commit

Permalink
Introduce Swift Package Manager Support (#86)
Browse files Browse the repository at this point in the history
* last change

* Revert "last change"

This reverts commit 92123ec.

* added package.swift file

* moved test files into a test directory for package file to reference.

* moved Package.swift to top level directory

* Moved all files under Sources and Tests directory

* Updating source file name from ReactiveExtensions to ReactiveExtensions-iOS

* Renamed source folder from ReactiveExtensions-TestHelpers to ReactiveExtensions-TestHelpers-iOS

* Added ReactiveSwift dependency to Package.swift

* Update target dependencies on SPM package ReactiveSwift

* Add In Foundation in Link Binary with Libraries Build Phase

* Oddly Foundation import failing when in another public package.

Foundation import, which is the base iOS library for any Swift related code.

* Renamed ReactiveExtensions-iOS to ReactiveExtensions, ReactiveExtensions-TestHelpers-iOS to ReactiveExtensions-TestHelpers

* Updated to latest xcode and newer iOS versions.

* Updated target names to match library names.

This might fix an issue when this framework is imported of not being able to import ReactiveExtensions. Previously ReactiveExtensions was the library name but not the target name.

* removed dependency because it might be interrupting another ReactiveSwift Carthage dependency when imported inside Kickstarter.

* trigger SPM update to Package.swift

* triggering spm update.

* triggering spm update.

* lock reactiveswift version and make it a named dependency so we dont have to import it after we import reactiveextensions.

* added Foundation as being a linker setting in the targets. Hope is it will be exposed when the package is resolved in the consumer.

* Updated location of Info.plist in project file now all targets are building.

* trying Foundation as a dependency

* correctly broken package.swift

* removed git submodule of ReactiveSwift dependency and replaced with SPM package

* all targets building with xcode 14.2. Tests are/were failing since the last xcode upgrade. fix next.

* tests are working now with cmd+u

needed to remove linked binaries because they were listed as dependencies in the test targets.

* updated package manifest to include tvOS because its now compiling and tests are running against it.

* Updated deployment target for main project.

* bumped current project version from 1 to 2

* updated ci for newer version of xcode.

* triggering ci build

* updated ci file for supported devices. bin/test works locally at least.

* updated ci file to support iPhone 8 simulator.

* updated to use iOS 15 and 16 with specific devices available on CI's xcode version 14.2.0

* updated ci file to prestart simulators - its still referencing the iPhone 8 somewhere.

* added a few simluator preload steps and a default environmnent. Hoping to get past the destination specifier error.

* update ci file to test tv and ios in separate jobs reflecting how config.yml works with ios-oss

* moved steps around to lint before preload simulator

* moved lint step right after checkout...not sure why its failing.

* added a makefile

* removed bootstrap step - unneeded

* spacing might make this work...

* syntax corrections

* simplified file so '-' might be recognized by scheme

* minor modifications

* updated tv os sim name, renamed artifact steps

* this file might be why the import is failing in SPM

* updated package paths for tvOS

* changed around the dependency download requirement to be less specific

* tried some more submodule cleanup.

* Ok consolidated iOS and tvOS into one main target, test helper target and testing target.

The framework can still be tested against both platforms...just allows SPM to easily import one set of dependencies.

* addressed warnings - tests passing

* Addressed some recommended settings from xcode 14.2

* More recommended build settings.

* trigger build on ci

* updated ci file to run tvOS and iOS test jobs using the same target

* linter fixes

* update makefile to reference on scheme for both jobs

* added minimum versions to the spm import. Might solve an issue with version targeting with Swift 5.6.2

* updated minimum base version of dependency
  • Loading branch information
msadoon authored May 2, 2023
1 parent e3f7786 commit 36984cc
Show file tree
Hide file tree
Showing 98 changed files with 616 additions and 1,156 deletions.
139 changes: 139 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
version: 2.1

xcode_version: &xcode_version 14.2.0
iphone_name: &iphone_name iPhone 14 Pro Max
preload_iphone_simulator: &preload_iphone_simulator xcrun instruments -w "iPhone 14 Pro Max (16.2) [" || true
apple_tv_name: &apple_tv_name Apple TV 4K (at 1080p) (2nd generation)
preload_apple_tv_simulator: &preload_apple_tv_simulator xcrun instruments -w "Apple TV 4K (at 1080p) (2nd generation) (16.1) [" || true

# Works around an issue in xcodebuild where it requires GitHub to have been added to the known_hosts in order for it to clone dependencies.
spm_ssh_workaround: &spm_ssh_workaround for ip in $(dig @1.1.1.1 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts

# Templates

ios_default_environment: &ios_default_environment
CIRCLE_ARTIFACTS: /tmp
BUNDLE_PATH: vendor/bundle
FL_OUTPUT_DIR: output
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
IPHONE_NAME: *iphone_name
XCODE_VERSION: *xcode_version
PLATFORM: iOS

tvos_default_environment: &tvos_default_environment
CIRCLE_ARTIFACTS: /tmp
BUNDLE_PATH: vendor/bundle
FL_OUTPUT_DIR: output
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
IPHONE_NAME: *apple_tv_name
XCODE_VERSION: *xcode_version
PLATFORM: tvOS

base_job: &base_job
macos:
xcode: *xcode_version
working_directory: ~/ReactiveExtensions

test_ios_setup_job: &test_ios_setup_job
steps:
- checkout
- run: HOMEBREW_NO_AUTO_UPDATE=1 brew install swiftlint
- run: set -o pipefail &&
swiftlint lint --strict --reporter json |
tee $CIRCLE_ARTIFACTS/swiftlint-report.json
- run:
name: SPM SSH Workaround
command: *spm_ssh_workaround
- run:
name: Store Xcode Version
command: xcodebuild -version > xcode_version.txt
- restore_cache:
name: Restore SPM Cache
keys:
- spm-cache-v1-{{ checksum "./ReactiveExtensions.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
- run:
name: Bootstrap SPM
command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
- run:
name: Pre-load iOS simulator
command: *preload_iphone_simulator
- run:
name: Run iOS Tests
command: make test-ios
no_output_timeout: "20m" # 20 minutes
- store_artifacts:
name: Swiftlint Artifacts
path: /tmp/swiftlint-report.json
- store_artifacts:
name: Xcode Artifacts
path: /tmp/xcode_raw.log

test_tvos_setup_job: &test_tvos_setup_job
steps:
- checkout
- run: HOMEBREW_NO_AUTO_UPDATE=1 brew install swiftlint
- run: set -o pipefail &&
swiftlint lint --strict --reporter json |
tee $CIRCLE_ARTIFACTS/swiftlint-report.json
- run:
name: SPM SSH Workaround
command: *spm_ssh_workaround
- run:
name: Store Xcode Version
command: xcodebuild -version > xcode_version.txt
- restore_cache:
name: Restore SPM Cache
keys:
- spm-cache-v1-{{ checksum "./ReactiveExtensions.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
- run:
name: Bootstrap SPM
command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
- run:
name: Pre-load iOS simulator
command: *preload_apple_tv_simulator
- run:
name: Run tvOS Tests
command: make test-tvos
no_output_timeout: "20m" # 20 minutes
- store_artifacts:
name: Swiftlint Artifacts
path: /tmp/swiftlint-report.json
- store_artifacts:
name: Xcode Artifacts
path: /tmp/xcode_raw.log


# Jobs

jobs:
# ReactiveExtensions-iOS tests
reactiveextensions-ios-tests:
<<: *base_job
<<: *test_ios_setup_job
environment:
- *ios_default_environment
- SCHEME=ReactiveExtensions

# Reactive-Extensions-tvOS tests
reactiveextensions-tvos-tests:
<<: *base_job
<<: *test_tvos_setup_job
environment:
- *tvos_default_environment
- SCHEME=ReactiveExtensions

# Workflows
workflows:
version: 2
build:
jobs:
- reactiveextensions-ios-tests
- reactiveextensions-tvos-tests

experimental:
notify:
branches:
only:
- master
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion Frameworks/ReactiveSwift
Submodule ReactiveSwift deleted from e03cda
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test-ios:
xcodebuild test -scheme ReactiveExtensions -destination platform='iOS Simulator',name='iPhone 14 Pro Max',OS=16.2

test-tvos:
xcodebuild test -scheme ReactiveExtensions -destination platform='tvOS Simulator',name='Apple TV 4K (3rd generation) (at 1080p)',OS=16.1
39 changes: 39 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// swift-tools-version:5.5
import PackageDescription

let package = Package(
name: "ReactiveExtensions",
platforms: [
.iOS(.v14),
.tvOS(.v14)
],
products: [
.library(
name: "ReactiveExtensions",
targets: ["ReactiveExtensions"]
),
.library(
name: "ReactiveExtensions-TestHelpers",
targets: ["ReactiveExtensions-TestHelpers"]
)
],
dependencies: [
.package(name: "ReactiveSwift", url: "https://github.com/ReactiveCocoa/ReactiveSwift",
.upToNextMajor(from: "7.1.1"))
],
targets: [
.target(name: "ReactiveExtensions", dependencies: ["ReactiveSwift"],
linkerSettings: [
.linkedFramework("Foundation")
]),
.testTarget(
name: "ReactiveExtensions-iOSTests",
dependencies: ["ReactiveExtensions", "ReactiveExtensions-TestHelpers"],
path: "Tests"
),
.target(name: "ReactiveExtensions-TestHelpers", dependencies: ["ReactiveSwift"],
linkerSettings: [
.linkedFramework("Foundation")
])
]
)
Loading

0 comments on commit 36984cc

Please sign in to comment.