Skip to content
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

[Gutenberg] Upgrade React Native 0.71.11 #20956

Merged
merged 57 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b7fd735
Add a local `podspec` to download Gutenberg XCFramework commit builds
mokagio May 17, 2023
27e6b3f
Add check to fail `pod install` if Gutenberg ZIP doesn't exist at URL
mokagio May 17, 2023
22334c5
Use latest CocoaPods version
mokagio May 17, 2023
aca165e
Switch to tar.gz for the Gutenberg XCFramework archive
mokagio May 17, 2023
211b497
Use same license as the main project for the Gutenberg pod
mokagio May 18, 2023
0aa0487
Work around CP not finding XCFrameworks by downloading manually
mokagio May 22, 2023
dffeb71
Add a couple of newly required `import React`
mokagio May 22, 2023
1acc425
Address new warnings introduced by the Gutenberg via XCFramework
mokagio May 22, 2023
8176593
Update `CopyGutenbergJS` build phase script to account for XCFramework
mokagio May 23, 2023
7d31186
Use relative paths when importing the local Gutenberg podspec
mokagio May 25, 2023
27186a2
Remove `pre_install` download hook in favor of `prepare_command`
mokagio Jun 2, 2023
a4c6070
Use remote spec instead of a local one for Gutenberg via commit
mokagio Jun 5, 2023
11b0d2c
Update Gutenberg `tar.gz` URL after changes in gutenberg-mobile
mokagio Jun 7, 2023
64ac588
Use Xcode 14.3.1
mokagio Jun 8, 2023
ede6c5d
Update Gutenberg CP setup to use XCFrameworks when referenced via tag
mokagio Jun 13, 2023
0806f9b
Switch to Gutenberg v1.98.1 installed as an XCFramework
mokagio Jun 21, 2023
dfae970
Do not `@testable import` Gutenberg in unit tests
mokagio Jun 21, 2023
4726973
DRY logic setting Gutenberg URL when using tag or commit
mokagio Jun 28, 2023
c2c46cc
Simplify `gutenberg_dependencies` with early return
mokagio Jun 28, 2023
59d7b78
Update Gutenberg local setup to work with React Native 0.71.11
mokagio Jul 3, 2023
d03be58
Add calls to RN hooks when using Gutenberg from local path
mokagio Jul 3, 2023
3fcd1b5
Update build script to run locally without a Gutenberg `App.js`
mokagio Jul 4, 2023
b6b8d9c
Shrink inline comment of `gutenberg_post_install` helper
fluiddot Jul 6, 2023
d6dd34e
Update `Podfile.lock` file
fluiddot Jul 6, 2023
d81f466
Add build phase to prevent nested frameworks
mokagio Jul 18, 2023
f875968
Remove outdated Xcode 12.5 mention from nested frameworks linter
mokagio Jul 19, 2023
9192af0
Merge branch 'trunk' into mokagio/gutenberg-xcframework-setup
fluiddot Jul 19, 2023
381d49a
Update RNReanimated pod source to `wp-fork-2.17.0`
fluiddot Jul 5, 2023
ebd4cca
Add `gutenberg_local_pod` helper
fluiddot Jul 6, 2023
2b1138f
Tweak pod dependencies based on the React Native version
fluiddot Jul 6, 2023
65e5454
Merge and fix pre-install logic into `gutenberg_dependencies` block
fluiddot Jul 7, 2023
2d40a68
Fix typo in post install hook
fluiddot Jul 7, 2023
598b038
Move RNReanimated dependency workaround to a separate function
fluiddot Jul 10, 2023
341f617
Fetch React Native version using JSON lib
fluiddot Jul 19, 2023
551968e
Update Gutenberg Mobile ref to use workaround for Hermes framework
fluiddot Jul 19, 2023
723f8ed
Reintroduce link to internal doc with "Do Not Embed" explanation
mokagio Jul 19, 2023
9ceb947
Use CI toolkit version 2.18.1 for better failure annotations
mokagio Jul 19, 2023
e39537b
Add build phase to detect nested frameworks (#21130)
mokagio Jul 20, 2023
4530832
Add workaround for editor UI tests failing with keyboard not available
mokagio Jul 19, 2023
170d7f4
Merge pull request #21143 from wordpress-mobile/test/latest-wip-xcfra…
fluiddot Jul 20, 2023
a4fe6e8
Update Gutenberg Mobile ref
fluiddot Jul 20, 2023
d7cf5c3
Update release notes
fluiddot Jul 20, 2023
4945d03
Merge branch 'trunk' into gutenberg/upgrade/react-native-0.71.11
fluiddot Jul 20, 2023
795a9c2
Merge remote-tracking branch 'origin/trunk' into gutenberg/upgrade/re…
mokagio Jul 21, 2023
64811c6
Merge branch 'mokagio/gutenberg-xcframework-setup' into gutenberg/upg…
fluiddot Jul 21, 2023
c992bcb
Remove adding `React-jsc` Pod
fluiddot Jul 21, 2023
7e11b1e
Remove inline comment about error explanation
fluiddot Jul 21, 2023
6ce7fdc
Update Gutenberg Mobile ref
fluiddot Jul 21, 2023
59b6bb3
Fix typo in `CopyGutenbergJS.sh` script
fluiddot Jul 21, 2023
8c8f945
Merge branch 'trunk' into gutenberg/upgrade/react-native-0.71.11
fluiddot Jul 21, 2023
e39dfaf
Merge branch 'trunk' of github.com:wordpress-mobile/WordPress-iOS int…
dcalhoun Jul 27, 2023
12164fc
build: Update Gutenberg version
dcalhoun Jul 27, 2023
4642cfb
Re-introduce Gutenberg pod to remove duplicated sources in `Podfile.l…
fluiddot Jul 27, 2023
131057d
Re-introduce `SDWebImage` pod
fluiddot Jul 27, 2023
812b034
Merge branch 'trunk' into gutenberg/upgrade/react-native-0.71.11
fluiddot Jul 27, 2023
40541ae
Update release notes
fluiddot Jul 27, 2023
66ad340
Update Gutenberg Mobile ref with tag
fluiddot Jul 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/cache-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#2.18.1
- automattic/git-s3-cache#1.1.4:
bucket: "a8c-repo-mirrors"
repo: "automattic/wordpress-ios/"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#2.18.1
- automattic/git-s3-cache#1.1.4:
bucket: "a8c-repo-mirrors"
repo: "automattic/wordpress-ios/"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/release-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.17.0
- automattic/a8c-ci-toolkit#2.18.1
- automattic/git-s3-cache#1.1.4:
bucket: "a8c-repo-mirrors"
repo: "automattic/wordpress-ios/"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source 'https://rubygems.org'

# 1.12.x and higher, starting from 1.12.1
# 1.12.x and higher, starting from 1.12.1, because that hotfix fixes Xcode 14.3 compatibility
gem 'cocoapods', '~> 1.12', '>= 1.12.1'
gem 'commonmarker'
gem 'danger', '~> 9.3'
Expand Down
4 changes: 1 addition & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ GEM
specs:
CFPropertyList (3.0.6)
rexml
activesupport (6.1.7.3)
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
Expand Down Expand Up @@ -366,7 +365,6 @@ GEM
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
zeitwerk (2.6.8)

PLATFORMS
ruby
Expand Down
161 changes: 113 additions & 48 deletions Gutenberg/cocoapods_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,19 @@

# Helpers and configurations for integrating Gutenberg in Jetpack and WordPress via CocoaPods.

require 'json'
require_relative './version'

DEFAULT_GUTENBERG_LOCATION = File.join(__dir__, '..', '..', 'gutenberg-mobile')

LOCAL_GUTENBERG_KEY = 'LOCAL_GUTENBERG'

# Note that the pods in this array might seem unused if you look for
# `import` statements in this codebase. However, make sure to also check
# whether they are used in the gutenberg-mobile and Gutenberg projects.
#
# See https://github.com/wordpress-mobile/gutenberg-mobile/issues/5025
DEPENDENCIES = %w[
FBLazyVector
React
ReactCommon
RCTRequired
RCTTypeSafety
React-Core
React-CoreModules
React-RCTActionSheet
React-RCTAnimation
React-RCTBlob
React-RCTImage
React-RCTLinking
React-RCTNetwork
React-RCTSettings
React-RCTText
React-RCTVibration
React-callinvoker
React-cxxreact
React-jsinspector
React-jsi
React-jsiexecutor
React-logger
React-perflogger
React-runtimeexecutor
boost
Yoga
RCT-Folly
glog
react-native-safe-area
react-native-safe-area-context
react-native-video
Expand All @@ -55,23 +30,32 @@
RNCMaskedView
RNCClipboard
RNFastImage
React-Codegen
React-bridging
].freeze

def gutenberg_pod(config: GUTENBERG_CONFIG)
# We check local_gutenberg first because it should take precedence, being an override set by the user.
return gutenberg_local_pod if should_use_local_gutenberg

options = config

local_gutenberg_key = 'LOCAL_GUTENBERG'
local_gutenberg = ENV.fetch(local_gutenberg_key, nil)
if local_gutenberg
options = { path: File.exist?(local_gutenberg) ? local_gutenberg : DEFAULT_GUTENBERG_LOCATION }
id = options[:tag] || options[:commit]

raise "Could not find Gutenberg pod at #{options[:path]}. You can configure the path using the #{local_gutenberg_key} environment variable." unless File.exist?(options[:path])
else
options[:git] = "https://github.com/#{GITHUB_ORG}/#{REPO_NAME}.git"
options[:submodules] = true
end
# Notice there's no period at the end of the message as CocoaPods will add it.
raise 'Neither tag nor commit to use for Gutenberg found' unless id

pod 'Gutenberg', podspec: "https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-#{id}.podspec"
end

def gutenberg_local_pod
options = { path: local_gutenberg_path }

raise "Could not find Gutenberg pod at #{options[:path]}. You can configure the path using the #{LOCAL_GUTENBERG_KEY} environment variable." unless File.exist?(options[:path])

puts "[Gutenberg] Installing pods using local Gutenberg version from #{local_gutenberg_path}"

react_native_path = require_react_native_helpers!(gutenberg_path: local_gutenberg_path)

use_react_native! path: react_native_path

pod 'Gutenberg', options
pod 'RNTAztecView', options
Expand All @@ -80,20 +64,101 @@ def gutenberg_pod(config: GUTENBERG_CONFIG)
end

def gutenberg_dependencies(options:)
if options[:path]
podspec_prefix = options[:path]
else
tag_or_commit = options[:tag] || options[:commit]
podspec_prefix = "https://github.com/#{GITHUB_ORG}/#{REPO_NAME}/#{tag_or_commit}"
end
# When referencing via a tag or commit, we download pre-built frameworks.
return if options.key?(:tag) || options.key?(:commit)
Comment on lines +67 to +68
Copy link
Contributor

Choose a reason for hiding this comment

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

These conditions will never be met as gutenberg_dependencies is only called when using Gutenberg locally, i.e. it will always reference the pod using a path.

Copy link
Contributor

@fluiddot fluiddot Jul 21, 2023

Choose a reason for hiding this comment

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

Maybe it makes sense to keep it in case gutenberg_dependencies is used somewhere else in the future 🤔.


podspec_prefix = options[:path]
gutenberg_path = options[:path]

raise "Unexpected Gutenberg dependencies configuration '#{options}'" if podspec_prefix.nil?

podspec_prefix += '/third-party-podspecs'
podspec_extension = 'podspec.json'

# FBReactNativeSpec needs special treatment because of react-native-codegen code generation
pod 'FBReactNativeSpec', podspec: "#{podspec_prefix}/FBReactNativeSpec/FBReactNativeSpec.#{podspec_extension}"
computed_dependencies = DEPENDENCIES.dup

react_native_version = react_native_version!(gutenberg_path: gutenberg_path)
# We need to apply a workaround for the RNReanimated library when using React Native 0.71+.
apply_rnreanimated_workaround!(dependencies: computed_dependencies, gutenberg_path: gutenberg_path) unless react_native_version[1] < 71

DEPENDENCIES.each do |pod_name|
computed_dependencies.each do |pod_name|
pod pod_name, podspec: "#{podspec_prefix}/#{pod_name}.#{podspec_extension}"
end
end

def apply_rnreanimated_workaround!(dependencies:, gutenberg_path:)
# Use a custom RNReanimated version while we coordinate a fix upstream
dependencies.delete('RNReanimated')

# This is required to workaround an issue with RNReanimated after upgrading to version 2.17.0
rn_node_modules = File.join(gutenberg_path, '..', 'gutenberg', 'node_modules')
raise "Could not find node modules at given path #{rn_node_modules}" unless File.exist? rn_node_modules

ENV['REACT_NATIVE_NODE_MODULES_DIR'] = rn_node_modules
puts "[Gutenberg] Set REACT_NATIVE_NODE_MODULES_DIR env var for RNReanimated to #{rn_node_modules}"

pod 'RNReanimated', git: 'https://github.com/wordpress-mobile/react-native-reanimated', branch: 'wp-fork-2.17.0'
end

def gutenberg_post_install(installer:)
return unless should_use_local_gutenberg

raise "[Gutenberg] Could not find local Gutenberg at given path #{local_gutenberg_path}" unless File.exist?(local_gutenberg_path)

react_native_path = require_react_native_helpers!(gutenberg_path: local_gutenberg_path)

puts "[Gutenberg] Running Gutenberg post install hook (RN path: #{react_native_path})"

# It seems like React Native prepends $PWD to the path internally in the post install hook.
# To workaround, we make sure the path is relative to Dir.pwd
react_native_path = Pathname.new(react_native_path).relative_path_from(Dir.pwd)

react_native_post_install(installer, react_native_path)
end

private

def should_use_local_gutenberg
value = ENV.fetch(LOCAL_GUTENBERG_KEY, nil)

return false if value.nil?

value
end

def local_gutenberg_path
local_gutenberg = ENV.fetch(LOCAL_GUTENBERG_KEY, nil)

return nil if local_gutenberg.nil?

return local_gutenberg if File.exist?(local_gutenberg)

DEFAULT_GUTENBERG_LOCATION
end

def require_react_native_helpers!(gutenberg_path:)
react_native_path = react_native_path!(gutenberg_path: gutenberg_path)

require_relative File.join(react_native_path, 'scripts', 'react_native_pods')

react_native_path
end

def react_native_path!(gutenberg_path:)
react_native_path = File.join(gutenberg_path, 'gutenberg', 'node_modules', 'react-native')

raise "[Gutenberg] Could not find React Native at given path #{react_native_path}" unless File.exist?(react_native_path)

react_native_path
end

def react_native_version!(gutenberg_path:)
react_native_path = react_native_path!(gutenberg_path: gutenberg_path)
package_json_path = File.join(react_native_path, 'package.json')
package_json_content = File.read(package_json_path)
package_json_version = JSON.parse(package_json_content)['version']

raise "[Gutenberg] Could not find React native version at #{react_native_path}" unless package_json_version

package_json_version.split('.').map(&:to_i)
end
4 changes: 2 additions & 2 deletions Gutenberg/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#
# LOCAL_GUTENBERG=../my-gutenberg-fork bundle exec pod install
GUTENBERG_CONFIG = {
# commit: ''
tag: 'v1.100.1'
commit: 'be8917c55fb6bdc33dcd8e283b9f7e59f4fc1bad'
# tag: 'v1.100.1'
}

GITHUB_ORG = 'wordpress-mobile'
Expand Down
2 changes: 2 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ pre_install do |installer|
end

post_install do |installer|
gutenberg_post_install(installer: installer)

project_root = File.dirname(__FILE__)

## Convert the 3rd-party license acknowledgements markdown into html for use in the app
Expand Down
Loading