Skip to content

Commit

Permalink
Merge pull request #18 from 4taras4/xcode9
Browse files Browse the repository at this point in the history
Xcode 9 compatible swift3
  • Loading branch information
4taras4 authored Sep 16, 2017
2 parents 098e731 + 2af5bc4 commit 8939a1f
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 270 deletions.
22 changes: 11 additions & 11 deletions CountryPicker/Classes/CountryPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import CoreTelephony
/// - phoneCode: Phone digit code of country
/// - flag: Flag of country
@objc public protocol CountryPickerDelegate {
func countryPhoneCodePicker(_ picker: CountryPicker, didSelectCountryWithName name: String, countryCode: String, phoneCode: String, flag: UIImage)
func countryPhoneCodePicker(_ picker: CountryPicker, didSelectCountryWithName name: String, countryCode: String, phoneCode: String, flag: UIImage)
}

/// Structure of country code picker
struct Country {
var code: String?
var name: String?
var phoneCode: String?
var flagName: String
public struct Country {
public let code: String?
public let name: String?
public let phoneCode: String?
public let flagName: String

/// Country code initialization
///
Expand All @@ -40,7 +40,7 @@ struct Country {
self.phoneCode = phoneCode
self.flagName = flagName
}

var flag: UIImage? {
return UIImage(named: flagName, in: Bundle(for: CountryPicker.self), compatibleWith: nil)
}
Expand All @@ -67,7 +67,7 @@ open class CountryPicker: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSo

/// Setup country code picker
func setup() {
countries = countryNamesByCode()
countries = CountryPicker.countryNamesByCode()

super.dataSource = self
super.delegate = self
Expand Down Expand Up @@ -118,9 +118,9 @@ open class CountryPicker: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSo
/// sorted array with data
///
/// - Returns: sorted array with all information phone, flag, name
func countryNamesByCode() -> [Country] {
open static func countryNamesByCode() -> [Country] {
var countries = [Country]()
let frameworkBundle = Bundle(for: type(of: self))
let frameworkBundle = Bundle(for: self)
guard let jsonPath = frameworkBundle.path(forResource: "CountryPicker.bundle/Data/countryCodes", ofType: "json"), let jsonData = try? Data(contentsOf: URL(fileURLWithPath: jsonPath)) else {
return countries
}
Expand All @@ -139,7 +139,7 @@ open class CountryPicker: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSo
}

let flagName = "CountryPicker.bundle/Images/\(code.uppercased())"

let country = Country(code: code, name: name, phoneCode: phoneCode, flagName: flagName)
countries.append(country)
}
Expand Down
2 changes: 1 addition & 1 deletion CountryPickerSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'CountryPickerSwift'
s.version = '1.4.4'
s.version = '1.4.5'
s.summary = 'Swift CountryPicker'

# This description is used to generate tags and improve search results.
Expand Down
31 changes: 26 additions & 5 deletions Example/CountryPicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
209CD8A2D854B983A93D2171 /* Pods-CountryPicker_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CountryPicker_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-CountryPicker_Example/Pods-CountryPicker_Example.release.xcconfig"; sourceTree = "<group>"; };
27098C420114D138DF155FC3 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
45FD0ABAAA7AACB6A23990C4 /* Pods-CountryPicker_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CountryPicker_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CountryPicker_Tests/Pods-CountryPicker_Tests.release.xcconfig"; sourceTree = "<group>"; };
5DFDDDFBC529B6FC298982AA /* CountryPicker.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CountryPicker.podspec; path = ../CountryPicker.podspec; sourceTree = "<group>"; };
5DFDDDFBC529B6FC298982AA /* CountryPickerSwift.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CountryPickerSwift.podspec; path = ../CountryPickerSwift.podspec; sourceTree = "<group>"; };
607FACD01AFB9204008FA782 /* CountryPicker_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CountryPicker_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -140,7 +140,7 @@
607FACF51AFB993E008FA782 /* Podspec Metadata */ = {
isa = PBXGroup;
children = (
5DFDDDFBC529B6FC298982AA /* CountryPicker.podspec */,
5DFDDDFBC529B6FC298982AA /* CountryPickerSwift.podspec */,
27098C420114D138DF155FC3 /* README.md */,
FAE7B2B83B39399CA782AC48 /* LICENSE */,
);
Expand Down Expand Up @@ -207,7 +207,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand Down Expand Up @@ -268,13 +268,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-CountryPicker_Tests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
38E3BDED35ED23722584FEE2 /* [CP] Copy Pods Resources */ = {
Expand All @@ -298,9 +301,12 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-CountryPicker_Example/Pods-CountryPicker_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/CountryPickerSwift/CountryPicker.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CountryPicker.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -343,13 +349,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-CountryPicker_Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -410,14 +419,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -457,14 +472,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -74,6 +75,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- CountryPickerSwift (1.4.2)
- CountryPickerSwift (1.4.4)

DEPENDENCIES:
- CountryPickerSwift (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
CountryPickerSwift: 86494e2ce7731ff2aa2263a3584b53f4e3c5a051
CountryPickerSwift: 00bdc937eb320fec9fdabb04befda6454458d94e

PODFILE CHECKSUM: d723b5011b7a7609a69686f941e3de18a743d4d9

COCOAPODS: 1.2.0
COCOAPODS: 1.3.1
6 changes: 3 additions & 3 deletions Example/Pods/Manifest.lock

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

Loading

0 comments on commit 8939a1f

Please sign in to comment.