diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..5eec115 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,33 @@ +name: Build + +on: + push: + branches: [ master ] + pull_request: + branches: '*' + +env: + DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer + +jobs: + iOS: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Build + run: xcodebuild -scheme "Rswift-iOS" + tvOS: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Build + run: xcodebuild -scheme "Rswift-tvOS" + watchOS: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Build + run: xcodebuild -scheme "Rswift-watchOS" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ebf96c1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: Release + +on: + release: + types: created + +env: + DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer + +jobs: + publish: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Publish to Cocoapods + run: | + export POD_VERSION=$(echo $TAG_NAME | cut -c2-) + pod trunk push + env: + TAG_NAME: ${{ github.event.release.tag_name }} + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} diff --git a/Library/UIKit/NibResource+UIKit.swift b/Library/UIKit/NibResource+UIKit.swift index 4339d3f..2875cc5 100644 --- a/Library/UIKit/NibResource+UIKit.swift +++ b/Library/UIKit/NibResource+UIKit.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import Foundation import UIKit @@ -23,3 +24,4 @@ public extension NibResourceType { return UINib(resource: self).instantiate(withOwner: ownerOrNil, options: optionsOrNil) } } +#endif diff --git a/Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift b/Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift index b5b114c..4ba1902 100644 --- a/Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift +++ b/Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import Foundation import UIKit @@ -20,3 +21,4 @@ public extension StoryboardResourceWithInitialControllerType { return UIStoryboard(resource: self).instantiateInitialViewController() as? InitialController } } +#endif diff --git a/Library/UIKit/TypedStoryboardSegueInfo+UIStoryboardSegue.swift b/Library/UIKit/TypedStoryboardSegueInfo+UIStoryboardSegue.swift index 5edd9be..894c8c2 100644 --- a/Library/UIKit/TypedStoryboardSegueInfo+UIStoryboardSegue.swift +++ b/Library/UIKit/TypedStoryboardSegueInfo+UIStoryboardSegue.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import Foundation import UIKit @@ -33,3 +34,4 @@ extension TypedStoryboardSegueInfo { self.destination = destination } } +#endif diff --git a/Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift b/Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift index bf68fa1..ebac685 100644 --- a/Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift +++ b/Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import Foundation import UIKit @@ -62,3 +63,4 @@ public extension UICollectionView { register(UINib(resource: nibResource), forSupplementaryViewOfKind: kind, withReuseIdentifier: nibResource.identifier) } } +#endif diff --git a/Library/UIKit/UINib+NibResource.swift b/Library/UIKit/UINib+NibResource.swift index 73bb048..8aaa0fd 100644 --- a/Library/UIKit/UINib+NibResource.swift +++ b/Library/UIKit/UINib+NibResource.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import UIKit public extension UINib { @@ -21,3 +22,4 @@ public extension UINib { self.init(nibName: resource.name, bundle: resource.bundle) } } +#endif diff --git a/Library/UIKit/UIStoryboard+StoryboardResource.swift b/Library/UIKit/UIStoryboard+StoryboardResource.swift index 8848be0..1ed8015 100644 --- a/Library/UIKit/UIStoryboard+StoryboardResource.swift +++ b/Library/UIKit/UIStoryboard+StoryboardResource.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import UIKit public extension UIStoryboard { @@ -21,3 +22,4 @@ public extension UIStoryboard { self.init(name: resource.name, bundle: resource.bundle) } } +#endif diff --git a/Library/UIKit/UIStoryboard+StoryboardViewControllerResource.swift b/Library/UIKit/UIStoryboard+StoryboardViewControllerResource.swift index 59adab3..75c61f0 100644 --- a/Library/UIKit/UIStoryboard+StoryboardViewControllerResource.swift +++ b/Library/UIKit/UIStoryboard+StoryboardViewControllerResource.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import Foundation import UIKit @@ -22,3 +23,4 @@ public extension UIStoryboard { return self.instantiateViewController(withIdentifier: resource.identifier) as? ViewControllerResource.ViewControllerType } } +#endif diff --git a/Library/UIKit/UITableView+ReuseIdentifierProtocol.swift b/Library/UIKit/UITableView+ReuseIdentifierProtocol.swift index 10d4b4f..aa6589e 100644 --- a/Library/UIKit/UITableView+ReuseIdentifierProtocol.swift +++ b/Library/UIKit/UITableView+ReuseIdentifierProtocol.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import Foundation import UIKit @@ -65,3 +66,4 @@ public extension UITableView { register(UINib(resource: nibResource), forHeaderFooterViewReuseIdentifier: nibResource.identifier) } } +#endif diff --git a/Library/UIKit/UIViewController+NibResource.swift b/Library/UIKit/UIViewController+NibResource.swift index dbef8ce..717bd09 100644 --- a/Library/UIKit/UIViewController+NibResource.swift +++ b/Library/UIKit/UIViewController+NibResource.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import Foundation import UIKit @@ -22,3 +23,4 @@ public extension UIViewController { self.init(nibName: nib.name, bundle: nib.bundle) } } +#endif diff --git a/Library/UIKit/UIViewController+StoryboardSegueIdentifierProtocol.swift b/Library/UIKit/UIViewController+StoryboardSegueIdentifierProtocol.swift index 27364a4..e7aff99 100644 --- a/Library/UIKit/UIViewController+StoryboardSegueIdentifierProtocol.swift +++ b/Library/UIKit/UIViewController+StoryboardSegueIdentifierProtocol.swift @@ -7,6 +7,7 @@ // License: MIT License // +#if !os(watchOS) import Foundation import UIKit @@ -37,3 +38,4 @@ public extension StoryboardSegue where Source : UIViewController { source.performSegue(withIdentifier: identifier.identifier, sender: sender) } } +#endif diff --git a/Package.swift b/Package.swift index cf94adc..a7e2267 100644 --- a/Package.swift +++ b/Package.swift @@ -5,12 +5,13 @@ import PackageDescription let package = Package( name: "R.swift.Library", platforms: [ - .iOS(.v8), + .iOS(.v9), .tvOS(.v9), .watchOS(.v2), ], products: [ - .library(name: "Rswift", targets: ["Rswift"]) + .library(name: "Rswift", targets: ["Rswift"]), + .library(name: "RswiftDynamic", type: .dynamic, targets: ["Rswift"]) ], targets: [ .target(name: "Rswift", path: "Library") diff --git a/R.swift.Library.podspec b/R.swift.Library.podspec index e899e61..9c9a766 100644 --- a/R.swift.Library.podspec +++ b/R.swift.Library.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |spec| spec.name = "R.swift.Library" - spec.version = "5.1.0" + spec.version = ENV['POD_VERSION'] spec.license = "MIT" spec.summary = "Companion library for R.swift, featuring types used to type resources" @@ -21,11 +21,11 @@ Pod::Spec.new do |spec| spec.pod_target_xcconfig = { 'APPLICATION_EXTENSION_API_ONLY' => 'YES' } - spec.ios.deployment_target = '8.0' + spec.ios.deployment_target = '11.0' spec.ios.source_files = "Library/**/*.swift" - spec.tvos.deployment_target = '9.0' + spec.tvos.deployment_target = '11.0' spec.tvos.source_files = "Library/**/*.swift" - spec.watchos.deployment_target = '2.2' + spec.watchos.deployment_target = '4.0' spec.watchos.source_files = ["Library/Core/*.swift", "Library/Foundation/*.swift"] spec.module_name = "Rswift" diff --git a/Readme.md b/Readme.md index e79efb8..4180ed7 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,8 @@ # R.swift.Library [](https://cocoapods.org/pods/R.swift) [](https://github.com/Carthage/Carthage) [](blob/master/License)  -_Library containing types supporting code generated by [R.swift](https://github.com/mac-cain13/R.swift)_ +⚠ As of version 7 of [R.swift](https://github.com/mac-cain13/R.swift), this separate library is no longer needed. R.swift is now a self contained library. + +This repository remains for older versions of R.swift. ## Why use this? diff --git a/fastlane/Fastfile b/fastlane/Fastfile deleted file mode 100644 index 5c2bb3b..0000000 --- a/fastlane/Fastfile +++ /dev/null @@ -1,98 +0,0 @@ -fastlane_version "1.86.0" - -lane :release do |options| - if options[:skip_branch_check] != true - ensure_git_branch(branch: "master") - end - - if options[:allow_dirty_branch] != true - ensure_git_status_clean - else - UI.message "Skipping the 'git status clean' check!".yellow - end - - git_pull - - runalltests - - unless is_ci - notification( - title: "R.swift.Library release", - message: "💡 Needs your attention." - ) - end - - currentVersion = version_get_podspec() - UI.message "Current R.swift.Library podspec version is #{currentVersion}" - - bumpType = prompt(text: "What kind of release is this? (major/minor/patch/custom)".green, boolean: false, ci_input: "") - isPrerelease = false - case bumpType - when "major", "minor", "patch" - version_bump_podspec(bump_type: bumpType) - when "custom" - newVersion = prompt(text: "What is the new custom version number?".green, boolean: false, ci_input: "") - version_bump_podspec(version_number: newVersion) - - isPrerelease = prompt(text: "Is this a prerelease version?".green, boolean: true, ci_input: "") - else - raise "Invalid release type: #{bumpType}".red - end - - changelog = prompt(text: "Please provide release notes:".green, boolean: false, ci_input: "", multi_line_end_keyword: "FIN") - - newVersion = version_get_podspec() - unless prompt(text: "#{newVersion} has been prepped for release. If you have any additional changes you would like to make, please do those before continuing. Would you like to commit, tag, push and release #{newVersion} including all uncommitted changes?".green, boolean: true, ci_input:"y") - raise "Aborted by user".red - end - - git_commit( - path: ".", - message: "Preparing for the #{newVersion} release" - ) - - push_to_git_remote - - af_create_github_release( - owner: "mac-cain13", - repository: "r.swift.library", - tag_name: "v#{newVersion}", - target_commitish: "master", - name: "#{newVersion}", - body: "#{changelog}", - prerelease: isPrerelease - ) - - pod_push - - unless is_ci - notification( - title: "R.swift.Library release", - message: "🎉 Version #{newVersion} is released." - ) - end -end - -lane :runalltests do - scan( - project: "R.swift.Library.xcodeproj", - scheme: "Rswift-iOS", - device: "iPhone 8", - clean: true - ) - scan( - project: "R.swift.Library.xcodeproj", - scheme: "Rswift-tvOS", - device: "Apple TV 4K", - clean: true - ) -end - -error do |lane, exception| - unless is_ci - notification( - title: "R.swift.Library #{lane}", - message: "❌ Failed with an exception." - ) - end -end diff --git a/fastlane/actions/af_create_github_release.rb b/fastlane/actions/af_create_github_release.rb deleted file mode 100644 index 55a6b5f..0000000 --- a/fastlane/actions/af_create_github_release.rb +++ /dev/null @@ -1,157 +0,0 @@ -# From: https://github.com/AFNetworking/fastlane/blob/master/fastlane/actions/af_create_github_release.rb -module Fastlane - module Actions - module SharedValues - GITHUB_RELEASE_ID = :GITHUB_RELEASE_ID - GITHUB_RELEASE_HTML_URL = :GITHUB_RELEASE_HTML_URL - GITHUB_RELEASE_UPLOAD_URL_TEMPLATE = :GITHUB_RELEASE_UPLOAD_URL_TEMPLATE - end - - # To share this integration with the other fastlane users: - # - Fork https://github.com/KrauseFx/fastlane - # - Clone the forked repository - # - Move this integration into lib/fastlane/actions - # - Commit, push and submit the pull request - - class AfCreateGithubReleaseAction < Action - def self.run(params) - require 'net/http' - require 'net/https' - require 'json' - require 'base64' - - begin - uri = URI("https://api.github.com/repos/#{params[:owner]}/#{params[:repository]}/releases") - - # Create client - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_PEER - - dict = Hash.new - dict["draft"] = params[:draft] - dict["prerelease"] = params[:prerelease] - dict["body"] = params[:body] if params[:body] - dict["tag_name"] = params[:tag_name] if params[:tag_name] - dict["name"] = params[:name] if params[:name] - body = JSON.dump(dict) - - # Create Request - req = Net::HTTP::Post.new(uri) - # Add headers - req.add_field "Content-Type", "application/json" - # Add headers - api_token = params[:api_token] - req.add_field "Authorization", "Basic #{Base64.strict_encode64(api_token)}" - # Add headers - req.add_field "Accept", "application/vnd.github.v3+json" - # Set header and body - req.add_field "Content-Type", "application/json" - req.body = body - - # Fetch Request - res = http.request(req) - rescue StandardError => e - UI.message "HTTP Request failed (#{e.message})".red - end - - case res.code.to_i - when 201 - json = JSON.parse(res.body) - UI.message "Github Release Created (#{json["id"]})".green - UI.message "#{json["html_url"]}".green - - Actions.lane_context[SharedValues::GITHUB_RELEASE_ID] = json["id"] - Actions.lane_context[SharedValues::GITHUB_RELEASE_HTML_URL] = json["html_url"] - Actions.lane_context[SharedValues::GITHUB_RELEASE_UPLOAD_URL_TEMPLATE] = json["upload_url"] - return json - when 400..499 - json = JSON.parse(res.body) - raise "Error Creating Github Release (#{res.code}): #{json}".red - else - UI.message "Status Code: #{res.code} Body: #{res.body}" - raise "Error Creating Github Release".red - end - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - "Create a Github Release" - end - - def self.available_options - [ - FastlaneCore::ConfigItem.new(key: :owner, - env_name: "GITHUB_OWNER", - description: "The Github Owner", - is_string:true, - optional:false), - FastlaneCore::ConfigItem.new(key: :repository, - env_name: "GITHUB_REPOSITORY", - description: "The Github Repository", - is_string:true, - optional:false), - FastlaneCore::ConfigItem.new(key: :api_token, - env_name: "GITHUB_API_TOKEN", - description: "Personal API Token for GitHub - generate one at https://github.com/settings/tokens", - is_string: true, - optional: false), - FastlaneCore::ConfigItem.new(key: :tag_name, - env_name: "GITHUB_RELEASE_TAG_NAME", - description: "Pass in the tag name", - is_string: true, - optional: false), - FastlaneCore::ConfigItem.new(key: :target_commitish, - env_name: "GITHUB_TARGET_COMMITISH", - description: "Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists", - is_string: true, - optional: true), - FastlaneCore::ConfigItem.new(key: :name, - env_name: "GITHUB_RELEASE_NAME", - description: "The name of the release", - is_string: true, - optional: true), - FastlaneCore::ConfigItem.new(key: :body, - env_name: "GITHUB_RELEASE_BODY", - description: "Text describing the contents of the tag", - is_string: true, - optional: true), - FastlaneCore::ConfigItem.new(key: :draft, - env_name: "GITHUB_RELEASE_DRAFT", - description: "true to create a draft (unpublished) release, false to create a published one", - is_string: false, - default_value: false), - FastlaneCore::ConfigItem.new(key: :prerelease, - env_name: "GITHUB_RELEASE_PRERELEASE", - description: "true to identify the release as a prerelease. false to identify the release as a full release", - is_string: false, - default_value: false), - - ] - end - - def self.output - [ - ['GITHUB_RELEASE_ID', 'The Github Release ID'], - ['GITHUB_RELEASE_HTML_URL', 'The Github Release URL'], - ['GITHUB_RELEASE_UPLOAD_URL_TEMPLATE', 'The Github Release Upload URL'] - ] - end - - def self.return_value - "The Hash representing the API response" - end - - def self.authors - ["kcharwood"] - end - - def self.is_supported?(platform) - return true - end - end - end -end \ No newline at end of file diff --git a/fastlane/actions/version_get_podspec.rb b/fastlane/actions/version_get_podspec.rb deleted file mode 100644 index b2d82f1..0000000 --- a/fastlane/actions/version_get_podspec.rb +++ /dev/null @@ -1,107 +0,0 @@ -module Fastlane - module Actions - class VersionGetPodspecAction < Action - def self.run(params) - podspec_path = params[:path] - - UI.user_error!("Could not find podspec file at path '#{podspec_path}'") unless File.exist? podspec_path - - version_podspec_file = PodspecHelper.new(podspec_path) - - Actions.lane_context[SharedValues::PODSPEC_VERSION_NUMBER] = version_podspec_file.version_value - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - "Receive the version number from a podspec file" - end - - def self.available_options - [ - FastlaneCore::ConfigItem.new(key: :path, - env_name: "FL_VERSION_PODSPEC_PATH", - description: "You must specify the path to the podspec file", - is_string: true, - default_value: Dir["*.podspec"].last, - verify_block: proc do |value| - UI.user_error!("Please pass a path to the `version_get_podspec` action") if value.length == 0 - end) - ] - end - - def self.output - [ - ['PODSPEC_VERSION_NUMBER', 'The podspec version number'] - ] - end - - def self.authors - ["Liquidsoul", "KrauseFx"] - end - - def self.is_supported?(platform) - true - end - end - - class PodspecHelper - attr_accessor :path - attr_accessor :podspec_content - attr_accessor :version_regex - attr_accessor :version_match - attr_accessor :version_value - - def initialize(path = nil) - version_var_name = 'version' - @version_regex = /^(?<begin>[^#]*#{version_var_name}\s*=\s*['"])(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(\.(?<type>[a-z]+))?(\.(?<buildnumber>[0-9]+))?)(?<end>['"])/i - - return unless (path || '').length > 0 - UI.user_error!("Could not find podspec file at path '#{path}'") unless File.exist?(path) - - @path = File.expand_path(path) - podspec_content = File.read(path) - - parse(podspec_content) - end - - def parse(podspec_content) - @podspec_content = podspec_content - @version_match = @version_regex.match(@podspec_content) - UI.user_error!("AAAAAH!!! Could not find version in podspec content '#{@podspec_content}'") if @version_match.nil? - @version_value = @version_match[:value] - end - - def bump_version(bump_type) - major = version_match[:major].to_i - minor = version_match[:minor].to_i || 0 - patch = version_match[:patch].to_i || 0 - - case bump_type - when 'patch' - patch += 1 - when 'minor' - minor += 1 - patch = 0 - when 'major' - major += 1 - minor = 0 - patch = 0 - end - - @version_value = "#{major}.#{minor}.#{patch}" - end - - def update_podspec(version = nil) - new_version = version || @version_value - updated_podspec_content = @podspec_content.gsub(@version_regex, "#{@version_match[:begin]}#{new_version}#{@version_match[:end]}") - - File.open(@path, "w") { |file| file.puts updated_podspec_content } unless Helper.test? - - updated_podspec_content - end - end - end -end