-
Notifications
You must be signed in to change notification settings - Fork 26
Upgrade expo apple targets #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request introduces modifications to multiple files across a React Native device activity module. The primary changes involve updating import paths for configuration types, renaming variables, and enhancing the Changes
Sequence DiagramsequenceDiagram
participant App
participant DeviceActivityModule
participant AuthorizationService
App->>DeviceActivityModule: requestAuthorization("individual")
DeviceActivityModule->>AuthorizationService: Request Authorization
AuthorizationService-->>DeviceActivityModule: Authorization Result
DeviceActivityModule-->>App: Return Authorization Status
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (22)
ios/ScreenTimeActivityPicker.swift (2)
40-43: Consider adding explicit error handling for the authorization request.
Currently, errors may be silently ignored due totry?. Providing explicit catch or fallback behavior would enhance resilience.
54-59: Maintain consistent authorization flow in earlier iOS versions.
Although you are conditionally requesting authorization on iOS 16.0 and later, consider logging or handling the case when the API is unavailable on lower versions, to provide clarity on why authorization isn’t fully requested.ios/ReactNativeDeviceActivityView.swift (1)
73-73: Remove trailing comma in the literal if adhering to strict style rules.
Although trailing commas in array/dictionary literals are a matter of style, SwiftLint warns about them. If your team enforces this rule, remove the trailing comma:- "webDomainCount": selection.webDomainTokens.count, + "webDomainCount": selection.webDomainTokens.count🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 73-73: Collection literals should not have trailing commas
(trailing_comma)
targets/ShieldAction/ShieldActionExtension.swift (1)
62-63: Adjust brace positioning for SwiftLint compliance.
SwiftLint suggests aligning braces on the same line. If desired by your team’s style conventions, apply the fix:- ] as? [String: Any] -{ + ] as? [String: Any] {🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 63-63: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
ios/ReactNativeDeviceActivityModule.swift (2)
69-70: Inline opening brace to align with the function declaration style.
To comply with the SwiftLint rule, place the brace after the function declaration on the same line:-func convertToSwiftDateComponents(from dateComponentsFromJS: DateComponentsFromJS) -> DateComponents -{ +func convertToSwiftDateComponents(from dateComponentsFromJS: DateComponentsFromJS) -> DateComponents {🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 70-70: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
327-328: Adhere to a single-line brace for the closure declaration.
Adjust to align with SwiftLint’s preference:-let decodedFamilyActivitySelections: [FamilyActivitySelection] = familyActivitySelections.map -{ familyActivitySelection in +let decodedFamilyActivitySelections: [FamilyActivitySelection] = familyActivitySelections.map { + familyActivitySelection in🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 328-328: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
ios/Shared.swift (12)
27-28: Move the opening brace onto the same line for Swift style consistency.
SwiftLint recommends placing the brace ({) on the same line as the declaration, preceded by a space.- if let shieldConfiguration = userDefaults?.dictionary( - forKey: "shieldConfiguration_\(shieldId)") - { + if let shieldConfiguration = userDefaults?.dictionary( + forKey: "shieldConfiguration_\(shieldId)") { userDefaults?.set(shieldConfiguration, forKey: "shieldConfiguration") }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 28-28: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
34-35: Apply the same-line brace style here as well.- if let shieldActions = userDefaults?.dictionary( - forKey: "shieldActions_\(shieldId)") - { + if let shieldActions = userDefaults?.dictionary( + forKey: "shieldActions_\(shieldId)") { userDefaults?.set(shieldActions, forKey: "shieldActions") }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 35-35: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
222-223: Keep braces on the same line for function declarations.-func sendHttpRequest(with url: String, config: [String: Any], placeholders: [String: String?]) - -> URLSessionDataTask -{ +func sendHttpRequest(with url: String, config: [String: Any], placeholders: [String: String?]) -> URLSessionDataTask { // ... }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 223-223: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
266-267: Follow SwiftLint brace rules when entering thedoblock.- if let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) - as? [String: Any] - { + if let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] { print(json) }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 267-267: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
292-293: One-line function signature brace style.-func getTextToReplaceWithOptionalSpecialTreatment(_ stringToReplace: String) - -> TextToReplaceWithOptionalSpecialTreatment -{ +func getTextToReplaceWithOptionalSpecialTreatment(_ stringToReplace: String) -> TextToReplaceWithOptionalSpecialTreatment { // ... }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 293-293: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
295-296: Maintain consistent brace placement in conditional checks.-if stringToReplace.starts(with: "{") && stringToReplace.hasSuffix("}") - && stringToReplace.contains(":") -{ +if stringToReplace.starts(with: "{"), + stringToReplace.hasSuffix("}"), + stringToReplace.contains(":") { // ... }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 296-296: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
330-331: Keep the brace on the same line when unwrapping placeholders.- if let placeholderValue = placeholders[ - textToReplaceWithOptionalSpecialTreatment.textToReplace] as? String - { + if let placeholderValue = placeholders[textToReplaceWithOptionalSpecialTreatment.textToReplace] as? String { // ... }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 331-331: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
339-340: Maintain consistent brace style in userDefaults fetch.- if let value = userDefaults?.string( - forKey: textToReplaceWithOptionalSpecialTreatment.textToReplace) - { + if let value = userDefaults?.string(forKey: textToReplaceWithOptionalSpecialTreatment.textToReplace) { // ... }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 340-340: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
368-369: Same-line brace for dictionary retrieval from userDefaults.- if let familyActivitySelectionIds = userDefaults?.dictionary( - forKey: "familyActivitySelectionIds") - { + if let familyActivitySelectionIds = userDefaults?.dictionary(forKey: "familyActivitySelectionIds") { // ... }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 369-369: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
385-386: Apply the brace style consistently here.- if let familyActivitySelectionIds = userDefaults?.dictionary(forKey: "familyActivitySelectionIds") - { + if let familyActivitySelectionIds = userDefaults?.dictionary(forKey: "familyActivitySelectionIds") { // ... }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 386-386: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
434-435: Include the brace on the same line for the function header.- func deserializeFamilyActivitySelection(familyActivitySelectionStr: String) - -> FamilyActivitySelection - { + func deserializeFamilyActivitySelection(familyActivitySelectionStr: String) -> FamilyActivitySelection { // ... }🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 435-435: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
564-564: Remove trailing comma in collection literal.
SwiftLint warns about trailing commas in array or dictionary literals.- "secondaryButtonAction": secondary.actions.map({ _ in - return ["type": "unblockAll"] - }), + "secondaryButtonAction": secondary.actions.map({ _ in + return ["type": "unblockAll"] + })🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 564-564: Collection literals should not have trailing commas
(trailing_comma)
package.json (1)
36-38: Pinning@kingstinct/expo-apple-targetsto version0might be risky.
Pinning dependencies to zero or a non-semantic version can make it hard to get updates or track stable releases.Would you consider specifying a semantic range for better maintainability?
targets/ActivityMonitorExtension/DeviceActivityMonitorExtension.swift (2)
55-56: Maintain Swift style conventions for brace placementThe opening brace should be on the same line as the function declaration, preceded by a single space, following Swift style conventions.
- func executeActionsForEvent(activityName: String, callbackName: String, eventName: String? = nil) - { + func executeActionsForEvent(activityName: String, callbackName: String, eventName: String? = nil) {🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 56-56: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
63-63: Remove trailing comma from dictionary literalSwift style conventions typically avoid trailing commas for the last item in collection literals.
- "activityName": activityName, "callbackName": callbackName, "eventName": eventName, + "activityName": activityName, "callbackName": callbackName, "eventName": eventName🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 63-63: Collection literals should not have trailing commas
(trailing_comma)
targets/ShieldConfiguration/ShieldConfigurationExtension.swift (1)
25-26: Maintain consistent Swift style conventions across the fileMultiple instances of style deviations from Swift conventions:
- Opening braces should be on the same line as declarations (lines 26, 58, 125, 171)
- Trailing commas should be removed from the last items in collection literals (lines 113, 137, 158, 183)
Example fixes for brace placement:
-func buildLabel(text: String?, with color: UIColor?, placeholders: [String: String?]) - -> ShieldConfiguration.Label? -{ +func buildLabel(text: String?, with color: UIColor?, placeholders: [String: String?]) -> ShieldConfiguration.Label? {Example fixes for trailing commas:
- ), + )If these changes are from an automated formatter, consider updating its configuration to align with Swift style conventions.
Also applies to: 57-58, 124-125, 170-171, 113-113, 137-137, 158-158, 183-183
🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 26-26: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
example/ios/Podfile.lockis excluded by!**/*.lockyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (15)
app.plugin.js(2 hunks)example/targets/ActivityMonitorExtension/expo-target.config.js(1 hunks)example/targets/ShieldAction/expo-target.config.js(1 hunks)example/targets/ShieldConfiguration/expo-target.config.js(1 hunks)ios/ReactNativeDeviceActivityModule.swift(4 hunks)ios/ReactNativeDeviceActivityView.swift(2 hunks)ios/ScreenTimeActivityPicker.swift(2 hunks)ios/Shared.swift(10 hunks)package.json(3 hunks)targets/ActivityMonitorExtension/DeviceActivityMonitorExtension.swift(1 hunks)targets/ActivityMonitorExtension/expo-target.config.js(1 hunks)targets/ShieldAction/ShieldActionExtension.swift(1 hunks)targets/ShieldAction/expo-target.config.js(1 hunks)targets/ShieldConfiguration/ShieldConfigurationExtension.swift(8 hunks)targets/ShieldConfiguration/expo-target.config.js(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- example/targets/ShieldAction/expo-target.config.js
🧰 Additional context used
🪛 SwiftLint (0.57.0)
ios/ReactNativeDeviceActivityView.swift
[Warning] 41-41: Collection literals should not have trailing commas
(trailing_comma)
[Warning] 73-73: Collection literals should not have trailing commas
(trailing_comma)
targets/ShieldAction/ShieldActionExtension.swift
[Warning] 63-63: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
ios/ReactNativeDeviceActivityModule.swift
[Warning] 70-70: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 328-328: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
ios/Shared.swift
[Warning] 28-28: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 35-35: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 223-223: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 267-267: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 293-293: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 296-296: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 331-331: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 340-340: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 369-369: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 386-386: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 435-435: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 564-564: Collection literals should not have trailing commas
(trailing_comma)
targets/ActivityMonitorExtension/DeviceActivityMonitorExtension.swift
[Warning] 56-56: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 63-63: Collection literals should not have trailing commas
(trailing_comma)
targets/ShieldConfiguration/ShieldConfigurationExtension.swift
[Warning] 26-26: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 58-58: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 113-113: Collection literals should not have trailing commas
(trailing_comma)
[Warning] 125-125: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 137-137: Collection literals should not have trailing commas
(trailing_comma)
[Warning] 158-158: Collection literals should not have trailing commas
(trailing_comma)
[Warning] 171-171: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 183-183: Collection literals should not have trailing commas
(trailing_comma)
🔇 Additional comments (15)
targets/ShieldConfiguration/expo-target.config.js (1)
1-1: **The new import reference looks solid. **The switch from
expo-apple-targets/target-plugin/configto@kingstinct/expo-apple-targets/build/config-plugineffectively aligns with the updated library structure. No further changes required here.example/targets/ShieldConfiguration/expo-target.config.js (1)
1-1: **Consistent library reference update. **This import path change is consistent with the rest of the project’s move to
@kingstinct/expo-apple-targets/build/config-plugin. If everything compiles and no calls to the old path remain, you should be all set.example/targets/ActivityMonitorExtension/expo-target.config.js (1)
1-1: **Corrected import for Activity Monitor config. **Similarly, updating the
Configimport path from the old package to@kingstinct/expo-apple-targets/build/config-pluginkeeps the code uniform. Looks good.app.plugin.js (2)
17-17: **Usage ofwithTargetsDirin the return statement. **Calling
withTargetsDir(...)in line 17 is consistent with the updated import naming. This preserves the original plugin flow, just referencing the library’s new symbol.
1-2: **Confirm the imported symbols and types. **You’re importing
Configfrom@kingstinct/expo-apple-targets/build/config-pluginand storing it inwithTargetsDir. Make surewithTargetsDiris the intended symbol from that library and that it provides the correct functionality for your plugin.Suggested verification script:
ios/ReactNativeDeviceActivityView.swift (4)
29-31: Auto Layout initialization is correct.
Disabling AutoResizingMask and setting a clear background is a good practice when using constraints in SwiftUI hosting controllers.
33-35: View hierarchy addition looks fine.
Adding the hosting controller’s.viewdirectly to this container is an appropriate approach.
36-42: Constraint setup is correct.
Your usage ofNSLayoutConstraint.activateensures thecontentViewfills its superview.🧰 Tools
🪛 SwiftLint (0.57.0)
[Warning] 41-41: Collection literals should not have trailing commas
(trailing_comma)
44-48: Child view controller addition is correct.
Including the hosting controller as part of the root view controller’s hierarchy is essential for correct appearance callbacks.ios/ReactNativeDeviceActivityModule.swift (2)
464-469: Authorization request logic is well-structured.
Switching behavior based on theforIndividualOrChildparameter is beneficial for customizing requests. Adding logging for failures or user feedback could enrich user experience.
521-522: Block selection logic is correct.
Consistent usage ofblockSelectedAppsor a fallback to block all apps is a clear approach.targets/ShieldAction/expo-target.config.js (1)
1-1: Changes to import path look good.
No issues here; updating the import path to@kingstinct/expo-apple-targets/build/config-pluginis consistent with the rest of the PR.targets/ActivityMonitorExtension/expo-target.config.js (1)
1-1: Import path updated properly.
All references appear consistent and correct.package.json (2)
3-3: Package version increment acknowledged.
No problems are apparent with this version bump, but ensure proper semantic versioning.
49-49: Fixed dev dependency version recognized.
Check if pinningpkg-pr-newto0is intentional; zero-based versions often indicate alpha or incomplete states.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/index.ts (1)
30-36: Consider documenting the new parameter for clarity.The addition of the
forIndividualOrChildparameter is logical, but it would be helpful to briefly document its purpose (e.g., what "child" implies) for future maintainers.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
example/ios/Podfile.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
ios/ReactNativeDeviceActivityModule.swift(2 hunks)ios/ReactNativeDeviceActivityView.swift(1 hunks)ios/Shared.swift(1 hunks)src/ReactNativeDeviceActivity.types.ts(1 hunks)src/index.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- ios/ReactNativeDeviceActivityView.swift
- ios/ReactNativeDeviceActivityModule.swift
🔇 Additional comments (2)
src/ReactNativeDeviceActivity.types.ts (1)
238-240: Looks good and consistent with the calling side.The method signature aligns well with the updated code in
src/index.ts, ensuring type safety and clarity for consumers of the module.ios/Shared.swift (1)
438-438: Implementation is clear for encoding FamilyActivitySelection.This function properly handles empty selections and returns
nil. The base64 encoding with JSON ensures that more complex selections remain intact. The logic is straightforward and aligns with the rest of the module.
…litch in some cases" This reverts commit 9bc7670. # Conflicts: # ios/ReactNativeDeviceActivityView.swift
Summary by CodeRabbit
New Features
requestAuthorizationto specify authorization context for individual or childDependencies
Refactor