Skip to content

Commit

Permalink
Upgrade samples to 0.75 (#965)
Browse files Browse the repository at this point in the history
## Description
Upgrades the Calculator and NativeModule samples to 0.75

### Why
Part of 0.75 release:
microsoft/react-native-windows#13358
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/react-native-windows-samples/pull/965)

---------

Co-authored-by: TatianaKapos <[email protected]>
  • Loading branch information
Yajur-Grover and TatianaKapos authored Sep 23, 2024
1 parent 0ae8afe commit 1608dff
Show file tree
Hide file tree
Showing 52 changed files with 5,693 additions and 300,444 deletions.
148,049 changes: 0 additions & 148,049 deletions samples/Calculator/cppwinrt/.yarn/releases/yarn-1.22.22.cjs

This file was deleted.

925 changes: 925 additions & 0 deletions samples/Calculator/cppwinrt/.yarn/releases/yarn-stable-temp.cjs

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions samples/Calculator/cppwinrt/.yarnrc

This file was deleted.

7 changes: 3 additions & 4 deletions samples/Calculator/cppwinrt/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
# bound in the template on Cocoapods with next React Native release.
gem 'cocoapods', '>= 1.13', '< 1.15'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
26 changes: 16 additions & 10 deletions samples/Calculator/cppwinrt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ See [../README.md](../README.md) for details of this sample.

See [../csharp/](../csharp/) for a C# version of this sample.

It currently targets React Native Windows 0.74.
It currently targets React Native Windows 0.75.

### Setup
See [../README.md#Setup](../README.md#Setup).
Expand All @@ -23,30 +23,36 @@ To upgrade this sample to the latest version of RNW:
```cmd
rd /s /q cppwinrt
```
3. Create a new React Native app and change version to version you want to upgrade to:
3. Create a new React Native app and change version to version you want to upgrade to (replace 'version' with desired version - for latest version, use 'latest'):
```cmd
npx @react-native-community/cli@latest init Calculator --template @react-native-community/template@latest
npx @react-native-community/cli@latest init Calculator --version {version}
```
4. Add a lockfile to the calculator directory:
```
4. Add Windows support:
```cmd
cd Calculator
yarn install
```
5. Add Windows support:
```cmd
yarn add react-native-windows@latest
npx @react-native-community/cli@latest init-windows --template old/uwp-cpp-app --overwrite
```
5. Rename the folder to cppwinrt
6. Rename the folder to cppwinrt
```
cd ..
ren Calculator cppwinrt
```
6. Restore these original app files:
7. Restore these original app files:
```
cd cppwinrt
git restore README.md
git restore App.tsx
```
7. Verify the new app builds and runs:
8. Verify the new app builds and runs:
```
npx @react-native-community/cli@latest run-windows
```
8. Look at windows/Calculators/Package.appxmanifast and change the publisher name to "CN=React Native Windows Sample".
9. Update this readme with the new major version at the top.
9. Look at windows/Calculators/Package.appxmanifast and change the publisher name to "CN=React Native Windows Sample".
10. Update this readme with the new major version at the top.
21 changes: 11 additions & 10 deletions samples/Calculator/cppwinrt/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ apply plugin: "com.facebook.react"
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
// reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
// codegenDir = file("../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
// cliFile = file("../../node_modules/react-native/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand Down Expand Up @@ -49,6 +49,9 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]

/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand Down Expand Up @@ -114,5 +117,3 @@ dependencies {
implementation jscFlavor
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
2 changes: 1 addition & 1 deletion samples/Calculator/cppwinrt/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
kotlinVersion = "1.9.24"
}
repositories {
google()
Expand Down
2 changes: 0 additions & 2 deletions samples/Calculator/cppwinrt/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion samples/Calculator/cppwinrt/android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
4 changes: 3 additions & 1 deletion samples/Calculator/cppwinrt/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'Calculator'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Calculator/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Calculator/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Calculator/main.m; sourceTree = "<group>"; };
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = Calculator/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = Calculator/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
19F6CBCC0A4E27FBF8BF4A61 /* libPods-Calculator-CalculatorTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Calculator-CalculatorTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
3B4392A12AC88292D35C810B /* Pods-Calculator.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Calculator.debug.xcconfig"; path = "Target Support Files/Pods-Calculator/Pods-Calculator.debug.xcconfig"; sourceTree = "<group>"; };
5709B34CF0A7D63546082F79 /* Pods-Calculator.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Calculator.release.xcconfig"; path = "Target Support Files/Pods-Calculator/Pods-Calculator.release.xcconfig"; sourceTree = "<group>"; };
Expand Down
63 changes: 31 additions & 32 deletions samples/Calculator/cppwinrt/ios/Calculator/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,36 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyCollectedDataTypes</key>
<array>
</array>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
</dict>
</plist>
6 changes: 4 additions & 2 deletions samples/Calculator/cppwinrt/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const rnwPath = fs.realpathSync(
path.resolve(require.resolve('react-native-windows/package.json'), '..'),
);

//

/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
Expand All @@ -16,6 +18,7 @@ const rnwPath = fs.realpathSync(
*/

const config = {
//
resolver: {
blockList: exclusionList([
// This stops "react-native run-windows" from causing the metro server to crash if its already running
Expand All @@ -27,6 +30,7 @@ const config = {
new RegExp(`${rnwPath}/target/.*`),
/.*\.ProjectImports\.zip/,
]),
//
},
transformer: {
getTransformOptions: async () => ({
Expand All @@ -35,8 +39,6 @@ const config = {
inlineRequires: true,
},
}),
// This fixes the 'missing-asset-registry-path` error (see https://github.com/microsoft/react-native-windows/issues/11437)
assetRegistryPath: 'react-native/Libraries/Image/AssetRegistry',
},
};

Expand Down
20 changes: 10 additions & 10 deletions samples/Calculator/cppwinrt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
"windows": "react-native run-windows"
},
"dependencies": {
"react": "18.2.0",
"react-native": "0.74.0",
"react-native-windows": "0.74.0"
"react": "18.3.1",
"react-native": "0.75.2",
"react-native-windows": "0.75.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "0.74.81",
"@react-native/eslint-config": "0.74.81",
"@react-native/metro-config": "0.74.81",
"@react-native/typescript-config": "0.74.81",
"@react-native/babel-preset": "0.75.2",
"@react-native/eslint-config": "0.75.2",
"@react-native/metro-config": "0.75.2",
"@react-native/typescript-config": "0.75.2",
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"metro-config": "^0.80.10",
"prettier": "2.8.8",
"react-test-renderer": "18.2.0",
"typescript": "5.0.4",
"metro-config": "^0.80.8"
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
},
"engines": {
"node": ">=18"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This project was created with react-native-windows 0.74.0 -->
<!-- This project was created with react-native-windows 0.75.0 -->
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)\ExperimentalFeatures.props" Condition="Exists('$(SolutionDir)\ExperimentalFeatures.props')" />
<PropertyGroup Label="Globals">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
IgnorableNamespaces="uap mp">

<Identity
Name="f35c6620-552d-4b0c-a662-bb037cb4c5ea"
Name="fab77527-ae8a-49d7-ae2d-cdfc5901d785"
Publisher="CN=React Native Windows Sample"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="f35c6620-552d-4b0c-a662-bb037cb4c5ea" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<mp:PhoneIdentity PhoneProductId="fab77527-ae8a-49d7-ae2d-cdfc5901d785" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>Calculator</DisplayName>
Expand Down
20 changes: 10 additions & 10 deletions samples/Calculator/cppwinrt/windows/Calculator/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"native,Version=v0.0": {
"Microsoft.JavaScript.Hermes": {
"type": "Direct",
"requested": "[0.1.18, )",
"resolved": "0.1.18",
"contentHash": "5K8rRihGwIs2XNOTP2Jsw3T6cegxCBQXcpPS4optONU/AmFElGAfnA6XBQJ4UqlCFCl9Nf9zQrgvCUPBWYHiag=="
"requested": "[0.1.23, )",
"resolved": "0.1.23",
"contentHash": "cA9t1GjY4Yo0JD1AfA//e1lOwk48hLANfuX6GXrikmEBNZVr2TIX5ONJt5tqCnpZyLz6xGiPDgTfFNKbSfb21g=="
},
"Microsoft.UI.Xaml": {
"type": "Direct",
Expand All @@ -25,8 +25,8 @@
},
"boost": {
"type": "Transitive",
"resolved": "1.76.0",
"contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
"resolved": "1.83.0",
"contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ=="
},
"Microsoft.Web.WebView2": {
"type": "Transitive",
Expand All @@ -36,7 +36,7 @@
"common": {
"type": "Project",
"dependencies": {
"boost": "[1.76.0, )"
"boost": "[1.83.0, )"
}
},
"fmt": {
Expand All @@ -45,7 +45,7 @@
"folly": {
"type": "Project",
"dependencies": {
"boost": "[1.76.0, )",
"boost": "[1.83.0, )",
"fmt": "[1.0.0, )"
}
},
Expand All @@ -54,17 +54,17 @@
"dependencies": {
"Common": "[1.0.0, )",
"Folly": "[1.0.0, )",
"Microsoft.JavaScript.Hermes": "[0.1.18, )",
"Microsoft.JavaScript.Hermes": "[0.1.23, )",
"Microsoft.UI.Xaml": "[2.8.0, )",
"ReactCommon": "[1.0.0, )",
"boost": "[1.76.0, )"
"boost": "[1.83.0, )"
}
},
"reactcommon": {
"type": "Project",
"dependencies": {
"Folly": "[1.0.0, )",
"boost": "[1.76.0, )"
"boost": "[1.83.0, )"
}
}
},
Expand Down
Loading

0 comments on commit 1608dff

Please sign in to comment.