Skip to content

Commit f12f5d3

Browse files
committed
SPM implemetation. Thx to @RomanTysiachnik
Added Package file. Updated readme. Added Bundle.local. Moved Resources folder to Sources.
1 parent f48afce commit f12f5d3

File tree

85 files changed

+198
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+198
-45
lines changed

Package.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// swift-tools-version:5.3
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "YPImagePicker",
7+
defaultLocalization: "en",
8+
platforms: [
9+
.iOS(.v12)
10+
],
11+
products: [
12+
.library(name: "YPImagePicker", targets: ["YPImagePicker"])
13+
],
14+
dependencies: [
15+
.package(
16+
url: "https://github.com/freshOS/Stevia",
17+
.exact("5.1.0")
18+
),
19+
.package(
20+
url: "https://github.com/HHK1/PryntTrimmerView",
21+
.exact("4.0.2")
22+
)
23+
24+
],
25+
targets: [
26+
.target(
27+
name: "YPImagePicker",
28+
dependencies: ["Stevia", "PryntTrimmerView"],
29+
path: "Source",
30+
exclude: ["Info.plist", "YPImagePickerHeader.h"]
31+
)
32+
]
33+
)

README.md

Lines changed: 19 additions & 10 deletions

Source/Filters/Crop/YPCropView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import UIKit
1010
import Stevia
1111

12-
class YPCropView: UIView {
12+
final class YPCropView: UIView {
1313

1414
let containerView = UIView()
1515
let imageView = UIImageView()
@@ -171,7 +171,7 @@ class YPCropView: UIView {
171171
}
172172
}
173173

174-
class YPCropAreaView: UIView {
174+
final class YPCropAreaView: UIView {
175175

176176
var isCircle = false {
177177
didSet {

Source/Filters/Photo/YPFilterCollectionViewCell.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
// Copyright © 2016 octopepper. All rights reserved.
77
//
88

9+
import UIKit
910
import Stevia
1011

11-
class YPFilterCollectionViewCell: UICollectionViewCell {
12+
final class YPFilterCollectionViewCell: UICollectionViewCell {
1213

1314
let name = UILabel()
1415
let imageView = UIImageView()

Source/Filters/Photo/YPFiltersView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2016 octopepper. All rights reserved.
77
//
88

9+
import UIKit
910
import Stevia
1011

1112
class YPFiltersView: UIView {

Source/Filters/Video/YPVideoFiltersVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class YPVideoFiltersVC: UIViewController, IsMediaFilterVC {
3434
/// Designated initializer
3535
public class func initWith(video: YPMediaVideo,
3636
isFromSelectionVC: Bool) -> YPVideoFiltersVC {
37-
let vc = YPVideoFiltersVC(nibName: "YPVideoFiltersVC", bundle: Bundle(for: YPVideoFiltersVC.self))
37+
let vc = YPVideoFiltersVC(nibName: "YPVideoFiltersVC", bundle: Bundle.local)
3838
vc.inputVideo = video
3939
vc.isFromSelectionVC = isFromSelectionVC
4040

Source/Filters/Video/YPVideoFiltersVC.xib

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
7-
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
87
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
98
</dependencies>
109
<objects>
11-
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="YPVideoFiltersVC" customModule="YPImagePicker" customModuleProvider="target">
10+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="YPVideoFiltersVC" customModule="Example" customModuleProvider="target">
1211
<connections>
1312
<outlet property="coverBottomItem" destination="qy9-MY-67C" id="LaY-F2-uVO"/>
1413
<outlet property="coverImageView" destination="daH-No-sZc" id="sNy-7V-7gV"/>
@@ -24,18 +23,18 @@
2423
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2524
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2625
<subviews>
27-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qy9-MY-67C" customClass="YPMenuItem" customModule="YPImagePicker" customModuleProvider="target">
26+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qy9-MY-67C" customClass="YPMenuItem" customModule="Example" customModuleProvider="target">
2827
<rect key="frame" x="187.5" y="627" width="187.5" height="40"/>
2928
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
3029
<constraints>
3130
<constraint firstAttribute="height" constant="40" id="Ik5-9V-0hz"/>
3231
</constraints>
3332
</view>
34-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uB8-a7-Vh0" customClass="YPMenuItem" customModule="YPImagePicker" customModuleProvider="target">
33+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uB8-a7-Vh0" customClass="YPMenuItem" customModule="Example" customModuleProvider="target">
3534
<rect key="frame" x="0.0" y="627" width="187.5" height="40"/>
3635
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
3736
</view>
38-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AFl-Bk-oPH" customClass="YPVideoView" customModule="YPImagePicker" customModuleProvider="target">
37+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AFl-Bk-oPH" customClass="YPVideoView" customModule="Example" customModuleProvider="target">
3938
<rect key="frame" x="0.0" y="0.0" width="375" height="375"/>
4039
<constraints>
4140
<constraint firstAttribute="width" secondItem="AFl-Bk-oPH" secondAttribute="height" multiplier="1:1" id="tL6-cM-ei5"/>
@@ -69,26 +68,25 @@
6968
</subviews>
7069
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
7170
<constraints>
72-
<constraint firstItem="uB8-a7-Vh0" firstAttribute="bottom" secondItem="fnl-2z-Ty3" secondAttribute="bottom" id="CC1-rc-s2V"/>
73-
<constraint firstItem="AFl-Bk-oPH" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="FRD-Vm-8CW"/>
71+
<constraint firstItem="uB8-a7-Vh0" firstAttribute="bottom" secondItem="i5M-Pr-FkT" secondAttribute="bottom" id="CC1-rc-s2V"/>
72+
<constraint firstItem="AFl-Bk-oPH" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="FRD-Vm-8CW"/>
7473
<constraint firstItem="uB8-a7-Vh0" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="Fzr-Gx-9yI"/>
75-
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="AFl-Bk-oPH" secondAttribute="trailing" id="HuF-V0-NP6"/>
74+
<constraint firstAttribute="trailing" secondItem="AFl-Bk-oPH" secondAttribute="trailing" id="HuF-V0-NP6"/>
7675
<constraint firstItem="daH-No-sZc" firstAttribute="top" secondItem="AFl-Bk-oPH" secondAttribute="top" id="IXg-d6-twu"/>
77-
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="qy9-MY-67C" secondAttribute="bottom" id="K8l-EJ-kc2"/>
76+
<constraint firstAttribute="bottom" secondItem="qy9-MY-67C" secondAttribute="bottom" id="K8l-EJ-kc2"/>
7877
<constraint firstItem="daH-No-sZc" firstAttribute="bottom" secondItem="AFl-Bk-oPH" secondAttribute="bottom" id="MaG-K6-Aq8"/>
7978
<constraint firstItem="qy9-MY-67C" firstAttribute="top" secondItem="dMy-Fy-gyR" secondAttribute="bottom" id="Qlv-q8-8Hh"/>
80-
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="qy9-MY-67C" secondAttribute="trailing" id="RdA-eh-2U7"/>
81-
<constraint firstItem="AFl-Bk-oPH" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="SaE-kX-wSu"/>
79+
<constraint firstAttribute="trailing" secondItem="qy9-MY-67C" secondAttribute="trailing" id="RdA-eh-2U7"/>
80+
<constraint firstItem="AFl-Bk-oPH" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="SaE-kX-wSu"/>
8281
<constraint firstItem="uB8-a7-Vh0" firstAttribute="height" secondItem="qy9-MY-67C" secondAttribute="height" id="dil-cq-CMa"/>
83-
<constraint firstItem="dMy-Fy-gyR" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="ecA-Oe-ps4"/>
84-
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="dMy-Fy-gyR" secondAttribute="trailing" id="hyI-iq-qoa"/>
82+
<constraint firstItem="dMy-Fy-gyR" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="ecA-Oe-ps4"/>
83+
<constraint firstAttribute="trailing" secondItem="dMy-Fy-gyR" secondAttribute="trailing" id="hyI-iq-qoa"/>
8584
<constraint firstItem="qy9-MY-67C" firstAttribute="leading" secondItem="uB8-a7-Vh0" secondAttribute="trailing" id="i8m-ID-dah"/>
8685
<constraint firstItem="daH-No-sZc" firstAttribute="leading" secondItem="AFl-Bk-oPH" secondAttribute="leading" id="mBO-x4-u0c"/>
8786
<constraint firstItem="daH-No-sZc" firstAttribute="trailing" secondItem="AFl-Bk-oPH" secondAttribute="trailing" id="ncu-ea-Qsv"/>
8887
<constraint firstItem="uB8-a7-Vh0" firstAttribute="width" secondItem="qy9-MY-67C" secondAttribute="width" id="qhk-iL-B9n"/>
8988
<constraint firstItem="dMy-Fy-gyR" firstAttribute="top" secondItem="AFl-Bk-oPH" secondAttribute="bottom" id="zco-k3-gb7"/>
9089
</constraints>
91-
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
9290
<point key="canvasLocation" x="32.5" y="105.5"/>
9391
</view>
9492
</objects>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Bundle+Extensions.swift
3+
// YPImagePicker
4+
//
5+
// Created by Nik Kov on 19.09.2021.
6+
// Copyright © 2021 Yummypets. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
extension Bundle {
12+
static var local: Bundle {
13+
#if SWIFT_PACKAGE
14+
return Bundle.module
15+
#else
16+
return Bundle(for: BundleToken.self)
17+
#endif
18+
}
19+
}
20+
21+
private class BundleToken {}

Source/Helpers/YPHelper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import Photos
1313
internal func ypLocalized(_ str: String) -> String {
1414
return NSLocalizedString(str,
1515
tableName: "YPImagePickerLocalizable",
16-
bundle: Bundle(for: YPPickerVC.self),
16+
bundle: Bundle.local,
1717
value: "",
1818
comment: "")
1919
}
2020

2121
internal func imageFromBundle(_ named: String) -> UIImage {
22-
return UIImage(named: named, in: Bundle(for: YPPickerVC.self), compatibleWith: nil) ?? UIImage()
22+
return UIImage(named: named, in: Bundle.local, compatibleWith: nil) ?? UIImage()
2323
}
2424

2525
struct YPHelper {

Source/Pages/Gallery/BottomPager/YPBottomPager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ open class YPBottomPager: UIViewController, UIScrollViewDelegate {
2727
}
2828

2929
override open func loadView() {
30-
self.automaticallyAdjustsScrollViewInsets = false
30+
v.scrollView.contentInsetAdjustmentBehavior = .never
3131
v.scrollView.delegate = self
3232
view = v
3333
}

Source/Pages/Gallery/YPGridView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
// Copyright © 2016 Yummypets. All rights reserved.
77
//
88

9+
import UIKit
910
import Stevia
1011

11-
class YPGridView: UIView {
12+
final class YPGridView: UIView {
1213

1314
let line1 = UIView()
1415
let line2 = UIView()

Source/Pages/Gallery/YPLibraryView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ final class YPLibraryView: UIView {
9999
extension YPLibraryView {
100100

101101
class func xibView() -> YPLibraryView? {
102-
let bundle = Bundle(for: YPPickerVC.self)
103-
let nib = UINib(nibName: "YPLibraryView", bundle: bundle)
102+
let nib = UINib(nibName: "YPLibraryView", bundle: Bundle.local)
104103
let xibView = nib.instantiate(withOwner: self, options: nil)[0] as? YPLibraryView
105104
return xibView
106105
}

Source/YPPickerVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2016 Yummypets. All rights reserved.
77
//
88

9-
import Foundation
9+
import UIKit
1010
import Stevia
1111
import Photos
1212

YPImagePicker.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
1313
s.source_files = 'Source/**/*.swift'
1414
s.dependency 'SteviaLayout', '= 4.7.3'
1515
s.dependency 'PryntTrimmerView', '= 4.0.2'
16-
s.resources = ['Resources/*', 'Source/**/*.xib']
16+
s.resources = ['Source/Resources/*', 'Source/**/*.xib']
1717
s.description = "Instagram-like image picker & filters for iOS supporting videos and albums"
1818
s.swift_versions = ['5.0', '5.1', '5.2', '5.3']
1919
end

0 commit comments

Comments
 (0)