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

Add support swiftpackage #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ out/

# generated by mpeltonen/sbt-idea plugin
.idea_modules/
.swiftpm/
27 changes: 27 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "ScrollableDatepicker",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "ScrollableDatepicker",
targets: ["ScrollableDatepicker"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "ScrollableDatepicker",
dependencies: [],
resources: [.process("Resources")
]),
]
)
4 changes: 2 additions & 2 deletions ScrollableDatepicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Pod::Spec.new do |s|
s.author = { "Dmitry Ivanenko" => "[email protected]" }
s.platform = :ios, "9.0"
s.source = { :git => "https://github.com/noxt/ScrollableDatepicker.git", :tag => "#{s.version}" }
s.source_files = "Sources"
s.resource_bundles = { "ScrollableDatepicker" => ["Sources/*.xib"] }
s.source_files = "Sources/ScrollableDatepicker"
s.resource_bundles = { "ScrollableDatepicker" => ["Sources/ScrollableDatepicker/Resources/*.xib"] }
s.requires_arc = true

end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ open class LoadableFromXibView: UIView {

@IBOutlet public weak var view: UIView!


// MARK: - Inits

override public init(frame: CGRect) {
Expand All @@ -34,9 +33,15 @@ open class LoadableFromXibView: UIView {
if bundlePath != nil {
bundle = Bundle(path: bundlePath!)
}

#if SWIFT_PACKAGE
let nib = UINib(nibName: String(describing: type(of: self)), bundle: .module)
view = nib.instantiate(withOwner: self, options: nil).first as? UIView
#else
let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
view = nib.instantiate(withOwner: self, options: nil).first as? UIView
#endif


addSubview(view)

view.translatesAutoresizingMaskIntoConstraints = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16G12b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="DayCell" id="JlJ-Yf-ukc" customClass="DayCell" customModule="ScrollableDatepicker" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="DayCell" id="JlJ-Yf-ukc" customClass="DayCell" customModule="ScrollableDatepicker">
<rect key="frame" x="0.0" y="0.0" width="73" height="51"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
Expand All @@ -21,16 +20,16 @@
<rect key="frame" x="0.0" y="8.5" width="73" height="34"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalCentering" alignment="firstBaseline" spacing="3" translatesAutoresizingMaskIntoConstraints="NO" id="FcK-Sc-nuG">
<rect key="frame" x="17" y="0.0" width="39" height="24"/>
<rect key="frame" x="18" y="0.0" width="37.5" height="24"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="22" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qvg-q9-SfV">
<rect key="frame" x="0.0" y="0.0" width="23.5" height="24"/>
<rect key="frame" x="0.0" y="0.0" width="22.5" height="24"/>
<fontDescription key="fontDescription" type="system" weight="thin" pointSize="20"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" text="FRI" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Ye-5o-RAT">
<rect key="frame" x="26.5" y="11.5" width="12.5" height="10"/>
<rect key="frame" x="25.5" y="11.5" width="12" height="10"/>
<fontDescription key="fontDescription" type="system" weight="thin" pointSize="8"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -18,6 +19,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="bHB-sV-bER">
<rect key="frame" x="0.0" y="0.0" width="240" height="50"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="5" id="XLp-AA-98S">
<size key="itemSize" width="70" height="50"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ open class ScrollableDatepicker: LoadableFromXibView {
let podBundle = Bundle(for: ScrollableDatepicker.self)
let bundlePath = podBundle.path(forResource: String(describing: type(of: self)), ofType: "bundle")
var bundle: Bundle? = nil

#if SWIFT_PACKAGE
collectionView.register(UINib(nibName: DayCell.ClassName, bundle: .module),
forCellWithReuseIdentifier: DayCell.ClassName)
#else
if bundlePath != nil {
bundle = Bundle(path: bundlePath!)
}

let cellNib = UINib(nibName: DayCell.ClassName, bundle: bundle)
collectionView.register(cellNib, forCellWithReuseIdentifier: DayCell.ClassName)
#endif




}
}

Expand Down