Skip to content

Commit

Permalink
Release 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose authored Oct 2, 2021
2 parents d48ebe4 + 6ecf221 commit de49390
Show file tree
Hide file tree
Showing 268 changed files with 678 additions and 70 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>CountryPickerView.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
6 changes: 3 additions & 3 deletions CountryPickerView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "CountryPickerView"
spec.version = "3.2.0"
spec.version = "3.3.0"
spec.summary = "A simple, customizable view for selecting countries in iOS apps."
spec.homepage = "https://github.com/kizitonwose/CountryPickerView"
spec.license = "MIT"
Expand All @@ -11,8 +11,8 @@ Pod::Spec.new do |spec|
spec.source = { :git => "https://github.com/kizitonwose/CountryPickerView.git", :tag => spec.version }
spec.source_files = "CountryPickerView/**/*.{swift}"
spec.resource_bundles = {
'CountryPickerView' => ['CountryPickerView/Assets/CountryPickerView.bundle/*',
'CountryPickerView/**/*.{xib}']
# See Bundle.swift for why this is named like this.
'CountryPickerView_CountryPickerView' => ['CountryPickerView/Resources/*']
}
spec.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' }

Expand Down
542 changes: 534 additions & 8 deletions CountryPickerView.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions CountryPickerView/Bundle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import class Foundation.Bundle

private class BundleFinder {}

// For some reason this extension for SPM is not geneated when we build the
// framework (CMD + B) but gets generated when the framework is used in a progect.
// Just add it manually with the "_" prefix so it does not clash with the one
// that gets generated when used in a project.
extension Foundation.Bundle {
/// Returns the resource bundle associated with the current Swift module.
static var _module: Bundle = {
// We also use this name for the cocopods bundle (see podspec) so same code is used for SPM and Cocoapods.
let bundleName = "CountryPickerView_CountryPickerView"

let candidates = [
// Bundle should be present here when the package is linked into an App.
Bundle.main.resourceURL,

// Bundle should be present here when the package is linked into a framework.
Bundle(for: BundleFinder.self).resourceURL,

// For command-line tools.
Bundle.main.bundleURL,
]

for candidate in candidates {
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
return bundle
}
}
// This should be a fallback for Carthage.
return Bundle(for: CountryPickerView.self)
// fatalError("unable to find bundle named CountryPickerView_CountryPickerView")
}()
}
30 changes: 13 additions & 17 deletions CountryPickerView/CountryPickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public struct Country: Equatable {
return locale.localizedString(forRegionCode: code)
}
public var flag: UIImage {
return UIImage(named: "CountryPickerView.bundle/Images/\(code.uppercased())",
in: Bundle(for: CountryPickerView.self), compatibleWith: nil)!
// Cocoapods || SPM
return UIImage(named: "Images/\(code.uppercased())", in: Bundle._module, compatibleWith: nil) ??
UIImage.init(named: code.uppercased(), in: Bundle._module, compatibleWith: nil)!
}
}

Expand Down Expand Up @@ -171,27 +172,22 @@ public class CountryPickerView: NibView {

public let countries: [Country] = {
var countries = [Country]()
let bundle = Bundle(for: CountryPickerView.self)
guard let jsonPath = bundle.path(forResource: "CountryPickerView.bundle/Data/CountryCodes", ofType: "json"),
let jsonData = try? Data(contentsOf: URL(fileURLWithPath: jsonPath)) else {
return countries
}

if let jsonObjects = (try? JSONSerialization.jsonObject(with: jsonData, options: JSONSerialization
.ReadingOptions.allowFragments)) as? Array<Any> {

// Cocoapods || SPM
let path = Bundle._module.path(forResource: "Data/CountryCodes", ofType: "json") ??
Bundle._module.path(forResource: "CountryCodes", ofType: "json")
guard let jsonPath = path, let jsonData = try? Data(contentsOf: URL(fileURLWithPath: jsonPath)) else {
return countries
}
if let jsonObjects = (try? JSONSerialization.jsonObject(with: jsonData, options: .allowFragments)) as? Array<Any> {
for jsonObject in jsonObjects {

guard let countryObj = jsonObject as? Dictionary<String, Any> else {
continue
}

guard let name = countryObj["name"] as? String,
let code = countryObj["code"] as? String,
let phoneCode = countryObj["dial_code"] as? String else {
continue
let code = countryObj["code"] as? String,
let phoneCode = countryObj["dial_code"] as? String else {
continue
}

let country = Country(name: name, code: code, phoneCode: phoneCode)
countries.append(country)
}
Expand Down
11 changes: 1 addition & 10 deletions CountryPickerView/NibView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,7 @@ public class NibView: UIView {

fileprivate func loadViewFromNib() -> UIView {
let selfName = String(describing: type(of: self))
let podBundle = Bundle(for: type(of: self))
let nibBundleURL = podBundle.url(forResource: selfName, withExtension: "bundle")!
var nibBundle = Bundle(url: nibBundleURL)
// The framework crashes if installed via Carthage because the nib
// file does not exist in the nibBundle but rather in the podBundle.
// This is a workaround.
if nibBundle?.url(forResource: selfName, withExtension: "nib") == nil {
nibBundle = podBundle
}
let nib = UINib(nibName: selfName, bundle: nibBundle)
let nib = UINib(nibName: selfName, bundle: Bundle._module)
let nibView = nib.instantiate(withOwner: self, options: nil).first as! UIView
return nibView
}
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
004CA2FB1F705DD600B690B8 /* Sources */,
004CA2FC1F705DD600B690B8 /* Frameworks */,
004CA2FD1F705DD600B690B8 /* Resources */,
D073A94C45743AB4CB4D944D /* [CP] Embed Pods Frameworks */,
509720AE1FDEE189001244B0 /* Embed Frameworks */,
93906A0D2037B5BC9ACD5600 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -177,7 +177,7 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
D073A94C45743AB4CB4D944D /* [CP] Embed Pods Frameworks */ = {
93906A0D2037B5BC9ACD5600 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,97 @@
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
4 changes: 2 additions & 2 deletions CountryPickerViewDemo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
CountryPickerView: 9b093bfffb4b06a69ba6185a798cadbf863720e7
CountryPickerView: 680940ad6a502cda951dd1b82547b0c78a03ccd7

PODFILE CHECKSUM: 1cd5c4aa4d0640ed508d2a66a00ff43232db9ee3

COCOAPODS: 1.9.3
COCOAPODS: 1.10.1
4 changes: 3 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ let package = Package(
targets: [
.target(
name: "CountryPickerView",
path: "CountryPickerView"
path: "CountryPickerView",
resources: [
.process("Resources")]
)
]
)
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Platform](https://img.shields.io/badge/Platform-iOS-00BCD4.svg)](http://cocoapods.org/pods/CountryPickerView)
[![Version](https://img.shields.io/cocoapods/v/CountryPickerView.svg?style=flat)](http://cocoapods.org/pods/CountryPickerView)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![SPM compatible](https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager)
[![License](https://img.shields.io/badge/License-MIT-8D6E63.svg)](https://github.com/kizitonwose/CountryPickerView/blob/master/LICENSE.md)

CountryPickerView is a simple, customizable view for selecting countries in iOS apps.
Expand All @@ -21,6 +22,11 @@ You can clone/download the repository and run the [demo project](https://github.

> Note that 3.x releases are Swift 5 compatible. For the Swift 4 compatibility, use 2.x releases. For the Swift 3 compatibility, use 1.x releases.
### Swift Package Manager
[Swift Package Manager](https://swift.org/package-manager) is a dependency manager built into Xcode.

If you are using Xcode 11 or higher, go to `File / Swift Packages / Add Package Dependency…` and enter package repository URL https://github.com/kizitonwose/CountryPickerView.git then follow the instructions.

### Cocoapods

CountryPickerView is available through [CocoaPods](http://cocoapods.org). Simply add the following to your Podfile:
Expand Down

0 comments on commit de49390

Please sign in to comment.