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

Swift 5 support #132

Merged
merged 8 commits into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: swift
xcode_workspace: Example/CardParts.xcworkspace
xcode_scheme: CardParts-Example
osx_image: xcode10.1
osx_image: xcode10.2
podfile: Example/Podfile
before_install:
- gem install cocoapods
- pod repo update
script: xcodebuild test -workspace Example/CardParts.xcworkspace -scheme CardParts-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO -quiet
script: xcodebuild test -workspace Example/CardParts.xcworkspace -scheme CardParts-Example -sdk iphonesimulator -destination "platform=iOS Simulator,OS=12.2,name=iPhone Xs Max" ONLY_ACTIVE_ARCH=NO -quiet
12 changes: 6 additions & 6 deletions CardParts.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'CardParts'
s.version = '2.7.5'
s.version = '2.8.0'
s.platform = :ios
s.summary = 'iOS Card UI framework.'

Expand All @@ -17,20 +17,20 @@ CardParts is an iOS Card UI framework that uses MVVM and automatic data binding
DESC

s.homepage = 'https://github.com/intuit/CardParts'
s.authors = { "Chase Roossin" => "[email protected]", "Bharath Urs" => "[email protected]" }
s.authors = { "Chase Roossin" => "[email protected]", "Bharath Urs" => "[email protected]", "Lucien Dupont" => "[email protected]" }
s.source = { :git => 'https://github.com/intuit/CardParts.git', :tag => s.version.to_s }
s.license = { :type => 'Apache 2.0' }
s.resources = [
'CardParts/Assets/*.xcassets',
]

s.ios.deployment_target = '10.0'
s.swift_version = '4.2'
s.swift_version = '5.0'
s.source_files = 'CardParts/src/**/*'

s.dependency 'RxSwift', '~> 4.4'
s.dependency 'RxCocoa', '~> 4.4'
s.dependency 'RxSwift', '~> 4.5'
s.dependency 'RxCocoa', '~> 4.5'
s.dependency 'RxDataSources', '~> 3.1'
s.dependency 'RxGesture', '~> 2.1'
s.dependency 'RxGesture', '~> 2.2'

end
2 changes: 1 addition & 1 deletion CardParts/src/Classes/Card Parts/CardPartTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public class CardPartTextView : UIView, CardPartView {

label.attributedText = mutableAttrText
} else if let labelText = text {
let mutableAttrText = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor])
let mutableAttrText = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font!, NSAttributedString.Key.foregroundColor: textColor!])

mutableAttrText.addAttributes([NSAttributedString.Key.paragraphStyle: paragraphStyle],
range: NSRange(location: 0, length: mutableAttrText.length))
Expand Down
2 changes: 1 addition & 1 deletion CardParts/src/Classes/CardPartsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ open class CardPartsViewController : UIViewController, CardController {
padding = cardPart.margins.bottom
}

stateData.constraints.append(NSLayoutConstraint(item: view, attribute: .bottom, relatedBy: .greaterThanOrEqual, toItem: prevCardPart, attribute: .bottom, multiplier: 1.0, constant: padding))
stateData.constraints.append(NSLayoutConstraint(item: view!, attribute: .bottom, relatedBy: .greaterThanOrEqual, toItem: prevCardPart, attribute: .bottom, multiplier: 1.0, constant: padding))

if forState == self.state {
view.addConstraints(stateData.constraints)
Expand Down
12 changes: 6 additions & 6 deletions CardParts/src/Classes/CardsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ open class CardsViewController : UIViewController, UICollectionViewDataSource, U
collectionView.scrollIndicatorInsets = insets
self.view.addSubview(collectionView)

view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[collectionView]|", options: [], metrics: nil, views: ["collectionView" : collectionView]))
view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[collectionView]|", options: [], metrics: nil, views: ["collectionView" : collectionView]))
view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[collectionView]|", options: [], metrics: nil, views: ["collectionView" : collectionView!]))
view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[collectionView]|", options: [], metrics: nil, views: ["collectionView" : collectionView!]))
cardCellWidth.value = view.bounds.width - (CardParts.theme.cardCellMargins.left + CardParts.theme.cardCellMargins.right)
}

Expand Down Expand Up @@ -242,8 +242,8 @@ open class CardsViewController : UIViewController, UICollectionViewDataSource, U

let metrics = ["cardContentWidth": cardCellWidth.value]

cell.cardContentConstraints.append(contentsOf:NSLayoutConstraint.constraints(withVisualFormat: "H:|[view(cardContentWidth)]|", options: [], metrics: metrics, views: ["view" : viewController.view]))
cell.cardContentConstraints.append(contentsOf:NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: [], metrics: nil, views: ["view" : viewController.view]))
cell.cardContentConstraints.append(contentsOf:NSLayoutConstraint.constraints(withVisualFormat: "H:|[view(cardContentWidth)]|", options: [], metrics: metrics, views: ["view" : viewController.view!]))
cell.cardContentConstraints.append(contentsOf:NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: [], metrics: nil, views: ["view" : viewController.view!]))


cell.cardContentView.addConstraints(cell.cardContentConstraints)
Expand Down Expand Up @@ -284,11 +284,11 @@ open class CardsViewController : UIViewController, UICollectionViewDataSource, U
// let oldCardControllers = cardControllers

if isHidden {
if let index = cardControllers.index(of: cardInfo) {
if let index = cardControllers.firstIndex(of: cardInfo) {
cardControllers.remove(at: index)
}
} else {
if cardControllers.index(of: cardInfo) == nil {
if cardControllers.firstIndex(of: cardInfo) == nil {
cardControllers.append(cardInfo)
cardControllers = cardControllers.sorted { $0.position < $1.position }
}
Expand Down
40 changes: 12 additions & 28 deletions Example/CardParts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -305,25 +305,25 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
ProvisioningStyle = Manual;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
ProvisioningStyle = Manual;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
};
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "CardParts" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -369,10 +369,9 @@
inputFileListPaths = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-CardParts_Tests/Pods-CardParts_Tests-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-CardParts_Tests/Pods-CardParts_Tests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/CardParts/CardParts.framework",
"${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework",
"${BUILT_PRODUCTS_DIR}/RxAtomic/RxAtomic.framework",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxDataSources/RxDataSources.framework",
"${BUILT_PRODUCTS_DIR}/RxGesture/RxGesture.framework",
Expand All @@ -384,15 +383,14 @@
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CardParts.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Differentiator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxAtomic.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxDataSources.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxGesture.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CardParts_Tests/Pods-CardParts_Tests-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CardParts_Tests/Pods-CardParts_Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
2B9B7383D03B89214C749584 /* [CP] Embed Pods Frameworks */ = {
Expand All @@ -403,10 +401,9 @@
inputFileListPaths = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-CardParts_Example/Pods-CardParts_Example-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-CardParts_Example/Pods-CardParts_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/CardParts/CardParts.framework",
"${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework",
"${BUILT_PRODUCTS_DIR}/RxAtomic/RxAtomic.framework",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxDataSources/RxDataSources.framework",
"${BUILT_PRODUCTS_DIR}/RxGesture/RxGesture.framework",
Expand All @@ -418,15 +415,14 @@
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CardParts.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Differentiator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxAtomic.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxDataSources.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxGesture.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CardParts_Example/Pods-CardParts_Example-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CardParts_Example/Pods-CardParts_Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
90BAACBDEF50357EFD255920 /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -670,8 +666,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -690,8 +685,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -701,10 +695,6 @@
buildSettings = {
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
Expand All @@ -715,8 +705,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -726,18 +715,13 @@
buildSettings = {
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Example/CardParts/ThemedCardController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ThemedCardController: CardPartsViewController {

setupCardParts([titleCP])

view.addConstraint(NSLayoutConstraint(item: view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 280))
view.addConstraint(NSLayoutConstraint(item: view!, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 280))
}
}

Expand Down