Skip to content

Commit 8b17bb1

Browse files
nacho4dVojtech Pajer
and
Vojtech Pajer
authored
Swift Package Manager support and exposes initializer so clients that subclass work in newer swift version (teodorpatras#193)
* Added support for Swift Package Manager. * Bumped version to 2.0.5 * Fix ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES * Expose private init so I am able to subclass it * Update swift version to 5.0. Update Package.swift with platform .ios(.v9) to avoid warnings in Xcode12 Co-authored-by: Vojtech Pajer <vojtech.pajer@synetech.cz>
1 parent 6a93561 commit 8b17bb1

File tree

10 files changed

+97
-61
lines changed

10 files changed

+97
-61
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Finder
2+
.DS_Store
3+
14
# Xcode
25
#
36
build/
@@ -24,3 +27,4 @@ DerivedData
2427
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
2528
#
2629
# Pods/
30+
.build/

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EasyTipView.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'EasyTipView'
3-
s.version = '2.0.4'
3+
s.version = '2.0.5'
44
s.license = 'MIT'
55
s.summary = 'Elegant tooltip view written in Swift'
66
s.description = 'EasyTipView is a fully customisable tooltip view written in Swift that can be used as a call to action or informative tip. It can be shown above of below any UIBarItem or UIView subclass.'

EasyTipView.xcodeproj/project.pbxproj

+40-24
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
/* Begin PBXBuildFile section */
1010
1310EC961D0C53800000E71E /* EasyTipView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1310EC8B1D0C537F0000E71E /* EasyTipView.framework */; };
11-
13609E071D23AB8500593B38 /* UIKitExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13609E061D23AB8500593B38 /* UIKitExtensions.swift */; };
12-
13FB32A21D0C53CB001ACE20 /* EasyTipView.h in Headers */ = {isa = PBXBuildFile; fileRef = 13FB329F1D0C53CB001ACE20 /* EasyTipView.h */; settings = {ATTRIBUTES = (Public, ); }; };
13-
13FB32A31D0C53CB001ACE20 /* EasyTipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13FB32A01D0C53CB001ACE20 /* EasyTipView.swift */; };
1411
13FB32A91D0C53E5001ACE20 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13FB32A61D0C53E2001ACE20 /* Tests.swift */; };
12+
3DEF6DAB23A39E4F007B8C3C /* EasyTipView.h in Headers */ = {isa = PBXBuildFile; fileRef = 3DEF6DA823A39E4F007B8C3C /* EasyTipView.h */; settings = {ATTRIBUTES = (Public, ); }; };
13+
3DEF6DAC23A39E4F007B8C3C /* UIKitExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DEF6DA923A39E4F007B8C3C /* UIKitExtensions.swift */; };
14+
3DEF6DAD23A39E4F007B8C3C /* EasyTipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DEF6DAA23A39E4F007B8C3C /* EasyTipView.swift */; };
1515
/* End PBXBuildFile section */
1616

1717
/* Begin PBXContainerItemProxy section */
@@ -27,12 +27,12 @@
2727
/* Begin PBXFileReference section */
2828
1310EC8B1D0C537F0000E71E /* EasyTipView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EasyTipView.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2929
1310EC951D0C53800000E71E /* EasyTipViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EasyTipViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
30-
13609E061D23AB8500593B38 /* UIKitExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UIKitExtensions.swift; path = Source/UIKitExtensions.swift; sourceTree = SOURCE_ROOT; };
31-
13FB329F1D0C53CB001ACE20 /* EasyTipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EasyTipView.h; path = Source/EasyTipView.h; sourceTree = SOURCE_ROOT; };
32-
13FB32A01D0C53CB001ACE20 /* EasyTipView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EasyTipView.swift; path = Source/EasyTipView.swift; sourceTree = SOURCE_ROOT; };
3330
13FB32A11D0C53CB001ACE20 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Source/Info.plist; sourceTree = SOURCE_ROOT; };
3431
13FB32A51D0C53E2001ACE20 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Tests/Info.plist; sourceTree = SOURCE_ROOT; };
35-
13FB32A61D0C53E2001ACE20 /* Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Tests.swift; path = Tests/Tests.swift; sourceTree = SOURCE_ROOT; };
32+
13FB32A61D0C53E2001ACE20 /* Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Tests.swift; path = Tests/EasyTipViewTests/Tests.swift; sourceTree = SOURCE_ROOT; };
33+
3DEF6DA823A39E4F007B8C3C /* EasyTipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EasyTipView.h; sourceTree = "<group>"; };
34+
3DEF6DA923A39E4F007B8C3C /* UIKitExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIKitExtensions.swift; sourceTree = "<group>"; };
35+
3DEF6DAA23A39E4F007B8C3C /* EasyTipView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EasyTipView.swift; sourceTree = "<group>"; };
3636
/* End PBXFileReference section */
3737

3838
/* Begin PBXFrameworksBuildPhase section */
@@ -57,8 +57,8 @@
5757
1310EC811D0C537F0000E71E = {
5858
isa = PBXGroup;
5959
children = (
60-
1310EC8D1D0C537F0000E71E /* EasyTipView */,
61-
1310EC991D0C53800000E71E /* EasyTipViewTests */,
60+
1310EC8D1D0C537F0000E71E /* Sources */,
61+
1310EC991D0C53800000E71E /* Tests */,
6262
1310EC8C1D0C537F0000E71E /* Products */,
6363
);
6464
sourceTree = "<group>";
@@ -72,21 +72,37 @@
7272
name = Products;
7373
sourceTree = "<group>";
7474
};
75-
1310EC8D1D0C537F0000E71E /* EasyTipView */ = {
75+
1310EC8D1D0C537F0000E71E /* Sources */ = {
7676
isa = PBXGroup;
7777
children = (
78-
13FB329F1D0C53CB001ACE20 /* EasyTipView.h */,
79-
13FB32A01D0C53CB001ACE20 /* EasyTipView.swift */,
78+
3DEF6DA623A39E20007B8C3C /* EasyTipView */,
8079
13FB32A11D0C53CB001ACE20 /* Info.plist */,
81-
13609E061D23AB8500593B38 /* UIKitExtensions.swift */,
8280
);
83-
path = EasyTipView;
81+
path = Sources;
8482
sourceTree = "<group>";
8583
};
86-
1310EC991D0C53800000E71E /* EasyTipViewTests */ = {
84+
1310EC991D0C53800000E71E /* Tests */ = {
8785
isa = PBXGroup;
8886
children = (
8987
13FB32A51D0C53E2001ACE20 /* Info.plist */,
88+
3DEF6DA723A39E3E007B8C3C /* EasyTipViewTests */,
89+
);
90+
path = Tests;
91+
sourceTree = "<group>";
92+
};
93+
3DEF6DA623A39E20007B8C3C /* EasyTipView */ = {
94+
isa = PBXGroup;
95+
children = (
96+
3DEF6DA823A39E4F007B8C3C /* EasyTipView.h */,
97+
3DEF6DAA23A39E4F007B8C3C /* EasyTipView.swift */,
98+
3DEF6DA923A39E4F007B8C3C /* UIKitExtensions.swift */,
99+
);
100+
path = EasyTipView;
101+
sourceTree = "<group>";
102+
};
103+
3DEF6DA723A39E3E007B8C3C /* EasyTipViewTests */ = {
104+
isa = PBXGroup;
105+
children = (
90106
13FB32A61D0C53E2001ACE20 /* Tests.swift */,
91107
);
92108
path = EasyTipViewTests;
@@ -99,7 +115,7 @@
99115
isa = PBXHeadersBuildPhase;
100116
buildActionMask = 2147483647;
101117
files = (
102-
13FB32A21D0C53CB001ACE20 /* EasyTipView.h in Headers */,
118+
3DEF6DAB23A39E4F007B8C3C /* EasyTipView.h in Headers */,
103119
);
104120
runOnlyForDeploymentPostprocessing = 0;
105121
};
@@ -154,12 +170,12 @@
154170
TargetAttributes = {
155171
1310EC8A1D0C537F0000E71E = {
156172
CreatedOnToolsVersion = 7.3.1;
157-
LastSwiftMigration = 1000;
173+
LastSwiftMigration = 1220;
158174
ProvisioningStyle = Automatic;
159175
};
160176
1310EC941D0C53800000E71E = {
161177
CreatedOnToolsVersion = 7.3.1;
162-
LastSwiftMigration = 1000;
178+
LastSwiftMigration = 1220;
163179
};
164180
};
165181
};
@@ -204,8 +220,8 @@
204220
isa = PBXSourcesBuildPhase;
205221
buildActionMask = 2147483647;
206222
files = (
207-
13609E071D23AB8500593B38 /* UIKitExtensions.swift in Sources */,
208-
13FB32A31D0C53CB001ACE20 /* EasyTipView.swift in Sources */,
223+
3DEF6DAD23A39E4F007B8C3C /* EasyTipView.swift in Sources */,
224+
3DEF6DAC23A39E4F007B8C3C /* UIKitExtensions.swift in Sources */,
209225
);
210226
runOnlyForDeploymentPostprocessing = 0;
211227
};
@@ -361,7 +377,7 @@
361377
PRODUCT_NAME = "$(TARGET_NAME)";
362378
SKIP_INSTALL = YES;
363379
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
364-
SWIFT_VERSION = 4.2;
380+
SWIFT_VERSION = 5.0;
365381
};
366382
name = Debug;
367383
};
@@ -383,7 +399,7 @@
383399
PRODUCT_BUNDLE_IDENTIFIER = com.teodorpatras.EasyTipView;
384400
PRODUCT_NAME = "$(TARGET_NAME)";
385401
SKIP_INSTALL = YES;
386-
SWIFT_VERSION = 4.2;
402+
SWIFT_VERSION = 5.0;
387403
};
388404
name = Release;
389405
};
@@ -394,7 +410,7 @@
394410
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
395411
PRODUCT_BUNDLE_IDENTIFIER = com.teodorpatras.EasyTipViewTests;
396412
PRODUCT_NAME = "$(TARGET_NAME)";
397-
SWIFT_VERSION = 4.2;
413+
SWIFT_VERSION = 5.0;
398414
};
399415
name = Debug;
400416
};
@@ -405,7 +421,7 @@
405421
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
406422
PRODUCT_BUNDLE_IDENTIFIER = com.teodorpatras.EasyTipViewTests;
407423
PRODUCT_NAME = "$(TARGET_NAME)";
408-
SWIFT_VERSION = 4.2;
424+
SWIFT_VERSION = 5.0;
409425
};
410426
name = Release;
411427
};

Example/EasyTipView-Example.xcodeproj/project.pbxproj

-2
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@
381381
607FACF01AFB9204008FA782 /* Debug */ = {
382382
isa = XCBuildConfiguration;
383383
buildSettings = {
384-
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
385384
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
386385
DEVELOPMENT_TEAM = 752CFWL5Y4;
387386
INFOPLIST_FILE = EasyTipView/Info.plist;
@@ -397,7 +396,6 @@
397396
607FACF11AFB9204008FA782 /* Release */ = {
398397
isa = XCBuildConfiguration;
399398
buildSettings = {
400-
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
401399
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
402400
DEVELOPMENT_TEAM = 752CFWL5Y4;
403401
INFOPLIST_FILE = EasyTipView/Info.plist;

Package.swift

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// swift-tools-version:5.1
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "EasyTipView",
8+
platforms: [
9+
.iOS(.v9),
10+
],
11+
products: [
12+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
13+
.library(
14+
name: "EasyTipView",
15+
targets: ["EasyTipView"]),
16+
],
17+
dependencies: [
18+
// Dependencies declare other packages that this package depends on.
19+
// .package(url: /* package url */, from: "1.0.0"),
20+
],
21+
targets: [
22+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
23+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
24+
.target(
25+
name: "EasyTipView",
26+
dependencies: [],
27+
exclude: ["assets", "Example", "Source"]),
28+
.testTarget(
29+
name: "EasyTipViewTests",
30+
dependencies: ["EasyTipView"],
31+
exclude: ["assets", "Example", "Source"]),
32+
]
33+
)
File renamed without changes.

Source/EasyTipView.swift Sources/EasyTipView/EasyTipView.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
// SOFTWARE.
2323

24+
#if canImport(UIKit)
2425
import UIKit
2526

2627
public protocol EasyTipViewDelegate : class {
@@ -259,12 +260,12 @@ open class EasyTipView: UIView {
259260
public init() {}
260261
}
261262

262-
private enum Content: CustomStringConvertible {
263+
public enum Content: CustomStringConvertible {
263264

264265
case text(String)
265266
case view(UIView)
266267

267-
var description: String {
268+
public var description: String {
268269
switch self {
269270
case .text(let text):
270271
return "text : '\(text)'"
@@ -352,7 +353,7 @@ open class EasyTipView: UIView {
352353
self.init(content: .view(contentView), preferences: preferences, delegate: delegate)
353354
}
354355

355-
private init (content: Content, preferences: Preferences = EasyTipView.globalPreferences, delegate: EasyTipViewDelegate? = nil) {
356+
public init (content: Content, preferences: Preferences = EasyTipView.globalPreferences, delegate: EasyTipViewDelegate? = nil) {
356357

357358
self.content = content
358359
self.preferences = preferences
@@ -680,3 +681,4 @@ open class EasyTipView: UIView {
680681
return CGRect(x: bubbleFrame.origin.x + (bubbleFrame.size.width - contentSize.width) / 2, y: bubbleFrame.origin.y + (bubbleFrame.size.height - contentSize.height) / 2, width: contentSize.width, height: contentSize.height)
681682
}
682683
}
684+
#endif

Source/UIKitExtensions.swift Sources/EasyTipView/UIKitExtensions.swift

+5-31
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
// Copyright © 2016 teodorpatras. All rights reserved.
77
//
88

9-
import Foundation
9+
#if canImport(UIKit)
10+
import UIKit
1011

1112
// MARK: - UIBarItem extension -
1213

@@ -31,10 +32,10 @@ extension UIView {
3132
if let sview = view.superview {
3233
if sview === superview {
3334
return true
34-
}else{
35+
} else{
3536
return viewHasSuperview(sview, superview: superview)
3637
}
37-
}else{
38+
} else{
3839
return false
3940
}
4041
}
@@ -61,36 +62,9 @@ extension CGRect {
6162
self.origin.y = newValue
6263
}
6364
}
64-
//
65-
// var width: CGFloat {
66-
// get {
67-
// return self.size.width
68-
// }
69-
//
70-
// set {
71-
// self.size.width = newValue
72-
// }
73-
// }
74-
//
75-
// var height: CGFloat {
76-
// get {
77-
// return self.size.height
78-
// }
79-
//
80-
// set{
81-
// self.size.height = newValue
82-
// }
83-
// }
84-
85-
// var maxX: CGFloat {
86-
// return self.maxX
87-
// }
88-
//
89-
// var maxY: CGFloat {
90-
// return self.maxY
91-
// }
9265

9366
var center: CGPoint {
9467
return CGPoint(x: self.x + self.width / 2, y: self.y + self.height / 2)
9568
}
9669
}
70+
#endif

Tests/Tests.swift Tests/EasyTipViewTests/Tests.swift

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(UIKit)
12
import UIKit
23
import XCTest
34
import EasyTipView
@@ -163,3 +164,4 @@ class Tests: XCTestCase {
163164
XCTAssert((tipView.frame).minY == (view.frame).maxY, "EasyTipView should be below the presenting view")
164165
}
165166
}
167+
#endif

0 commit comments

Comments
 (0)