diff --git a/RNPermissions.podspec b/RNPermissions.podspec index 1dc4d0d8..60e121b5 100644 --- a/RNPermissions.podspec +++ b/RNPermissions.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.source = { :git => package["repository"]["url"], :tag => s.version } - s.source_files = "ios/*.{h,m,mm}" + s.source_files = "ios/*.{h,mm}" if ENV['RCT_NEW_ARCH_ENABLED'] == "1" then install_modules_dependencies(s) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 8b3221fd..abbb019f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1382,7 +1382,7 @@ SPEC CHECKSUMS: React-runtimescheduler: ed48e5faac6751e66ee1261c4bd01643b436f112 React-utils: 6e5ad394416482ae21831050928ae27348f83487 ReactCommon: 840a955d37b7f3358554d819446bffcf624b2522 - RNPermissions: 17daec882a3e12cc1d98baa7bbb7108a3515827e + RNPermissions: 09766cc679a5bb91aa300d7cbce64db250e1a5c3 RNVectorIcons: 210f910e834e3485af40693ad4615c1ec22fc02b SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 diff --git a/example/ios/RNPermissionsExample.xcodeproj/project.pbxproj b/example/ios/RNPermissionsExample.xcodeproj/project.pbxproj index 002263ec..16e7780d 100644 --- a/example/ios/RNPermissionsExample.xcodeproj/project.pbxproj +++ b/example/ios/RNPermissionsExample.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; - DDCFC0EE2B1CDF540082F946 /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDCFC0ED2B1CDF540082F946 /* PhotosUI.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -26,7 +25,6 @@ 5709B34CF0A7D63546082F79 /* Pods-RNPermissionsExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNPermissionsExample.release.xcconfig"; path = "Target Support Files/Pods-RNPermissionsExample/Pods-RNPermissionsExample.release.xcconfig"; sourceTree = ""; }; 5DCACB8F33CDC322A6C60F78 /* libPods-RNPermissionsExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNPermissionsExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = RNPermissionsExample/LaunchScreen.storyboard; sourceTree = ""; }; - DDCFC0ED2B1CDF540082F946 /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -36,7 +34,6 @@ buildActionMask = 2147483647; files = ( 0C80B921A6F3F58F76C31292 /* libPods-RNPermissionsExample.a in Frameworks */, - DDCFC0EE2B1CDF540082F946 /* PhotosUI.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -59,7 +56,6 @@ 2D16E6871FA4F8E400B85C8A /* Frameworks */ = { isa = PBXGroup; children = ( - DDCFC0ED2B1CDF540082F946 /* PhotosUI.framework */, ED297162215061F000B7C4FE /* JavaScriptCore.framework */, 5DCACB8F33CDC322A6C60F78 /* libPods-RNPermissionsExample.a */, ); diff --git a/ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.m b/ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.mm similarity index 97% rename from ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.m rename to ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.mm index 4e298862..e9476d27 100644 --- a/ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.m +++ b/ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.mm @@ -1,7 +1,7 @@ #import "RNPermissionHandlerAppTrackingTransparency.h" -@import AppTrackingTransparency; -@import AdSupport; +#import +#import @interface RNPermissionHandlerAppTrackingTransparency() diff --git a/ios/Bluetooth/RNPermissionHandlerBluetooth.m b/ios/Bluetooth/RNPermissionHandlerBluetooth.mm similarity index 98% rename from ios/Bluetooth/RNPermissionHandlerBluetooth.m rename to ios/Bluetooth/RNPermissionHandlerBluetooth.mm index 885890d6..88f766c0 100644 --- a/ios/Bluetooth/RNPermissionHandlerBluetooth.m +++ b/ios/Bluetooth/RNPermissionHandlerBluetooth.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerBluetooth.h" -@import CoreBluetooth; +#import @interface RNPermissionHandlerBluetooth() diff --git a/ios/Calendars/RNPermissionHandlerCalendars.m b/ios/Calendars/RNPermissionHandlerCalendars.mm similarity index 98% rename from ios/Calendars/RNPermissionHandlerCalendars.m rename to ios/Calendars/RNPermissionHandlerCalendars.mm index cc26725f..85092d5f 100644 --- a/ios/Calendars/RNPermissionHandlerCalendars.m +++ b/ios/Calendars/RNPermissionHandlerCalendars.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerCalendars.h" -@import EventKit; +#import @implementation RNPermissionHandlerCalendars diff --git a/ios/CalendarsWriteOnly/RNPermissionHandlerCalendarsWriteOnly.m b/ios/CalendarsWriteOnly/RNPermissionHandlerCalendarsWriteOnly.mm similarity index 98% rename from ios/CalendarsWriteOnly/RNPermissionHandlerCalendarsWriteOnly.m rename to ios/CalendarsWriteOnly/RNPermissionHandlerCalendarsWriteOnly.mm index 8dcd9070..fa14867c 100644 --- a/ios/CalendarsWriteOnly/RNPermissionHandlerCalendarsWriteOnly.m +++ b/ios/CalendarsWriteOnly/RNPermissionHandlerCalendarsWriteOnly.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerCalendarsWriteOnly.h" -@import EventKit; +#import @implementation RNPermissionHandlerCalendarsWriteOnly diff --git a/ios/Camera/RNPermissionHandlerCamera.m b/ios/Camera/RNPermissionHandlerCamera.mm similarity index 97% rename from ios/Camera/RNPermissionHandlerCamera.m rename to ios/Camera/RNPermissionHandlerCamera.mm index b5910c25..36c2a430 100644 --- a/ios/Camera/RNPermissionHandlerCamera.m +++ b/ios/Camera/RNPermissionHandlerCamera.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerCamera.h" -@import AVFoundation; +#import @implementation RNPermissionHandlerCamera diff --git a/ios/Contacts/RNPermissionHandlerContacts.m b/ios/Contacts/RNPermissionHandlerContacts.mm similarity index 97% rename from ios/Contacts/RNPermissionHandlerContacts.m rename to ios/Contacts/RNPermissionHandlerContacts.mm index b6ac89b3..3df413e3 100644 --- a/ios/Contacts/RNPermissionHandlerContacts.m +++ b/ios/Contacts/RNPermissionHandlerContacts.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerContacts.h" -@import Contacts; +#import @implementation RNPermissionHandlerContacts diff --git a/ios/FaceID/RNPermissionHandlerFaceID.m b/ios/FaceID/RNPermissionHandlerFaceID.mm similarity index 98% rename from ios/FaceID/RNPermissionHandlerFaceID.m rename to ios/FaceID/RNPermissionHandlerFaceID.mm index 071eb8ea..05875003 100644 --- a/ios/FaceID/RNPermissionHandlerFaceID.m +++ b/ios/FaceID/RNPermissionHandlerFaceID.mm @@ -1,7 +1,6 @@ #import "RNPermissionHandlerFaceID.h" -@import LocalAuthentication; -@import UIKit; +#import static NSString* SETTING_KEY = @"@RNPermissions:Requested"; diff --git a/ios/LocationAccuracy/RNPermissionHandlerLocationAccuracy.m b/ios/LocationAccuracy/RNPermissionHandlerLocationAccuracy.mm similarity index 98% rename from ios/LocationAccuracy/RNPermissionHandlerLocationAccuracy.m rename to ios/LocationAccuracy/RNPermissionHandlerLocationAccuracy.mm index 314b3829..3cc64aec 100644 --- a/ios/LocationAccuracy/RNPermissionHandlerLocationAccuracy.m +++ b/ios/LocationAccuracy/RNPermissionHandlerLocationAccuracy.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerLocationAccuracy.h" -@import CoreLocation; +#import @interface RNPermissionHandlerLocationAccuracy() diff --git a/ios/LocationAlways/RNPermissionHandlerLocationAlways.m b/ios/LocationAlways/RNPermissionHandlerLocationAlways.mm similarity index 98% rename from ios/LocationAlways/RNPermissionHandlerLocationAlways.m rename to ios/LocationAlways/RNPermissionHandlerLocationAlways.mm index e20d4fe0..00b734f8 100644 --- a/ios/LocationAlways/RNPermissionHandlerLocationAlways.m +++ b/ios/LocationAlways/RNPermissionHandlerLocationAlways.mm @@ -1,7 +1,6 @@ #import "RNPermissionHandlerLocationAlways.h" -@import CoreLocation; -@import UIKit; +#import @interface RNPermissionHandlerLocationAlways() diff --git a/ios/LocationWhenInUse/RNPermissionHandlerLocationWhenInUse.m b/ios/LocationWhenInUse/RNPermissionHandlerLocationWhenInUse.mm similarity index 98% rename from ios/LocationWhenInUse/RNPermissionHandlerLocationWhenInUse.m rename to ios/LocationWhenInUse/RNPermissionHandlerLocationWhenInUse.mm index 9e133ea3..df174c51 100644 --- a/ios/LocationWhenInUse/RNPermissionHandlerLocationWhenInUse.m +++ b/ios/LocationWhenInUse/RNPermissionHandlerLocationWhenInUse.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerLocationWhenInUse.h" -@import CoreLocation; +#import @interface RNPermissionHandlerLocationWhenInUse() diff --git a/ios/MediaLibrary/RNPermissionHandlerMediaLibrary.m b/ios/MediaLibrary/RNPermissionHandlerMediaLibrary.mm similarity index 97% rename from ios/MediaLibrary/RNPermissionHandlerMediaLibrary.m rename to ios/MediaLibrary/RNPermissionHandlerMediaLibrary.mm index 05c48860..6176c400 100644 --- a/ios/MediaLibrary/RNPermissionHandlerMediaLibrary.m +++ b/ios/MediaLibrary/RNPermissionHandlerMediaLibrary.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerMediaLibrary.h" -@import MediaPlayer; +#import @implementation RNPermissionHandlerMediaLibrary diff --git a/ios/Microphone/RNPermissionHandlerMicrophone.m b/ios/Microphone/RNPermissionHandlerMicrophone.mm similarity index 97% rename from ios/Microphone/RNPermissionHandlerMicrophone.m rename to ios/Microphone/RNPermissionHandlerMicrophone.mm index a41577c9..b3c85016 100644 --- a/ios/Microphone/RNPermissionHandlerMicrophone.m +++ b/ios/Microphone/RNPermissionHandlerMicrophone.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerMicrophone.h" -@import AVFoundation; +#import @implementation RNPermissionHandlerMicrophone diff --git a/ios/Motion/RNPermissionHandlerMotion.m b/ios/Motion/RNPermissionHandlerMotion.mm similarity index 98% rename from ios/Motion/RNPermissionHandlerMotion.m rename to ios/Motion/RNPermissionHandlerMotion.mm index ab43a0bd..3a4f2576 100644 --- a/ios/Motion/RNPermissionHandlerMotion.m +++ b/ios/Motion/RNPermissionHandlerMotion.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerMotion.h" -@import CoreMotion; +#import @interface RNPermissionHandlerMotion() diff --git a/ios/Notifications/RNPermissionHandlerNotifications.m b/ios/Notifications/RNPermissionHandlerNotifications.mm similarity index 99% rename from ios/Notifications/RNPermissionHandlerNotifications.m rename to ios/Notifications/RNPermissionHandlerNotifications.mm index e59dfd47..faef058e 100644 --- a/ios/Notifications/RNPermissionHandlerNotifications.m +++ b/ios/Notifications/RNPermissionHandlerNotifications.mm @@ -1,7 +1,6 @@ #import "RNPermissionHandlerNotifications.h" -@import UserNotifications; -@import UIKit; +#import @interface RNPermissionHandlerNotifications() diff --git a/ios/PhotoLibrary/RNPermissionHandlerPhotoLibrary.m b/ios/PhotoLibrary/RNPermissionHandlerPhotoLibrary.mm similarity index 98% rename from ios/PhotoLibrary/RNPermissionHandlerPhotoLibrary.m rename to ios/PhotoLibrary/RNPermissionHandlerPhotoLibrary.mm index a63c890c..9f306629 100644 --- a/ios/PhotoLibrary/RNPermissionHandlerPhotoLibrary.m +++ b/ios/PhotoLibrary/RNPermissionHandlerPhotoLibrary.mm @@ -1,8 +1,8 @@ #import "RNPermissionHandlerPhotoLibrary.h" #import -@import Photos; -@import PhotosUI; +#import +#import @implementation RNPermissionHandlerPhotoLibrary diff --git a/ios/PhotoLibraryAddOnly/RNPermissionHandlerPhotoLibraryAddOnly.m b/ios/PhotoLibraryAddOnly/RNPermissionHandlerPhotoLibraryAddOnly.mm similarity index 98% rename from ios/PhotoLibraryAddOnly/RNPermissionHandlerPhotoLibraryAddOnly.m rename to ios/PhotoLibraryAddOnly/RNPermissionHandlerPhotoLibraryAddOnly.mm index d73583a1..aadde22c 100644 --- a/ios/PhotoLibraryAddOnly/RNPermissionHandlerPhotoLibraryAddOnly.m +++ b/ios/PhotoLibraryAddOnly/RNPermissionHandlerPhotoLibraryAddOnly.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerPhotoLibraryAddOnly.h" -@import Photos; +#import @implementation RNPermissionHandlerPhotoLibraryAddOnly diff --git a/ios/RNPermissions.xcodeproj/project.pbxproj b/ios/RNPermissions.xcodeproj/project.pbxproj index 1e504520..2fef47b8 100644 --- a/ios/RNPermissions.xcodeproj/project.pbxproj +++ b/ios/RNPermissions.xcodeproj/project.pbxproj @@ -95,7 +95,7 @@ }; buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNPermissions" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, diff --git a/ios/Reminders/RNPermissionHandlerReminders.m b/ios/Reminders/RNPermissionHandlerReminders.mm similarity index 98% rename from ios/Reminders/RNPermissionHandlerReminders.m rename to ios/Reminders/RNPermissionHandlerReminders.mm index b478b739..2fe34619 100644 --- a/ios/Reminders/RNPermissionHandlerReminders.m +++ b/ios/Reminders/RNPermissionHandlerReminders.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerReminders.h" -@import EventKit; +#import @implementation RNPermissionHandlerReminders diff --git a/ios/Siri/RNPermissionHandlerSiri.m b/ios/Siri/RNPermissionHandlerSiri.mm similarity index 97% rename from ios/Siri/RNPermissionHandlerSiri.m rename to ios/Siri/RNPermissionHandlerSiri.mm index 0b6e8249..7c60741f 100644 --- a/ios/Siri/RNPermissionHandlerSiri.m +++ b/ios/Siri/RNPermissionHandlerSiri.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerSiri.h" -@import Intents; +#import @implementation RNPermissionHandlerSiri diff --git a/ios/SpeechRecognition/RNPermissionHandlerSpeechRecognition.m b/ios/SpeechRecognition/RNPermissionHandlerSpeechRecognition.mm similarity index 98% rename from ios/SpeechRecognition/RNPermissionHandlerSpeechRecognition.m rename to ios/SpeechRecognition/RNPermissionHandlerSpeechRecognition.mm index a1cf861e..afe8d004 100644 --- a/ios/SpeechRecognition/RNPermissionHandlerSpeechRecognition.m +++ b/ios/SpeechRecognition/RNPermissionHandlerSpeechRecognition.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerSpeechRecognition.h" -@import Speech; +#import @implementation RNPermissionHandlerSpeechRecognition diff --git a/ios/StoreKit/RNPermissionHandlerStoreKit.m b/ios/StoreKit/RNPermissionHandlerStoreKit.mm similarity index 97% rename from ios/StoreKit/RNPermissionHandlerStoreKit.m rename to ios/StoreKit/RNPermissionHandlerStoreKit.mm index 7467783c..a107d62e 100644 --- a/ios/StoreKit/RNPermissionHandlerStoreKit.m +++ b/ios/StoreKit/RNPermissionHandlerStoreKit.mm @@ -1,6 +1,6 @@ #import "RNPermissionHandlerStoreKit.h" -@import StoreKit; +#import @implementation RNPermissionHandlerStoreKit diff --git a/scripts/setup.rb b/scripts/setup.rb index d1460ce9..1f23d728 100644 --- a/scripts/setup.rb +++ b/scripts/setup.rb @@ -9,6 +9,29 @@ def setup_permissions(config) return log_warning("Invalid config argument") end + permissions_frameworks = { + 'AppTrackingTransparency' => ['AdSupport', 'AppTrackingTransparency'], + 'Bluetooth' => ['CoreBluetooth'], + 'Calendars' => ['EventKit'], + 'CalendarsWriteOnly' => ['EventKit'], + 'Camera' => ['AVFoundation'], + 'Contacts' => ['Contacts'], + 'FaceID' => ['LocalAuthentication'], + 'LocationAccuracy' => ['CoreLocation'], + 'LocationAlways' => ['CoreLocation'], + 'LocationWhenInUse' => ['CoreLocation'], + 'MediaLibrary' => ['MediaPlayer'], + 'Microphone' => ['AVFoundation'], + 'Motion' => ['CoreMotion'], + 'Notifications' => ['UserNotifications'], + 'PhotoLibrary' => ['Photos', 'PhotosUI'], + 'PhotoLibraryAddOnly' => ['Photos'], + 'Reminders' => ['EventKit'], + 'Siri' => ['Intents'], + 'SpeechRecognition' => ['Speech'], + 'StoreKit' => ['StoreKit'] + } + module_dir = File.expand_path('..', __dir__) ios_dir = File.join(module_dir, 'ios') ios_dirents = Dir.entries(ios_dir).map { |entry| File.join(ios_dir, entry) } @@ -18,20 +41,33 @@ def setup_permissions(config) .map { |entry| File.basename(entry) } .select { |name| config.include?(name) } - source_files = [ - '"ios/*.{h,m,mm}"', - *directories.map { |name| "\"ios/#{name}/*.{h,m,mm}\"" } - ] - unknown_permissions = config.reject { |name| directories.include?(name) } unless unknown_permissions.empty? log_warning("Unknown permissions: #{unknown_permissions.join(', ')}") end + source_files = [ + '"ios/*.{h,mm}"', + *directories.map { |name| "\"ios/#{name}/*.{h,mm}\"" } + ].join(', ') + + frameworks = directories + .reduce([]) do |acc, dir| + arr = permissions_frameworks[dir] + arr ? acc.concat(arr) : acc + end + .map { |name| "\"#{name}\"" } + .uniq + .join(', ') + podspec_path = File.join(module_dir, 'RNPermissions.podspec') podspec = File.read(podspec_path) - podspec_content = podspec.gsub(/"ios\/\*\.{h,m,mm}".*/, source_files.join(', ')) + + podspec_content = podspec.gsub( + /"ios\/\*\.{h,mm}".*/, + source_files + "\n s.frameworks = #{frameworks}" + ) File.write(podspec_path, podspec_content) end