Skip to content

Commit

Permalink
Add support for the React Native's new architecture (#137)
Browse files Browse the repository at this point in the history
* init 3.2 branch

* Fix Android rendering issue, add prettier

* bump Android SDK dependency to 3.1.0

* Include ObjectiveC in pack files

* Fine tune settings to make packing work for iOS

* bump iOS SDK dependency to 3.1.0

* update circleCI config to publish

* V3.2.0-rc.1 (#122)

* V3.2.0-rc.2 (#123)

* Add type declarations (#124)

* V3.2.0-rc.4 (#134)

* Add support for both React Native architectures (#136)

* Updated names

* Fix forward compatibility

* Fix backwards compatibility

* Updated versions

* Updated versions

* Updated podlock file

* Updated versions

* Revert version back to 3.2.0-rc.5

* Disable workflow

* change publish branch

* Fix layout sizing (#138)

* Fix layout sizing

* change circleCI publish branch

* Backport Android react native version passing, bump to 3.2.0 (#140)

* Temporarily disable CI publish step for merge into main

* Add placeholder test CI job

---------

Co-authored-by: Allen Gao <[email protected]>
Co-authored-by: Allen Gao <[email protected]>
  • Loading branch information
3 people authored Nov 21, 2024
1 parent b812157 commit 3b7c472
Show file tree
Hide file tree
Showing 106 changed files with 14,800 additions and 5,617 deletions.
94 changes: 47 additions & 47 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,66 @@ version: 2.1
jobs:
test:
docker:
- image: cimg/node:16.7.0
- image: cimg/node:22.11.0

working_directory: ~/react-native-pinwheel/example

steps:
- checkout:
path: ~/react-native-pinwheel
- run: cd ../ && npm i && npm run build && npm pack && cd -
- run:
name: Remove package-lock hash for pkg because tarball will have a different hash than when built locally
command: node ../scripts/remove-pkg-hash.js
- run:
name: Create dummy env file
command: echo "export default \"x\"" > env.js
- run:
name: Check changelog for updates
command: grep -oq [^0-9]$pkgjsonversion[^0-9] ../CHANGELOG.md || (echo ERROR. Please update changelog. && exit 1)
- run:
name: Check for version bump if necessary
command:
(git branch | grep '\* main' && echo 'Skipping version check since on main') ||
(! (git status | grep -E "(src|package)") && echo 'Skipping version check since no changes to src or package') ||
(echo $(git diff main:package.json package.json) | grep version ||
(echo "Must bump version" && exit 1))
- run:
name: Confirm node version npm install
command: cat package-lock.json | grep lockfileVersion | grep 3 || exit 1
- run:
name: Confirm version matches in all relevant places
command: cd .. && node ./scripts/check-version-matchups.cjs && cd -
- run: npm install
- run:
name: jest tests
command: |
mkdir -p test-results/jest
yarn run test
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
- run: cd ../ && npm i && npm pack && cd -
# - run:
# name: Remove package-lock hash for pkg because tarball will have a different hash than when built locally
# command: node ../scripts/remove-pkg-hash.js
# - run:
# name: Create dummy env file
# command: echo "export default \"x\"" > env.js
# - run:
# name: Check changelog for updates
# command: grep -oq [^0-9]$pkgjsonversion[^0-9] ../CHANGELOG.md || (echo ERROR. Please update changelog. && exit 1)
# - run:
# name: Check for version bump if necessary
# command:
# (git branch | grep '\* main' && echo 'Skipping version check since on main') ||
# (! (git status | grep -E "(src|package)") && echo 'Skipping version check since no changes to src or package') ||
# (echo $(git diff main:package.json package.json) | grep version ||
# (echo "Must bump version" && exit 1))
# - run:
# name: Confirm node version npm install
# command: cat package-lock.json | grep lockfileVersion | grep 3 || exit 1
# - run:
# name: Confirm version matches in all relevant places
# command: cd .. && node ./scripts/check-version-matchups.cjs && cd -
# - run: npm install
# - run:
# name: jest tests
# command: |
# mkdir -p test-results/jest
# yarn run test
# - store_test_results:
# path: test-results
# - store_artifacts:
# path: test-results

publish:
docker:
- image: cimg/node:16.7.0
- image: cimg/node:22.11.0
working_directory: ~/react-native-pinwheel
steps:
- checkout
- run:
name: Authenticate with NPM registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >
~/react-native-pinwheel/.npmrc
- run:
name: NPM Install
command: npm install
- run:
name: NPM Prepublish
command: ./scripts/prepublish-test.sh
- run:
name: NPM Publish
command: npm publish
# - run:
# name: NPM Install
# command: npm install
# - run:
# name: NPM Prepublish
# command: ./scripts/prepublish-test.sh
# - run:
# name: NPM Publish
# command: npm publish
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large

Expand All @@ -73,8 +73,8 @@ workflows:
context: 'frontend-production'
- publish:
context: 'frontend-production'
requires:
- test
# requires:
# - test
filters:
branches:
only: main
only: main-3.2
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ android/build
android/gradle
android/gradlew
android/gradlew.bat
android/local.properties
android/local.properties
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"endOfLine": "lf",
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"bracketSpacing": true
}
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

# 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'
136 changes: 136 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.7)
base64
nkf
rexml
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
benchmark (0.3.0)
bigdecimal (3.1.8)
claide (1.1.0)
cocoapods (1.16.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.16.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.27.0, < 2.0)
cocoapods-core (1.16.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
drb (2.2.1)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.17.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-aarch64-linux-musl)
ffi (1.17.0-arm-linux-gnu)
ffi (1.17.0-arm-linux-musl)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86-linux-gnu)
ffi (1.17.0-x86-linux-musl)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.8.1)
logger (1.6.1)
minitest (5.25.1)
molinillo (0.8.0)
nanaimo (0.4.0)
nap (1.1.0)
netrc (0.11.0)
nkf (0.2.0)
public_suffix (4.0.7)
rexml (3.3.9)
ruby-macho (2.5.1)
securerandom (0.3.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.27.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.4.0)
rexml (>= 3.3.6, < 4.0)

PLATFORMS
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
ruby
x86-linux-gnu
x86-linux-musl
x86_64-darwin
x86_64-linux-gnu
x86_64-linux-musl

DEPENDENCIES
activesupport (>= 6.1.7.5, != 7.1.0)
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)

RUBY VERSION
ruby 3.1.4p223

BUNDLED WITH
2.5.6
44 changes: 44 additions & 0 deletions PinwheelLinkSDKObjC/ObjCWrapper.xcframework/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>ObjCWrapper.framework/ObjCWrapper</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>ObjCWrapper.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>ObjCWrapper.framework/ObjCWrapper</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>ObjCWrapper.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ObjCWrapper.h
// ObjCWrapper
//
// Created by Robby Abaya on 10/15/24.
//

#import <Foundation/Foundation.h>

//! Project version number for ObjCWrapper.
FOUNDATION_EXPORT double ObjCWrapperVersionNumber;

//! Project version string for ObjCWrapper.
FOUNDATION_EXPORT const unsigned char ObjCWrapperVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <ObjCWrapper/PublicHeader.h>

#import <ObjCWrapper/PinwheelVCWrapper.h>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@protocol PinwheelVCWrapperDelegate <NSObject>
- (void)onEventWithName:(NSString *)name event:(NSDictionary *)event;
@end

@interface PinwheelVCWrapper : UIViewController

- (instancetype)initWithToken:(NSString *)token delegate:(id<PinwheelVCWrapperDelegate>)delegate;
- (instancetype)initWithToken:(NSString *)token delegate:(id<PinwheelVCWrapperDelegate>)delegate sdk:(NSString *)sdk version:(NSString *)version;

@end

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module ObjCWrapper {
umbrella header "ObjCWrapper.h"
export *

module * { export * }
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Build for iOS device
```
xcodebuild archive -scheme ObjCWrapper -configuration Release -destination 'generic/platform=iOS' -archivePath './build/ObjCWrapper.framework-iphoneos.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
```

Build for simulator
```
xcodebuild archive -scheme ObjCWrapper -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath './build/ObjCWrapper.framework-iphonesimulator.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
```

Create a universal framework
```
xcodebuild -create-xcframework -framework './build/ObjCWrapper.framework-iphoneos.xcarchive/Products/Library/Frameworks/ObjCWrapper.framework' -framework './build/ObjCWrapper.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/ObjCWrapper.framework' -output './build/ObjCWrapper.xcframework'
```

Loading

0 comments on commit 3b7c472

Please sign in to comment.