diff --git a/np_ios_core/.gitignore b/np_ios_core/.gitignore new file mode 100644 index 00000000..805ffc7d --- /dev/null +++ b/np_ios_core/.gitignore @@ -0,0 +1,36 @@ +# macOS +.DS_Store + +# Xcode +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa + +# Bundler +.bundle + +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control +# +# Note: if you ignore the Pods directory, make sure to uncomment +# `pod install` in .travis.yml +# +# Pods/ diff --git a/np_ios_core/NpIosCore.podspec b/np_ios_core/NpIosCore.podspec new file mode 100644 index 00000000..c3ccca30 --- /dev/null +++ b/np_ios_core/NpIosCore.podspec @@ -0,0 +1,26 @@ +Pod::Spec.new do |s| + s.name = 'NpIosCore' + s.version = '0.1.0' + s.summary = 'A short description of NpIosCore.' + s.description = <<-DESC +TODO: Add long description of the pod here. + DESC + s.homepage = 'http://example.com' + s.license = { :type => 'GPLv3' } + s.author = { 'Your Company' => 'email@example.com' } + s.source = { :path => '.' } + + s.ios.deployment_target = '12.0' + + s.source_files = 'NpIosCore/Classes/**/*' + + # s.resource_bundles = { + # 'NpIosCore' => ['NpIosCore/Assets/*.png'] + # } + + # s.public_header_files = 'Pod/Classes/**/*.h' + # s.frameworks = 'UIKit', 'MapKit' + # s.dependency 'AFNetworking', '~> 2.3' + s.dependency 'Flutter' + s.dependency 'Logging' +end diff --git a/np_ios_core/NpIosCore/Assets/.gitkeep b/np_ios_core/NpIosCore/Assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/np_ios_core/NpIosCore/Classes/Error.swift b/np_ios_core/NpIosCore/Classes/Error.swift new file mode 100644 index 00000000..48d74e75 --- /dev/null +++ b/np_ios_core/NpIosCore/Classes/Error.swift @@ -0,0 +1,22 @@ +import Foundation + +public class AppError: Error { + public init(_ message: String? = nil, stackTrace: [String] = Thread.callStackSymbols) { + self.message_ = message + self.stackTrace = stackTrace.joined(separator: "\n") + } + + public var description: String { + return "\(message_ ?? "") (throw: \(String(describing: self))\nStack trace:\n\(stackTrace)" + } + + public var message: String { + return message_ == nil ? String(describing: self) : message_! + } + + public let stackTrace: String + private let message_: String? +} + +public class NilError: AppError { +} diff --git a/np_ios_core/NpIosCore/Classes/Util.swift b/np_ios_core/NpIosCore/Classes/Util.swift new file mode 100644 index 00000000..38392e69 --- /dev/null +++ b/np_ios_core/NpIosCore/Classes/Util.swift @@ -0,0 +1,14 @@ +import Foundation + +public extension Optional { + func unwrap( + _ errorBuilder: (() -> Error)? = nil, + file: String = #fileID, + line: Int = #line + ) throws -> Wrapped { + guard let value = self else { + throw errorBuilder?() ?? NilError("\(type(of: self)) is nil in \(file):\(line)") + } + return value + } +} diff --git a/np_platform_lock/ios/Classes/LockChannelHandler.swift b/np_platform_lock/ios/Classes/LockChannelHandler.swift index 69ede183..c0250175 100644 --- a/np_platform_lock/ios/Classes/LockChannelHandler.swift +++ b/np_platform_lock/ios/Classes/LockChannelHandler.swift @@ -1,5 +1,6 @@ import Flutter import Foundation +import NpIosCore class LockChannelHandler { func onMethodCall(call: FlutterMethodCall, result: FlutterResult) { diff --git a/np_platform_lock/ios/Classes/Util.swift b/np_platform_lock/ios/Classes/Util.swift deleted file mode 100644 index a3f17c05..00000000 --- a/np_platform_lock/ios/Classes/Util.swift +++ /dev/null @@ -1,35 +0,0 @@ -import Foundation - -class AppError: Error { - init(_ message: String? = nil, stackTrace: [String] = Thread.callStackSymbols) { - self.message_ = message - self.stackTrace = stackTrace.joined(separator: "\n") - } - - var description: String { - return "\(message_ ?? "") (throw: \(String(describing: self))\nStack trace:\n\(stackTrace)" - } - - var message: String { - return message_ == nil ? String(describing: self) : message_! - } - - let stackTrace: String - private let message_: String? -} - -class NilError: AppError { -} - -extension Optional { - func unwrap( - _ errorBuilder: (() -> Error)? = nil, - file: String = #fileID, - line: Int = #line - ) throws -> Wrapped { - guard let value = self else { - throw errorBuilder?() ?? NilError("\(type(of: self)) is nil in \(file):\(line)") - } - return value - } -} diff --git a/np_platform_lock/ios/np_platform_lock.podspec b/np_platform_lock/ios/np_platform_lock.podspec index 1fb1cbd7..892a82d7 100644 --- a/np_platform_lock/ios/np_platform_lock.podspec +++ b/np_platform_lock/ios/np_platform_lock.podspec @@ -10,11 +10,12 @@ Pod::Spec.new do |s| A new Flutter plugin project. DESC s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } + s.license = { :type => 'GPLv3' } s.author = { 'Your Company' => 'email@example.com' } s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' + s.dependency 'NpIosCore' s.platform = :ios, '9.0' # Flutter.framework does not contain a i386 slice.