
مرحبا! ستتعلم في هذه السلسلة الصغيرة من المقالات:
كيف ترث فئة Swift ليس بالكامل ، ولكن فقط ما تحتاجه فيها؟
كيف تسمح لمستخدمي مكتبة CocoaPods أو مكتبة قرطاج الخاصة بك بتجميع الأجزاء التي يستخدمونها بالفعل فقط؟
كيفية تمزيق موارد iOS للحصول على رموز نظام محددة وسلاسل مترجمة من هناك؟
كيف يمكن دعم كتل الإكمال حتى في حالة عدم توفرها بواسطة واجهة برمجة تطبيقات إذن النظام الافتراضية؟

, , iOS — . , !
— . ? . ? .
Apple, Stack Overflow. , , - .
GitHub , , . , — , - , .
. . , , . , PermissionWizard...
iOS 14 macOS 11 Big Sur
Mac Catalyst
«Info.plist» , -
, API
, - , , ,
DispatchQueue.main
Swift
API ,
UI
, ,
- ...
, , ?
PermissionWizard, , :
usageDescriptionPlistKey
checkStatus
requestAccess
, , , .
, , , Swift Xcode , — .
, :
(, ) , ,
checkStatus
. — , .
requestAccess(completion:)
, , , .requestAccess(whenInUseOnly:completion:)
, - , .
plist- — (NSPhotoLibraryUsageDescription) , (NSPhotoLibraryAddUsageDescription). , -
usageDescriptionPlistKey
— .
. . , 18 , , .
-. , . , — .
class SupportedType {
func requestAccess(completion: (Status) -> Void) { }
}
final class Bluetooth: SupportedType { ... }
final class Location: SupportedType {
@available(*, unavailable)
override func requestAccess(completion: (Status) -> Void) { }
func requestAccess(whenInUseOnly: Bool, completion: (Status) -> Void) { ... }
}
, @available(*, unavailable)
, , , Xcode, .
, , , .
CocoaPods- Carthage- , ?
PermissionWizard 18 — Siri iOS 14 . , AVKit, CoreBluetooth, CoreLocation, CoreMotion, EventKit, HealthKit, HomeKit .
, , - , Apple App Store, , API . , — . - .
CocoaPods
. , , . , .
pod 'PermissionWizard/Assets' # Icons and localized strings
pod 'PermissionWizard/Bluetooth'
pod 'PermissionWizard/Calendars'
pod 'PermissionWizard/Camera'
pod 'PermissionWizard/Contacts'
pod 'PermissionWizard/FaceID'
pod 'PermissionWizard/Health'
pod 'PermissionWizard/Home'
pod 'PermissionWizard/LocalNetwork'
pod 'PermissionWizard/Location'
pod 'PermissionWizard/Microphone'
pod 'PermissionWizard/Motion'
pod 'PermissionWizard/Music'
pod 'PermissionWizard/Notifications'
pod 'PermissionWizard/Photos'
pod 'PermissionWizard/Reminders'
pod 'PermissionWizard/Siri'
pod 'PermissionWizard/SpeechRecognition'
pod 'PermissionWizard/Tracking'
, «Podspec» (, CocoaPods) :
Pod::Spec.new do |spec|
...
spec.subspec 'Core' do |core|
core.source_files = 'Source/Permission.swift', 'Source/Framework'
end
spec.subspec 'Assets' do |assets|
assets.dependency 'PermissionWizard/Core'
assets.pod_target_xcconfig = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'ASSETS' }
assets.resource_bundles = {
'Icons' => 'Source/Icons.xcassets',
'Localizations' => 'Source/Localizations/*.lproj'
}
end
spec.subspec 'Bluetooth' do |bluetooth|
bluetooth.dependency 'PermissionWizard/Core'
bluetooth.pod_target_xcconfig = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'BLUETOOTH' }
bluetooth.source_files = 'Source/Supported Types/Bluetooth*.swift'
end
...
spec.default_subspec = 'Assets', 'Bluetooth', 'Calendars', 'Camera', 'Contacts', 'FaceID', 'Health', 'Home', 'LocalNetwork', 'Location', 'Microphone', 'Motion', 'Music', 'Notifications', 'Photos', 'Reminders', 'Siri', 'SpeechRecognition', 'Tracking'
end
, , .
#if BLUETOOTH
final class Bluetooth { ... }
#endif
Carthage
. , - — , . , - .
«Settings.xcconfig» :
#include? "../../../../PermissionWizard.xcconfig"
Carthage «Carthage/Build/iOS», «PermissionWizard.xcconfig», .
:
ENABLED_FEATURES = ASSETS BLUETOOTH ... SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) $(ENABLED_FEATURES) CUSTOM_SETTINGS
, , «Settings.xcconfig» . , , «project.pbxproj» . , , .
A53DFF50255AAB8200995A85 /* Settings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Settings.xcconfig; sourceTree = "<group>"; };
«XCBuildConfiguration» ( 3):
B6DAF0412528D771002483A6 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A53DFF50255AAB8200995A85 /* Settings.xcconfig */;
buildSettings = {
...
};
name = Release;
};
, CUSTOM_SETTINGS
. — , , «PermissionWizard.xcconfig» , .
#if BLUETOOTH || !CUSTOM_SETTINGS
final class Bluetooth { ... }
#endif
هذا كل شئ حتى الان
في الجزء التالي ، سنتحدث عن كيفية العثور على السلاسل المترجمة التي احتاجها بين 5 غيغابايت من نظام iOS 14 وكيف حصلت على أيقونات جميع أذونات النظام. وسأخبرك أيضًا كيف تمكنت من تقديمه requestAccess(completion:)
حتى عندما لا تدعم واجهة برمجة تطبيقات إذن النظام الافتراضية عمليات الاسترجاعات.
شكرا للاهتمام!