Skip to content
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

Extend injection options #1605

Merged
merged 34 commits into from
Jul 1, 2024
Merged

Conversation

aurimasmi
Copy link
Collaborator

@aurimasmi aurimasmi commented Jun 10, 2024

Description

Extends current injections possibilities also cleans some old very specific injections.

New additions: ios, tvos

templateXcode.AppDelegate_h.appDelegateMethods

Array of strings adds injections to AppDelegate.h interface. Arbitrary code can be written.

e.g.

"AppDelegate_h": {
    "appDelegateMethods": ["@property (nonatomic, strong) UIView *appSwitcherView;"]
}

templateXcode.AppDelegate_mm.appDelegateMethods.custom

Array of strings adds injections to AppDelegate.mm. Arbitrary code can be written.

e.g.

"AppDelegate_mm": {
    "appDelegateMethods": {
        "custom": [
            "- (UIImage *)createScreenshotOfCurrentContext {",
            "   CGSize screenSize = self.window.screen.bounds.size;",
            "   UIGraphicsBeginImageContext(screenSize);",
            "   CGContextRef currentContext = UIGraphicsGetCurrentContext();",
            "   if (!currentContext) {",
            "       return nil;",
            "   }",
            "   [self.window.layer renderInContext:currentContext];",
            "   UIImage *image = UIGraphicsGetImageFromCurrentImageContext();",
            "   UIGraphicsEndImageContext();",
            "   return image;",
            "}"
        ]
    }
}

templateXcode.privacyManifests.NSPrivacyAccessedAPITypes

Injections based on apple privacy manifest rules
https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api

e.g.

"privacyManifests": {
    "NSPrivacyAccessedAPITypes": [
        {
            "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategoryActiveKeyboards",
            "NSPrivacyAccessedAPITypeReasons": ["CA92.1"]
        }
    ]
}

New additions: android, androidtv, firetv

templateAndroid.build_gradle.buildscript.dependencies
templateAndroid.build_gradle.buildscript.repositories
templateAndroid.build_gradle.buildscript.ext
templateAndroid.build_gradle.buildscript.custom

Array of strings adds injections to build.gradle file dependencies, repositories, ext section. Also with .custom arbitrary functions can be written in buildscript.

e.g.

"build_gradle": {
    "buildscript": {
        "custom": [],
        "dependencies": ["def customVar2 = '2'"],
        "repositories": ["def customVar1 = '1'"],
        "ext": ["playServicesLocationVersion = \"21.0.1\""]
    }
}

templateAndroid.build_gradle.buildscript.injectAfterAll

Array of strings adds injections outside buildscript. Arbitrary functions can be written.

e.g.

"build_gradle": {
    "injectAfterAll": [
        "allprojects {",
        "   repositories {",
        "   }",
        "}"
    ]
}

How to test?

Follow instructions above by adding injections to renative.json file or plugin definitions and observe results in relevant files.

Related issues

TBA

justinasRm and others added 25 commits April 18, 2024 11:17
* release/1.0: (99 commits)
  bump up deps
  fix  description
  add description
  fix spelling
  fix(RnNext:Assets): Fix copying assets by providing absolute path
  fix/macos_export
  readd device cli option to withRun preset
  fix(Web:TemplateStarter): Fixing web icon
  clean code
  fix tests
  fix tests
  clean code
  change the engine root path definition
  fix ip input
  fix(macOS:TemplateStarter): fix template starter icon
  fix(macOS): Fixing icon for macos by updating renative assets
  fix registering engine tasks multiple times
  fix rnv core task option mocks
  add pair device option
  add packageReactNativeAndroid tests
  ...
* release/1.0:
  1.0.0-rc.18
  add configuresoft dependOn for crypto, fix tar
  add support for using rnv crypto in integrations
@aurimasmi aurimasmi changed the title WIP: extend injector options Extend injection options Jun 14, 2024
@aurimasmi aurimasmi marked this pull request as ready for review June 16, 2024 08:39
@aurimasmi aurimasmi added e2e and removed e2e labels Jun 20, 2024
@pavjacko pavjacko changed the base branch from main to release/1.0 June 25, 2024 07:15
@pavjacko pavjacko added this to the 1.0 milestone Jun 25, 2024
# Conflicts:
#	packages/core/jsonSchema/rnv.plugin.json
#	packages/core/jsonSchema/rnv.templates.json
#	packages/core/src/schema/platforms/fragments/templateAndroid.ts
@pauliusguzas pauliusguzas added e2e and removed e2e labels Jun 25, 2024
Copy link
Collaborator

@GabrieleKaceviciute GabrieleKaceviciute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tvos -> nothing changes if injections are added to renative.json file or not

add

no

@pavjacko pavjacko merged commit 85dbe98 into release/1.0 Jul 1, 2024
1 check passed
@pavjacko pavjacko deleted the feat/extend-overrides-options branch July 1, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants