From 186bca142f68c87bfc70c8ca443b04a054ca87ed Mon Sep 17 00:00:00 2001 From: Wei Date: Wed, 21 Dec 2022 10:45:59 +0800 Subject: [PATCH 1/2] [Add] Package.swift --- Package.swift | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..798ad41 --- /dev/null +++ b/Package.swift @@ -0,0 +1,32 @@ +// 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: "KVNProgress", + defaultLocalization: "en", + platforms: [.iOS(.v9)], + products: [ + .library( + name: "KVNProgress", + targets: ["KVNProgress"]), + ], + targets: [ + .target( + name: "KVNProgress", + dependencies: [ + "KVNProgressCategories", + ], + path: "KVNProgress/Classes", + resources: [.process("../Resources")], + publicHeadersPath: "." + ), + .target( + name: "KVNProgressCategories", + path: "KVNProgress/Categories", + publicHeadersPath: "." + ), + ], + swiftLanguageVersions: [.v5] +) From 1b1774a78c7bfa7c680abea7d2b0fe485dbf311f Mon Sep 17 00:00:00 2001 From: Wei Date: Wed, 21 Dec 2022 15:06:46 +0800 Subject: [PATCH 2/2] [Fix] load nib KVNProgress failed --- KVNProgress.podspec | 2 +- KVNProgress/Classes/KVNProgress.m | 8 +++++++- KVNProgress/{Resources => Classes}/KVNProgressView.xib | 0 Package.swift | 2 +- README.md | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) rename KVNProgress/{Resources => Classes}/KVNProgressView.xib (100%) diff --git a/KVNProgress.podspec b/KVNProgress.podspec index 6f2142c..2a2a7fc 100644 --- a/KVNProgress.podspec +++ b/KVNProgress.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |s| } s.source_files = "KVNProgress/Classes", "KVNProgress/Classes/**/*.{h,m}", "KVNProgress/Categories", "KVNProgress/Categories/**/*.{h,m}" - s.resources = "KVNProgress/Resources/*.{png,xib}" + s.resources = "KVNProgress/*.{png,xib}" s.frameworks = "QuartzCore", "GLKit" s.requires_arc = true diff --git a/KVNProgress/Classes/KVNProgress.m b/KVNProgress/Classes/KVNProgress.m index 61357f8..0a2e793 100644 --- a/KVNProgress/Classes/KVNProgress.m +++ b/KVNProgress/Classes/KVNProgress.m @@ -101,9 +101,15 @@ + (KVNProgress *)sharedView static KVNProgress *sharedView = nil; static dispatch_once_t onceToken; +#if SWIFT_PACKAGE + NSBundle *bundle = SWIFTPM_MODULE_BUNDLE; +#else + NSBundle *bundle = [NSBundle bundleForClass:[KVNProgress class]]; +#endif + dispatch_once(&onceToken, ^{ UINib *nib = [UINib nibWithNibName:@"KVNProgressView" - bundle:[NSBundle bundleForClass:[KVNProgress class]]]; + bundle:bundle]; NSArray *nibViews = [nib instantiateWithOwner:self options:0]; diff --git a/KVNProgress/Resources/KVNProgressView.xib b/KVNProgress/Classes/KVNProgressView.xib similarity index 100% rename from KVNProgress/Resources/KVNProgressView.xib rename to KVNProgress/Classes/KVNProgressView.xib diff --git a/Package.swift b/Package.swift index 798ad41..a3d4e3a 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "KVNProgress", defaultLocalization: "en", - platforms: [.iOS(.v9)], + platforms: [.iOS(.v13)], products: [ .library( name: "KVNProgress", diff --git a/README.md b/README.md index c3f52bb..d893dd7 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ If you want to try it yourself, just download/checkout this repository and launc ### Source files 1. Download the [latest code version](http://github.com/kevin-hirsch/KVNProgress/archive/master.zip) or add the repository as a git submodule to your git-tracked project. -2. Drag and drop the **Classes**, **Categories** and also the **Resources** directory from the archive in your project navigator. Make sure to select *Copy items* when asked if you extracted the code archive outside of your project. +2. Drag and drop the **Classes**, **Categories** directory from the archive in your project navigator. Make sure to select *Copy items* when asked if you extracted the code archive outside of your project. 3. Include KVNProgress wherever you need it with `#import `. ## Usage