react-native-orientation-locker icon indicating copy to clipboard operation
react-native-orientation-locker copied to clipboard

Feature request: Update docs for usage into 0.77

Open Pnlvfx opened this issue 11 months ago • 10 comments

Add the following to your project's AppDelegate.m:

AppDelegate has become a swift file into React Native 0.77

Pnlvfx avatar Feb 06 '25 20:02 Pnlvfx

Do you have any update? @Pnlvfx

quoctruongkt avatar Feb 10 '25 03:02 quoctruongkt

Do you have any update? @Pnlvfx

I used react-native-orientation-director

there is 1 issue with the instructions on how to do it.

Pnlvfx avatar Feb 10 '25 09:02 Pnlvfx

I resolved this issue by:

Creating the file YourProjectName-Bridging-Header.h and adding the following line:

#import "Orientation.h"

In AppDelegate.swift, adding:

override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
    return Orientation.getOrientation()
}

quoctruongkt avatar Feb 11 '25 02:02 quoctruongkt

override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return Orientation.getOrientation() }

Image

I have also added the following, but seeing above error

#import 'Orientation.h'

diptimaya-seneca avatar Feb 25 '25 01:02 diptimaya-seneca

Never mind, fixed the issue, added the path to the Bridging-Header.h file to the following

Build Settings > Swift Compiler - General > Objective-C Bridging Header > Double click to open the editor > Dragged the header file into it

XCode will Pre-Pan and then good to go.

Image

diptimaya-seneca avatar Feb 25 '25 02:02 diptimaya-seneca

I'd consider this library retired. It's still can be used for old react native projects based on bridge. If your project uses react native new architecture - consider using https://github.com/whitestranger7/react-native-orientation-turbo

Please note that this lib is working only with new architecture enabled. It's does not require any ios or android configuration. It's using latest android and ios sdk.

You're welcome to use discussions on the page for ideas of how lib can be improved

whitestranger7 avatar Jul 06 '25 19:07 whitestranger7

Never mind, fixed the issue, added the path to the Bridging-Header.h file to the following

Build Settings > Swift Compiler - General > Objective-C Bridging Header > Double click to open the editor > Dragged the header file into it

XCode will Pre-Pan and then good to go.

Image

This can also be fixed by importing below line in AppDelegate.swift file

import react_native_orientation_locker

izaanjahangir avatar Jul 10 '25 18:07 izaanjahangir

adding public at start of method fixed things for me

Image
  public override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
      return Orientation.getOrientation()
  }

I also added #import "Orientation.h" in Bridging header as suggested

noumantahir avatar Jul 25 '25 16:07 noumantahir

Add

#import "Orientation.h"

to your ProjectName-Bridging-Header.h file.

Then, add the following method inside your AppDelegate into AppDelegate: UIResponder, UIApplicationDelegate class:

func application(_ application: UIApplication,
                 supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
    return Orientation.getOrientation()
}

kingkongqn4444 avatar Nov 11 '25 14:11 kingkongqn4444