Saturday, April 13, 2024

Fix React Native atomic_notify_one is unavailable

Resolving React Native 'atomic_notify_one' Unavailability Issue in Xcode 12.5

React Native is a powerful framework for building cross-platform mobile applications, but like any technology, it's not without its challenges. One such challenge arises when working with Xcode 12.5, where an issue related to atomic_notify_one can disrupt the development process. In this article, we'll explore how to address this problem and keep your React Native projects running smoothly.

Issue Details:

The error stems from a discrepancy in the usage of atomic_notify_one within the DistributedMutex-inl.h file. Specifically, the absence of the folly:: namespace qualifier triggers errors during compilation.

Solution:

To resolve this issue, follow these steps:

  1. Update DistributedMutex-inl.h:
    Navigate to {project-name}/ios/Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h. Locate the instances of atomic_notify_one and prepend folly:: to the function call. For example:
    atomic_notify_one(state); // Change to
    folly::atomic_notify_one(state);
        
  2. Update RCTCxxBridge.mm and RCTTurboModuleManager.mm:
    After making the changes in DistributedMutex-inl.h, errors may surface in RCTCxxBridge.mm and RCTTurboModuleManager.mm files. To address these:
    • RCTCxxBridge.mm (line 770): Modify the parameter type from:
      (NSArray<id<RCTBridgeModule>> *)modules
      to:
      (NSArray<Class> *)modules
    • RCTTurboModuleManager.mm (line 300): Adjust the line from:
      RCTBridgeModuleNameForClass(module))
      to:
      RCTBridgeModuleNameForClass(Class(module)));

Conclusion:

By implementing the above changes, you can successfully overcome the 'atomic_notify_one' unavailability issue encountered in React Native projects running on Xcode 12.5. These adjustments ensure compatibility with the latest Xcode version, enabling you to continue development with confidence and efficiency.

Remember to regularly check for updates and patches from the React Native community, as staying informed about potential issues and their solutions is crucial for maintaining a smooth development workflow.

Stay proactive, stay coding!

Wednesday, April 3, 2024

React Native run ios specific device commands

These are the available devices for iOS 14.0

    npx react-native run-ios --simulator="iPhone 8"
    npx react-native run-ios --simulator="iPhone 8 Plus"
    npx react-native run-ios --simulator="iPhone 11"
    npx react-native run-ios --simulator="iPhone 11 Pro"
    npx react-native run-ios --simulator="iPhone 11 Pro Max"
    npx react-native run-ios --simulator="iPhone SE (2nd generation)"
    npx react-native run-ios --simulator="iPhone 12 mini"
    npx react-native run-ios --simulator="iPhone 12"
    npx react-native run-ios --simulator="iPhone 12 Pro"
    npx react-native run-ios --simulator="iPhone 12 Pro Max"
    npx react-native run-ios --simulator="iPod touch (7th generation)"
    npx react-native run-ios --simulator="iPad Pro (9.7-inch)"
    npx react-native run-ios --simulator="iPad Pro (11-inch) (2nd generation)"
    npx react-native run-ios --simulator="iPad Pro (12.9-inch) (4th generation)"
    npx react-native run-ios --simulator="iPad (8th generation)"
    npx react-native run-ios --simulator="iPad Air (4th generation)"



List all available iOS devices:
    xcrun simctl list devices