Skip to content

[prebuild][iOS] building up to React Core #50766

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

chrfalch
Copy link
Collaborator

@chrfalch chrfalch commented Apr 16, 2025

Summary:

  • Added multiple targets to Package.swift
  • WIP: Builds up untill we need to touch files in React/Base

Changelog:

[INTERNAL] - WIP: prebuilding using Swift packages

Test Plan

Build Package.swift in Xcode for now

- Added multiple targets to Package.swift
- WIP: Builds up untill we need to touch files in React/Base
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 16, 2025
- Added scripts for creating hardlinks to resolve headers
- Added multiple packages and dependencies
- Added hermes download
- Added codegen
- Tried resolving some more packages
@chrfalch chrfalch changed the title [prebuild][iOS] building up to "React/Base" [prebuild][iOS] building up to React Core Apr 28, 2025
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

I still have to go through the Package.swift file, but I'm leaving a few comments on the JS part.

- First it runs codegen
- Then it downloads hermes (if needed)
- Then it creates hard links
…folders

- Now uses fs.linkSync to link each file. This makes the output a bit cleaner as well.
- Removed parameter specifying library in codegen.
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Amazing work, thank you so much!

I left a few minor comments on things that might need to be adjusted or that are not needed. And then we can look at how we can simplify the Package.swift. But I'm super happy that we got here!

link('React/CxxUtils', 'CxxUtils', 'React');
link('React/DevSupport', 'DevSupport', 'React');
link('React/Inspector', 'Inspector', 'React');
link('React/I18n', 'I18n', 'React');
Copy link
Contributor

Choose a reason for hiding this comment

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

this scares me a little bit. We should verify that i18n keeps working after we build.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we need to solve including the strings as well - I haven't looked at it yet.

This target does not need to be built, it is for the app only.
Added abstractions and removed complex include file generation
- Combined hermesprebuilt + hermesIncludes
- Removed duplicate include paths to the compiler
- Removed version number for hermes in package.swift
- Made deps named and not by reference (due to order of initialization)
- Fixed issue in utils.js.
@chrfalch chrfalch force-pushed the @chrfalch/react-core-package-swift-update branch 2 times, most recently from 5b91784 to c73ebc5 Compare May 1, 2025 13:34
class RNTarget: BaseTarget {
let linkedFrameworks: [String]
let excludedPaths: [String]
let dependencies: [String]
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't be easier if this is already a [BaseTarget] instead of a [String]?
We already have the targets so we can pass them right into the other targets.

In this way, we can avoid the

    let dependencies = self.dependencies.compactMap { depName in
      targets.first(where: { $0.name == depName })
    }

below

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried it, but there’s a sneaky issue with non-initialized variables that was hard to debug where you can use a non-initialized target before it is declared. Then its name and props aren’t initialized and the dependencies weren’t resolved properly. It could be fixed with changing the order so that we never used an uninitialized target, but the moment someone added a new target and forgot this they’d have to try to find this bug all over again. So I thought it would be safest to use the name we already had to avoid this.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, in this case the order we use to define the variables is important, as it is important with any kind of program. We can keep it like it is for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Absolutely :) :) I think I'd just had enough with things I had to look out for at this moment and found going for strings would be safer - and hopefully save us some work in the future.

@chrfalch chrfalch marked this pull request as ready for review May 7, 2025 16:06
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label May 7, 2025
@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

cipolleschi pushed a commit to cipolleschi/react-native that referenced this pull request May 8, 2025
Summary:
This change adds a script to sdownload the hermes artifact and to prepare it for building react Native using SwiftPM

bypass-github-export-checks

## Changelog:

[INTERNAL] - Add script to download the hermes artifact

Pull Request resolved: facebook#50766

Test Plan: This will be tested in a diff in the stack.

Differential Revision: D74386522
cipolleschi pushed a commit to cipolleschi/react-native that referenced this pull request May 8, 2025
Summary:
- Added multiple targets to Package.swift
- WIP: Builds up untill we need to touch files in React/Base

## Changelog:

[INTERNAL] - WIP: prebuilding using Swift packages

Pull Request resolved: facebook#50766

Test Plan: This will be tested in a diff in the stack.

Differential Revision: D74386522
cipolleschi pushed a commit to cipolleschi/react-native that referenced this pull request May 8, 2025
Summary:
- Added multiple targets to Package.swift
- WIP: Builds up untill we need to touch files in React/Base

## Changelog:

[INTERNAL] - WIP: prebuilding using Swift packages

Pull Request resolved: facebook#50766

Test Plan: This will be tested in a diff in the stack.

Differential Revision: D74386522

Pulled By: cipolleschi
cipolleschi pushed a commit to cipolleschi/react-native that referenced this pull request May 8, 2025
Summary:
- Added multiple targets to Package.swift
- WIP: Builds up untill we need to touch files in React/Base

## Changelog:

[INTERNAL] - WIP: prebuilding using Swift packages

Pull Request resolved: facebook#50766

Test Plan: This will be tested in a diff in the stack.

Differential Revision: D74386522

Pulled By: cipolleschi
cipolleschi pushed a commit to cipolleschi/react-native that referenced this pull request May 8, 2025
Summary:
- Added multiple targets to Package.swift
- WIP: Builds up untill we need to touch files in React/Base

## Changelog:

[INTERNAL] - WIP: prebuilding using Swift packages

Pull Request resolved: facebook#50766

Test Plan: This will be tested in a diff in the stack.

Differential Revision: D74386522

Pulled By: cipolleschi
cipolleschi pushed a commit to cipolleschi/react-native that referenced this pull request May 8, 2025
Summary:
- Added multiple targets to Package.swift
- WIP: Builds up untill we need to touch files in React/Base

## Changelog:

[INTERNAL] - WIP: prebuilding using Swift packages

Pull Request resolved: facebook#50766

Test Plan: This will be tested in a diff in the stack.

Differential Revision: D74386522

Pulled By: cipolleschi
cipolleschi pushed a commit to cipolleschi/react-native that referenced this pull request May 8, 2025
Summary:
- Added multiple targets to Package.swift
- WIP: Builds up untill we need to touch files in React/Base

## Changelog:

[INTERNAL] - WIP: prebuilding using Swift packages

Pull Request resolved: facebook#50766

Test Plan: This will be tested in a diff in the stack.

Differential Revision: D74386522

Reviewed By: cortinico

Pulled By: cipolleschi
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 8, 2025
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in 43bfb5d.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @chrfalch in 43bfb5d

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants