Skip to content

Commit 2ab6f6c

Browse files
authored
Merge pull request #281 from RomanTysiachnik/master
Fixed crash when import using SPM
2 parents ca24284 + d040a7d commit 2ab6f6c

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

DropDown/resources/DropDownCell.xib

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
34
<dependencies>
45
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
7+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
68
</dependencies>
79
<objects>
810
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
911
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
10-
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="DropDownCell" customModule="DropDown" customModuleProvider="target">
12+
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="DropDownCell" customModule="DropDown">
1113
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
1214
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1315
<subviews>
1416
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dhL-pA-i6q">
1517
<rect key="frame" x="8" y="8" width="304" height="28"/>
1618
<fontDescription key="fontDescription" type="system" pointSize="17"/>
17-
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
19+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
1820
<nil key="highlightedColor"/>
1921
</label>
2022
</subviews>
21-
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
23+
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
2224
<constraints>
2325
<constraint firstAttribute="trailing" secondItem="dhL-pA-i6q" secondAttribute="trailing" constant="8" id="Phk-No-PFh"/>
2426
<constraint firstItem="dhL-pA-i6q" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="8" id="QIg-6Z-lbJ"/>
@@ -30,6 +32,7 @@
3032
<connections>
3133
<outlet property="optionLabel" destination="dhL-pA-i6q" id="1GT-db-EaA"/>
3234
</connections>
35+
<point key="canvasLocation" x="-16" y="2"/>
3336
</view>
3437
</objects>
3538
</document>

DropDown/src/DropDown.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,22 @@ public final class DropDown: UIView {
357357

358358
Changing the cell nib automatically reloads the drop down.
359359
*/
360-
public var cellNib = UINib(nibName: "DropDownCell", bundle: Bundle(for: DropDownCell.self)) {
360+
public var cellNib = UINib(nibName: "DropDownCell", bundle: bundle) {
361361
didSet {
362362
tableView.register(cellNib, forCellReuseIdentifier: DPDConstant.ReusableIdentifier.DropDownCell)
363363
templateCell = nil
364364
reloadAllComponents()
365365
}
366366
}
367+
368+
/// Correctly specify Bundle for Swift Packages
369+
fileprivate static var bundle: Bundle {
370+
#if SWIFT_PACKAGE
371+
return Bundle.module
372+
#else
373+
return Bundle(for: DropDownCell.self)
374+
#endif
375+
}
367376

368377
//MARK: Content
369378

Package.swift

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.3
22
import PackageDescription
33

44
let package = Package(
55
name: "DropDown",
66
platforms: [
7-
.iOS(.v8)
7+
.iOS(.v9)
88
],
99
products: [
1010
.library(
1111
name: "DropDown",
12-
targets: ["DropDown"])
12+
targets: ["DropDown"]
13+
)
1314
],
1415
targets: [
1516
.target(
1617
name: "DropDown",
17-
path: "DropDown"
18+
dependencies: [],
19+
path: "DropDown",
20+
exclude: ["Info.plist", "DropDown.h"],
21+
resources: [
22+
.process("DropDown/resources")
23+
]
1824
)
19-
]
25+
],
26+
swiftLanguageVersions: [.v5]
2027
)

0 commit comments

Comments
 (0)