-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jenkins
committed
Mar 4, 2022
1 parent
c2155a8
commit dda4548
Showing
41 changed files
with
2,048 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# CardIO и интеграция через dev pod | ||
|
||
Дано: CardIO не поддерживается уже долгое время, сам репозиторий заархивирован. В последнем релизе 5.4.1 присутсвует | ||
проблема что при установке через cocoapods не генерируется modulemap файл и библиотеку приходится дополнительно | ||
подключать через Bridging header. Это приводит к проблеме с которой мы столкнулись в Xcode 13 в наших проектах | ||
на Swift. На некоторых машинах начала появлятся ошибка: | ||
``` | ||
error: using bridging headers with module interfaces is unsupported Command CompileSwiftSources failed with a nonzero exit code | ||
``` | ||
|
||
Ошибка возникает независимо от настроек в подфайле или в конкретных подах. На некоторых машинах | ||
был ограниченный успех при выставлении настройки BUILD_LIBRARY_FOR_DISTRIBUTION=NO в Podfile, в post_install фазе. | ||
|
||
Для решения проблемы есть несколько вариантов относительно архивного состояния исходного репозитория. | ||
|
||
1. Собрать CardIO.framework из исходников вручную и подключить в проект. | ||
------ | ||
Это решение может быть довольно накладным, так как сами архивные исходники требуют некоторой, пусть и минимальной, | ||
настройки для того чтобы успешно собираться. Также требуется внести ручную линковку относительно некоторого набора | ||
библиотек из IOS SDK в фазе Link Binary With Libraries. | ||
|
||
2. Подключение CardIO как development pod. | ||
----- | ||
Позволяет локально решить проблему генерации modulemap реализацией изменений из | ||
https://github.com/card-io/card.io-iOS-SDK/pull/284 | ||
Преимущество также состоит в минимальном количестве усилий для достижения результата. | ||
Нетривиальные особенности решения: | ||
1) Добавление в исходники .m файлов активирует генерацию modulemap файла | ||
```spec.source_files = 'CardIO/*.{h,m}'``` | ||
2) Переименование libCardIO.a в libCardIOCore.a из-за конфликта линковки. | ||
https://github.com/card-io/card.io-iOS-SDK/pull/284#issuecomment-377663436 | ||
|
||
|
||
Альтернативный вариант: сделать свой форк https://github.com/card-io/ внести эти изменения и подключить его в Podfile. | ||
|
||
|
||
Это конечно не решает ошибку `using bridging headers with module interfaces` в общем случае, так как всегда есть | ||
вероятность наличия другого Objective-C кода подключенного напрямую в проект. Для этих случаев мы предлагаем | ||
упаковать необходимый код в локальную зависимость любым удобным способом. | ||
|
||
В YooKassaPaymentsDemoApp мы приводим простой пример упаковки Objective-C кода в Swift Package. | ||
|
||
Если ваш проект использует другие зависимости которые необходимо подключать через Bridging Header, то надеемся что | ||
пример с подключением CardIO окажется полезным и сэкономит вам время. | ||
|
||
На сегодняшний день мы не смогли найти непреодолимых причин подключения Objective-C кода через Briding Header. Если у | ||
вас есть подобный пример, мы будем рады если вы с нами им поделитесь. | ||
Мы продолжим исследование проблемы для более глубокого понимания её причин и разработки новых вариантов решения. | ||
|
||
Дополнительно о модулярных фреймворках можно найти информацию по следущим ссылкам: | ||
|
||
https://clang.llvm.org/docs/Modules.html | ||
http://nsomar.io/modular-framework-creating-and-using-them/ | ||
https://github.com/search?utf8=✓&q=modulemap+language%3Aswift&type= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Pod::Spec.new do |spec| | ||
spec.name = 'CardIO' | ||
spec.version = '5.4.1' | ||
spec.license = { type: 'MIT', file: 'CardIO/LICENSE.md' } | ||
spec.homepage = 'https://www.card.io' | ||
spec.authors = { 'CardIO' => '[email protected]' } | ||
spec.summary = 'Credit card scanning for mobile apps' | ||
spec.social_media_url = 'https://twitter.com/cardio' | ||
spec.source = { :git => 'https://github.com/card-io/card.io-iOS-SDK.git', :tag => "#{spec.version}" } | ||
spec.platform = :ios, '6.1' | ||
spec.ios.deployment_target = '6.1' | ||
spec.requires_arc = true | ||
spec.source_files = 'CardIO/*.{h,m}' | ||
spec.frameworks = 'Accelerate', 'AVFoundation', 'AudioToolbox', 'CoreGraphics', 'CoreMedia', 'CoreVideo', 'CoreServices', 'OpenGLES', 'QuartzCore', 'Security', 'UIKit' | ||
spec.libraries = 'c++' | ||
spec.vendored_libraries = 'CardIO/libCardIOCore.a', 'CardIO/libopencv_core.a', 'CardIO/libopencv_imgproc.a' | ||
spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-ObjC' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// CardIO.h | ||
// Version 5.4.1 | ||
// | ||
// See the file "LICENSE.md" for the full license governing this code. | ||
// | ||
|
||
// All-in-one header file for card.io sdk. | ||
#import "CardIOCreditCardInfo.h" | ||
#import "CardIODetectionMode.h" | ||
#import "CardIOView.h" | ||
#import "CardIOViewDelegate.h" | ||
#import "CardIOPaymentViewController.h" | ||
#import "CardIOPaymentViewControllerDelegate.h" | ||
#import "CardIOUtilities.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// | ||
// This file exists so that CocoaPods will generate a modulemap for CardIO | ||
// | ||
// See https://github.com/card-io/card.io-iOS-SDK/issues/115 | ||
// and https://github.com/card-io/card.io-iOS-SDK/pull/126 | ||
// for more details | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// CardIOCreditCardInfo.h | ||
// Version 5.4.1 | ||
// | ||
// See the file "LICENSE.md" for the full license governing this code. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
/// CardIOCreditCardType Identifies type of card. | ||
typedef NS_ENUM(NSInteger, CardIOCreditCardType) { | ||
/// The card number does not correspond to any recognizable card type. | ||
CardIOCreditCardTypeUnrecognized = 0, | ||
/// The card number corresponds to multiple card types (e.g., when only a few digits have been entered). | ||
CardIOCreditCardTypeAmbiguous = 1, | ||
/// American Express | ||
CardIOCreditCardTypeAmex = '3', | ||
/// Japan Credit Bureau | ||
CardIOCreditCardTypeJCB = 'J', | ||
/// VISA | ||
CardIOCreditCardTypeVisa = '4', | ||
/// MasterCard | ||
CardIOCreditCardTypeMastercard = '5', | ||
/// Discover Card | ||
CardIOCreditCardTypeDiscover = '6' | ||
}; | ||
|
||
|
||
/// Container for the information about a card. | ||
@interface CardIOCreditCardInfo : NSObject<NSCopying> | ||
|
||
/// Card number. | ||
@property(nonatomic, copy, readwrite) NSString *cardNumber; | ||
|
||
/// Card number with all but the last four digits obfuscated. | ||
@property(nonatomic, copy, readonly) NSString *redactedCardNumber; | ||
|
||
/// January == 1 | ||
/// @note expiryMonth & expiryYear may be 0, if expiry information was not requested. | ||
@property(nonatomic, assign, readwrite) NSUInteger expiryMonth; | ||
|
||
/// The full four digit year. | ||
/// @note expiryMonth & expiryYear may be 0, if expiry information was not requested. | ||
@property(nonatomic, assign, readwrite) NSUInteger expiryYear; | ||
|
||
/// Security code (aka CSC, CVV, CVV2, etc.) | ||
/// @note May be nil, if security code was not requested. | ||
@property(nonatomic, copy, readwrite) NSString *cvv; | ||
|
||
/// Postal code. Format is country dependent. | ||
/// @note May be nil, if postal code information was not requested. | ||
@property(nonatomic, copy, readwrite) NSString *postalCode; | ||
|
||
/// Cardholder Name. | ||
/// @note May be nil, if cardholder name was not requested. | ||
@property(nonatomic, copy, readwrite) NSString *cardholderName; | ||
|
||
/// Was the card number scanned (as opposed to entered manually)? | ||
@property(nonatomic, assign, readwrite) BOOL scanned; | ||
|
||
/// The rectified card image; usually 428x270. | ||
@property(nonatomic, strong, readwrite) UIImage *cardImage; | ||
|
||
/// Derived from cardNumber. | ||
/// @note CardIOCreditInfo objects returned by either of the delegate methods | ||
/// userDidProvideCreditCardInfo:inPaymentViewController: | ||
/// or cardIOView:didScanCard: | ||
/// will never return a cardType of CardIOCreditCardTypeAmbiguous. | ||
@property(nonatomic, assign, readonly) CardIOCreditCardType cardType; | ||
|
||
/// Convenience method which returns a card type string suitable for display (e.g. "Visa", "American Express", "JCB", "MasterCard", or "Discover"). | ||
/// Where appropriate, this string will be translated into the language specified. | ||
/// @param cardType The card type. | ||
/// @param languageOrLocale See CardIOPaymentViewController.h for a detailed explanation of languageOrLocale. | ||
/// @return Card type string suitable for display. | ||
+ (NSString *)displayStringForCardType:(CardIOCreditCardType)cardType usingLanguageOrLocale:(NSString *)languageOrLocale; | ||
|
||
/// Returns a 36x25 credit card logo, at a resolution appropriate for the device. | ||
/// @param cardType The card type. | ||
/// @return 36x25 credit card logo. | ||
+ (UIImage *)logoForCardType:(CardIOCreditCardType)cardType; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// CardIODetectionMode.h | ||
// Version 5.4.1 | ||
// | ||
// See the file "LICENSE.md" for the full license governing this code. | ||
// | ||
// | ||
|
||
#ifndef icc_CardIODetectionMode_h | ||
#define icc_CardIODetectionMode_h | ||
|
||
typedef NS_ENUM(NSInteger, CardIODetectionMode) { | ||
CardIODetectionModeCardImageAndNumber = 0, | ||
CardIODetectionModeCardImageOnly, | ||
CardIODetectionModeAutomatic | ||
}; | ||
|
||
#endif | ||
|
Oops, something went wrong.