Extract Flow types and constants (#49614)

Summary:
This change refactors the script to prebuild ios dependencies by:
- factoring out the constants
- factoring out the flow type definitions
- factoring out the .gitignore

bypass-github-export-check

## Changelog:

[INTERNAL] - Factor out flow types, constants and gitignore

Pull Request resolved: https://github.com/facebook/react-native/pull/49614

Test Plan:
Tested in this `AppDelegate.mm`:

Imports:

```obj-c
#import "AppDelegate.h"
#import <glog/logging.h>
#import <double-conversion.h>
#include <fmt/core.h>
#include <boost/assert.hpp>
#include <fast_float/fast_float.h>
#include <string>
#import <SocketRocket/SRWebSocket.h>
```

Code:
```obj-c
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  std::string input = "3.1416 xyz ";
  double_conversion::DoubleToStringConverter::EcmaScriptConverter();
  LOG(INFO) << "Hello from GLOG";
  fmt::print("Hello, world from FMT!\n");
  BOOST_ASSERT(100 == 100);
  double result;
  fast_float::from_chars(input.data(), input.data() + input.size(), result);
  LOG(INFO) << "Answer :" << result;

  NSArray *frameworks = [NSBundle allFrameworks];

  for (NSBundle *framework in frameworks) {
    NSString *frameworkName = framework.bundleURL.lastPathComponent;
    if ([frameworkName isEqualToString: @"ReactNativeDependencies.framework"]) {
      NSBundle *bundle = [NSBundle bundleWithURL:[framework bundleURL]];
      NSURL *bundleURL = [bundle URLForResource:@"ReactNativeDependencies_glog" withExtension:@"bundle"];
      NSBundle *resourceBundle = [NSBundle bundleWithURL:bundleURL];
      NSURL* url = [resourceBundle URLForResource:@"PrivacyInfo" withExtension:@"xcprivacy"];
      if (url == nil) {
        throw [NSException exceptionWithName:@"ResourceNotFoundException"
                                       reason:@"Could not find PrivacyInfo.xcprivacy in ReactNativeDependencies_glog bundle"
                                     userInfo:nil];
      }
      break;
    }
  }
  return YES;
}
```

Reviewed By: cortinico

Differential Revision: D70172536

Pulled By: cipolleschi

fbshipit-source-id: 91589693fd24e2b0d6d67759fb9fbc86841f4d13
This commit is contained in:
Christian Falch
2025-02-26 08:19:39 -08:00
committed by Facebook GitHub Bot
parent 5fcb69e8b7
commit a860c55f38
3 changed files with 81 additions and 3 deletions
+1 -3
View File
@@ -142,9 +142,7 @@ vendor/
/packages/react-native/sdks/hermes-engine/hermes-engine-from-local-source-dir.tar.gz
# iOS prebuilds
/packages/react-native/third-party/glog
/packages/react-native/third-party/.swiftpm
/packages/react-native/third-party/.build
/packages/react-native/third-party/
fix_*.patch
*.xcframework
+18
View File
@@ -0,0 +1,18 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
* @oncall react_native
*/
module.exports = {
SOURCE_FOLDER: 'source', // This is where the original structure will be stored
TARGET_FOLDER: 'target', // This is where the final structure will be stored
HEADERS_FOLDER: 'headers', // This is where the headers will be stored
SCRIPTS_FOLDER: 'scripts', // This is where the scripts will be stored
RESOURCES_FOLDER: 'Resources', // This is where the resources will be stored in side the target folder
};
+62
View File
@@ -0,0 +1,62 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
* @oncall react_native
*/
/*::
export type Folder = RegExp;
export type Files = $ReadOnly<{
headers: $ReadOnlyArray<string>,
sources: $ReadOnlyArray<string>,
resources?: $ReadOnlyArray<string>,
// Relative path from target root to where the header files should be copied.
// Can be used to ensure header search paths like <double-conversion/double-conversion.h>
// are correctly resolved.
headerTargetFolder?: string,
headerSkipFolderNames?: string,
}>;
export type Define = $ReadOnly<{
name: string,
value?: string,
}>;
export type Settings = $ReadOnly<{
headerSearchPaths?: $ReadOnlyArray<string>,
defines?: $ReadOnlyArray<Define>,
compilerFlags?: $ReadOnlyArray<string>,
linkedLibraries?: $ReadOnlyArray<string>,
publicHeaderFiles: string,
linkerSettings?: $ReadOnlyArray<string>
}>;
export type Dependency = $ReadOnly<{
name: string,
version: string,
url: URL,
prepareScript?: string,
files: Files,
settings: Settings,
disabled?: boolean,
dependencies?: $ReadOnlyArray<string>,
}>;
export type Platform =
'iOS' |
'iOS Simulator' |
'macOS' |
'macOS,variant=Mac Catalyst' |
'tvOS' |
'tvOS Simulator' |
'visionOS' |
'visionOS Simulator';
*/
module.exports = {};