-
Notifications
You must be signed in to change notification settings - Fork 930
feat(cli-platform-ios): add macOS auto-linking support #1126
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
feat(cli-platform-ios): add macOS auto-linking support #1126
Conversation
| * @property commands - An array of commands that are present in 3rd party packages | ||
| */ | ||
| export type Config = { | ||
| export interface Config extends IOSNativeModulesConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done purely to ensure the Config doesn’t deviate in a way that the otherwise uncheckable Ruby source.
| * have the name of the package. This property will be | ||
| * removed in a future major version. | ||
| * | ||
| * @todo Log a warning when this is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to follow-up on this in a future iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to identify libraries that follow a pattern of adding a Podspec into ios/ dir and send PRs.
| * only make changes to this interface (or `IOSScriptPhase`) if the data | ||
| * requirements of `native_modules.rb` change. | ||
| */ | ||
| export interface IOSNativeModulesConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ So this should only change if the Ruby source changes and should not be refactored/shared with other typings, even if they are similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that? Wouldn't it be better to just reference
cli/packages/cli-types/src/index.ts
Lines 131 to 153 in f570baf
| export interface Config extends IOSNativeModulesConfig { | |
| root: string; | |
| reactNativePath: string; | |
| project: ProjectConfig; | |
| assets: string[]; | |
| dependencies: {[key: string]: Dependency}; | |
| platforms: { | |
| android: PlatformConfig< | |
| AndroidProjectConfig, | |
| AndroidProjectParams, | |
| AndroidDependencyConfig, | |
| AndroidDependencyParams | |
| >; | |
| ios: PlatformConfig< | |
| IOSProjectConfig, | |
| IOSProjectParams, | |
| IOSDependencyConfig, | |
| IOSDependencyParams | |
| >; | |
| [name: string]: PlatformConfig<any, any, any, any>; | |
| }; | |
| commands: Command[]; | |
| } |
Could you help me understand where and how it is used? Maybe it's not the right place for it then (in shared package), but next to a utility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because TS cannot type-check the Ruby code, so people making changes to this Config interface might accidentally break some input data assumption made by it. Put differently, you should see this interface as if it were the function signature declaration of the Ruby code, if it were written in TS.
Only include pods in targets that target platforms the pod supports.
85040b6 to
9ef86dd
Compare
|
|
||
| # Skip pods that do not support the platform of the current target. | ||
| if platform = current_target_definition.platform | ||
| next unless spec.supported_on_platform?(platform.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual semantic change of the PR, so tiny 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that comment! And also, I am impressed by the CocoaPods API :D
| use_native_modules!(config) | ||
| end | ||
| require "json" | ||
| runInput = JSON.parse(ARGF.read) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Ruby script receives a JSON payload via stdin…
| end | ||
| unless runInput["capture_stdout"] | ||
| puts podfile.to_hash.to_json | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…and spits out a serialised version of the Podfile to stdout.
| - run-lint | ||
| cocoa-pods: | ||
| unit-tests: | ||
| executor: noderuby |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know which version of Node is run on this image? Would be cool if it was the latest or so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn’t spot an explicit listing of the version in the CI output, but it’s using circleci/ruby:2.4-node and in this listing I see ENV NODE_VERSION=12.16.2. So probably that?
|
Seeing as it’s failing on the |
e5382db to
1a411b3
Compare
grabbou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the changes. Good job! Just not sure about typings itself, rather than that, let's ship it!
|
Ace, thanks for the review! I feel confident about the need for the typing, but if needed we can amend the wording in the comment to clarify in a follow-up PR, so I’ll go ahead and merge for now 👍 |
Summary:
These changes make it so
react-native-macosapps can use thenative_modules.rbscript as-is, but only activate pods in those targets that target the platform the pods support.For instance, consider these npm packages that come with native modules:
ios-depmacos-depios-and-macos-dep…and given a
Podfilelike the following:…the result would be that:
A iOS Targethas the following dependencies:ios-depios-and-macos-depA macOS Targethas the following dependencies:macos-depios-and-macos-depNOTE: In a future major version, the
native_modulessupport will likely move to acli-platform-applepackage, but for now this was the least invasive change.Test Plan:
Changes have full test coverage, which have been moved from Ruby to JS, and I’ve performed test runs with new applications.