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

feat(android, sdk12)!: update to facebook-android-sdk 12 #127

Merged
merged 11 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 1 addition & 8 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ node_modules/react-native/flow/
[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js
Expand All @@ -47,10 +44,6 @@ suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
Expand All @@ -73,4 +66,4 @@ untyped-import
untyped-type-import

[version]
^0.122.0
^0.158.0
93 changes: 62 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,107 @@ jobs:
js-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 12.x
node-version: 14
- name: Install yarn
run: npm install -g yarn
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
retry_wait_seconds: 30
max_attempts: 3
command: npm install -g yarn
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-yarn-v1-
- name: Install dependencies
run: yarn install
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
retry_wait_seconds: 30
max_attempts: 3
command: yarn install
- name: Run tests
run: yarn test
android-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
- uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v2
with:
node-version: 12.x
node-version: 14
- name: Install yarn
run: npm install -g yarn
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
retry_wait_seconds: 30
max_attempts: 3
command: npm install -g yarn
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-yarn-v1-
- name: Install dependencies
run: yarn install
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
retry_wait_seconds: 30
max_attempts: 3
command: yarn install --frozen-lockfile
- name: Build android example app
run: cd RNFBSDKExample && yarn && cd android && ./gradlew assembleDebug
run: yarn example:install && yarn example:devcopy && yarn example:install && cd RNFBSDKExample && cd android && ./gradlew assembleDebug
ios-build:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
- uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v2
with:
node-version: 12.x
- uses: actions/setup-ruby@v1
node-version: 14
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.x'
ruby-version: 3
- name: Install cocoapods
run: gem install cocoapods
- name: Install yarn
run: npm install -g yarn
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
retry_wait_seconds: 30
max_attempts: 3
command: npm install -g yarn
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-yarn-v1
- name: Install dependencies
run: yarn install && cd RNFBSDKExample && yarn
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
retry_wait_seconds: 30
max_attempts: 3
command: yarn install && cd RNFBSDKExample && yarn
- name: Install pods
run: cd RNFBSDKExample/ios && rm -f Podfile.lock && pod install
- name: Build ios example app
run: cd RNFBSDKExample/ios && xcodebuild -scheme RNFBSDKExample -workspace RNFBSDKExample.xcworkspace ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator -configuration Debug
run: yarn example:install && yarn example:devcopy && yarn example:install && cd RNFBSDKExample/ios && xcodebuild -scheme RNFBSDKExample -workspace RNFBSDKExample.xcworkspace VALID_ARCHS=\"`uname -m`\" ONLY_ACTIVE_ARCH=YES -sdk iphonesimulator -configuration Debug
4 changes: 3 additions & 1 deletion .github/workflows/pr_title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v3.1.0
- uses: amannn/action-semantic-pull-request@v3.4.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: true
26 changes: 21 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,36 @@ on: workflow_dispatch
jobs:
release:
name: Release
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 14
- name: Install yarn
run: npm install -g yarn
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v1-
- name: Install dependencies
run: npm ci
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
retry_wait_seconds: 30
max_attempts: 3
command: rm -rf node_modules && yarn install --frozen-lockfile
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
run: yarn semantic-release
18 changes: 17 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
TO BE DEFINED YET

# PRs Welcome


Nothing much to add to that ;-), but this is an open source module. We always need contributors. We welcome PRs. We can merge and release them very quickly. Please help us keep the module working by digging in and helping fix problems instead of just logging them, thank you!

# Development Guide

The best way to develop the module is to fork/clone the repo, then develop against the example app.

Here is a procedure that works:

1. Fork the repo on github
1. `git clone git@github.com:<your github username>/react-native-fbsdk.next.git`
1. `cd react-native-fbsdk-next`
1. `yarn`
1. Follow the instructions in [RNFBSDKExample/README.md](the example README) related to using the example to test changes to the core module
File renamed without changes.
7 changes: 3 additions & 4 deletions RNFBSDKExample/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ node_modules/react-native/flow/
[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

exact_by_default=true

format.bracket_spacing=false

module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js
Expand Down Expand Up @@ -63,4 +62,4 @@ untyped-import
untyped-type-import

[version]
^0.137.0
^0.158.0
1 change: 1 addition & 0 deletions RNFBSDKExample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ build/
.gradle
local.properties
*.iml
*.hprof

# node.js
#
Expand Down
16 changes: 14 additions & 2 deletions RNFBSDKExample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This example is extremely basic but hopefully still useful.

You run it by cloning the main repo, and running `yarn` then `yarn example:android` or `yarn example:ios`
You run it by cloning the main repo, and running `yarn example:install` then `yarn example:start`, and finally `yarn example:android` or `yarn example:ios`

The example currently validates these things:

Expand All @@ -17,11 +17,23 @@ The example currently validates these things:

## Known Issues

- The App ID in use for the example is not configured, and it is problematic to configure one for the internet at large. Replace the App ID in `ios/RNFBSDKExample/Info.plist` and `android/src/main/res/values/strings.xml` with your App ID
- The Facebook App ID in use for the example is not configured, and it is problematic to configure one for the internet at large. Replace the App ID in `ios/RNFBSDKExample/Info.plist` and `android/src/main/res/values/strings.xml` with your App ID
- It does not demonstrate anything else, contributions welcome

## How to contribute to the example

- First, note that it is automatically constructed. The only file that is preserved when `refresh-example.sh` is run is `App.js`
- Make all UI changes in `App.js`
- Make all config changes (`Info.plist` or `.java` / `.m` file changes via sed edits in `refresh-example.sh`. No, that's not the easiest thing to do. But unless you commit to maintaining the project and updating the example app yourself for a few years, it is still the most efficient way)

## Using the example to test changes to the core module

If you are making changes to the core module and using the example for testing, you must understand the example references the module code via a github reference.

The example will contain stale files unless you clear the lockfiles/modules, copy in the module code and reinstall. There are three commands which are useful for development that help you manage this. You may run all of these from the main directory:

- `yarn example:clean` - this removes node_modules and the yarn and pod lockfiles
- `yarn example:install` - this just runs `yarn` and `pod install` for you
- `yarn example:devcopy` - this runs `yarn prepare` to build the core module, then copies the modules files in to the example

A typical workflow will involve you making changes in the core src / android / ios folders, then running `yarn example:devcopy` and - if you changed something in package.json or the podspec then `yarn example:install` repeatedly, while perhaps rebuilding the the native code in `RNFBSDKExample` as if it were a normal project (that is, `yarn android` or `yarn ios` to see the fresh native changes)
4 changes: 1 addition & 3 deletions RNFBSDKExample/__tests__/App-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ import App from '../App';
import renderer from 'react-test-renderer';

it('renders correctly', () => {
const render = renderer.create(<App />);
render.getByTestId("facebook-login");
renderer.create(<App />);
});

19 changes: 12 additions & 7 deletions RNFBSDKExample/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ def jscFlavor = 'org.webkit:android-jsc:+'
*/
def enableHermes = project.ext.react.get("enableHermes", false);

/**
* Architectures to build native code for in debug.
*/
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")

android {
ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.rnfbsdkexample"
minSdkVersion rootProject.ext.minSdkVersion
Expand All @@ -156,6 +156,11 @@ android {
buildTypes {
debug {
signingConfig signingConfigs.debug
if (nativeArchitectures) {
ndk {
abiFilters nativeArchitectures.split(',')
}
}
}
release {
// Caution! In production, you need to generate your own keystore file.
Expand Down Expand Up @@ -191,7 +196,7 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
exclude group:'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
Expand All @@ -215,7 +220,7 @@ dependencies {
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
from configurations.implementation
into 'libs'
}

Expand Down
2 changes: 1 addition & 1 deletion RNFBSDKExample/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="true" />
</application>
</manifest>
Loading