Skip to content

New-arch/MOB-11545-update-build-configurations-for-both-ios-and-andro #645

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

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
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
172 changes: 154 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
- name: Run unit tests
run: yarn test --maxWorkers=2 --coverage

build-library:
build-library-old-arch:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -47,27 +47,107 @@
- name: Setup
uses: ./.github/actions/setup

- name: Build package
run: yarn prepare
- name: Switch to old architecture
run: yarn switch-arch old

build-android:
- name: Build package with old architecture
run: yarn build:old-arch

build-library-new-arch:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Switch to new architecture
run: yarn switch-arch new

- name: Build package with new architecture
run: yarn build:new-arch

build-android-old-arch:
Comment on lines +57 to +71

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we need to add a permissions block to the workflow file. This block should specify the minimal permissions required for the workflow to function correctly. Based on the provided workflow, it appears that the jobs primarily involve checking out code, running setup scripts, linting, type-checking, testing, and building packages. These tasks typically require only contents: read permissions. Therefore, we will add a permissions block at the root level of the workflow to apply to all jobs.

Suggested changeset 1
.github/workflows/ci.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,2 +1,4 @@
 name: CI
+permissions:
+  contents: read
 on:
EOF
@@ -1,2 +1,4 @@
name: CI
permissions:
contents: read
on:
Copilot is powered by AI and may make mistakes. Always verify output.
runs-on: ubuntu-latest
env:
TURBO_CACHE_DIR: .turbo/android-old
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Switch to old architecture
run: yarn switch-arch old

- name: Cache turborepo for Android
uses: actions/cache@v3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-android-old-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-android-old-

- name: Check turborepo cache for Android
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi

- name: Install JDK
if: env.turbo_cache_hit != 1
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'

- name: Finalize Android SDK
if: env.turbo_cache_hit != 1
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"

- name: Cache Gradle
if: env.turbo_cache_hit != 1
uses: actions/cache@v3
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-old-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-old-

- name: Build example for Android (Old Architecture)
env:
JAVA_OPTS: '-XX:MaxHeapSize=6g'
run: |
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"

build-android-new-arch:
Comment on lines +72 to +130

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 18 days ago

To fix the issue, we need to add a permissions block to the workflow file. This block should specify the least privileges required for the workflow to function correctly. Since the workflow primarily involves linting, testing, building, and caching, the minimal permission contents: read is sufficient for most jobs. If specific jobs require additional permissions, they can be set individually.

The permissions block can be added at the root level of the workflow to apply to all jobs, or it can be added to individual jobs if different permissions are required for each job.


Suggested changeset 1
.github/workflows/ci.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,2 +1,4 @@
 name: CI
+permissions:
+  contents: read
 on:
EOF
@@ -1,2 +1,4 @@
name: CI
permissions:
contents: read
on:
Copilot is powered by AI and may make mistakes. Always verify output.
runs-on: ubuntu-latest
env:
TURBO_CACHE_DIR: .turbo/android
TURBO_CACHE_DIR: .turbo/android-new
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Switch to new architecture
run: yarn switch-arch new

- name: Cache turborepo for Android
uses: actions/cache@v3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
key: ${{ runner.os }}-turborepo-android-new-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-android-
${{ runner.os }}-turborepo-android-new-

- name: Check turborepo cache for Android
run: |
Expand Down Expand Up @@ -96,62 +176,118 @@
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
key: ${{ runner.os }}-gradle-new-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
${{ runner.os }}-gradle-new-

- name: Build example for Android
- name: Build example for Android (New Architecture)
env:
JAVA_OPTS: "-XX:MaxHeapSize=6g"
JAVA_OPTS: '-XX:MaxHeapSize=6g'
run: |
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"

build-ios:
build-ios-old-arch:
runs-on: macos-14
env:
TURBO_CACHE_DIR: .turbo/ios
TURBO_CACHE_DIR: .turbo/ios-old
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Switch to old architecture
run: yarn switch-arch old

- name: Cache turborepo for iOS
uses: actions/cache@v3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-ios-old-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-ios-old-

- name: Check turborepo cache for iOS
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi

- name: Cache cocoapods
if: env.turbo_cache_hit != 1
id: cocoapods-cache
uses: actions/cache@v3
with:
path: |
**/ios/Pods
key: ${{ runner.os }}-cocoapods-old-${{ hashFiles('example/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-cocoapods-old-

- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
cd example/ios
pod install
env:
NO_FLIPPER: 1

- name: Build example for iOS (Old Architecture)
run: |
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

build-ios-new-arch:
runs-on: macos-14
env:
TURBO_CACHE_DIR: .turbo/ios-new
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Switch to new architecture
run: yarn switch-arch new

- name: Cache turborepo for iOS
uses: actions/cache@v3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
key: ${{ runner.os }}-turborepo-ios-new-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-ios-
${{ runner.os }}-turborepo-ios-new-

- name: Check turborepo cache for iOS
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi

- name: Cache cocoapods
if: env.turbo_cache_hit != 1
id: cocoapods-cache
uses: actions/cache@v3
with:
path: |
**/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
key: ${{ runner.os }}-cocoapods-new-${{ hashFiles('example/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-cocoapods-
${{ runner.os }}-cocoapods-new-

- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
cd example/ios
pod install
env:
NO_FLIPPER: 1

- name: Build example for iOS
- name: Build example for iOS (New Architecture)
run: |
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
5 changes: 3 additions & 2 deletions Iterable-React-Native-SDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Pod::Spec.new do |s|

s.source_files = "ios/**/*.{h,m,mm,swift}"

s.dependency "Iterable-iOS-SDK", "6.5.4"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
if respond_to?(:install_modules_dependencies, true)
Expand All @@ -36,9 +38,8 @@ Pod::Spec.new do |s|
s.dependency "RCTRequired"
s.dependency "RCTTypeSafety"
s.dependency "ReactCommon/turbomodule/core"
s.dependency "React-RCTFabric" # This is for Fabric support
end
end

s.dependency "Iterable-iOS-SDK", "6.5.4"

end
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,69 @@ Iterable's React Native SDK relies on:

## Architecture Support

**Important**: Iterable's React Native SDK currently does not support [React Native's New Architecture](https://reactnative.dev/architecture/landing-page) (Fabric, TurboModules, and Codegen). The SDK is designed to work with the **legacy architecture only**. If you're using the New Architecture in your React Native application, you may encounter compatibility issues.
Iterable's React Native SDK supports both the legacy architecture and React Native's New Architecture (Fabric, TurboModules, and Codegen). The SDK is designed to work seamlessly with both architectures, providing flexibility for your React Native application.

### New Architecture Support

Starting from version 2.0.0-beta.1, the SDK supports React Native's New Architecture. To use the SDK with the New Architecture:

1. Enable the New Architecture in your project:
```bash
yarn switch-arch new
```

2. Clean and rebuild your project:
```bash
yarn clean
yarn build:new-arch
```

3. For Android, ensure your `android/gradle.properties` has:
```properties
newArchEnabled=true
```

4. For iOS, the New Architecture will be automatically enabled when building with the new architecture flag.

### Legacy Architecture Support

To use the SDK with the legacy architecture:

1. Ensure you're using the legacy architecture:
```bash
yarn switch-arch old
```

2. Clean and rebuild your project:
```bash
yarn clean
yarn build:old-arch
```

3. For Android, ensure your `android/gradle.properties` has:
```properties
newArchEnabled=false
```

### Building for Both Architectures

If you need to support both architectures in your project:

1. Build for both architectures:
```bash
yarn build:all
```

This will create builds for both the old and new architecture, allowing you to test and deploy your app with either architecture.

### CI/CD Integration

The SDK includes CI/CD configurations that test both architectures. The CI pipeline will:
- Build the library with both old and new architecture
- Build Android example app with both architectures
- Build iOS example app with both architectures

This ensures that your SDK works correctly with both architectures in your CI/CD pipeline.

## Installation

Expand Down
Loading
Loading