From c0b788cdfc4a99a28da0d2ea0f334dcf620452b6 Mon Sep 17 00:00:00 2001 From: Szczepan Barszczowski Date: Tue, 19 Sep 2023 14:10:58 +0200 Subject: [PATCH 1/5] Fixed autolinking issue --- RNTextSize.podspec | 40 ++++++++++++++++++++++++++++++++++++++++ android/build.gradle | 4 ++-- ios/RNTextSize.podspec | 22 ---------------------- package.json | 2 +- react-native.config.js | 12 ++++++++++++ 5 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 RNTextSize.podspec delete mode 100644 ios/RNTextSize.podspec create mode 100644 react-native.config.js diff --git a/RNTextSize.podspec b/RNTextSize.podspec new file mode 100644 index 0000000..b4f11f5 --- /dev/null +++ b/RNTextSize.podspec @@ -0,0 +1,40 @@ +require 'json' +package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) + +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' + +Pod::Spec.new do |s| + s.name = 'RNTextSize' + s.version = package['version'] + s.summary = package['description'] + s.description = <<-DESC + React Native library to measure blocks of text before laying it on screen and get fonts info, + based originally on Airam's react-native-measure-text (support iOS and Android). + DESC + s.homepage = package['homepage'] + s.license = package['license'] + s.author = package['author'] + s.platform = { :ios => "9.0" } + s.source = { :git => package['repository'], :tag => "v#{s.version}" } + s.source_files = 'ios/**/*.{h,m,mm,swift}' + s.requires_arc = true + + s.dependency 'React-Core' + + if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then + s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" + s.pod_target_xcconfig = { + "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"", + "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" + } + + s.dependency "React-RCTFabric" + s.dependency "React-Codegen" + s.dependency "RCT-Folly" + s.dependency "RCTRequired" + s.dependency "RCTTypeSafety" + s.dependency "ReactCommon/turbomodule/core" + end +end + diff --git a/android/build.gradle b/android/build.gradle index 2617bd7..0e4943f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,8 +9,8 @@ def safeExtGet(prop, fallback) { } def _buildToolsVersion = safeExtGet('buildToolsVersion', '28.0.3') -def _compileSdkVersion = safeExtGet('compileSdkVersion', 28) -def _targetSdkVersion = safeExtGet('targetSdkVersion', 28) +def _compileSdkVersion = safeExtGet('compileSdkVersion', 30) +def _targetSdkVersion = safeExtGet('targetSdkVersion', 30) def _minSdkVersion = safeExtGet('minSdkVersion', 16) buildscript { diff --git a/ios/RNTextSize.podspec b/ios/RNTextSize.podspec deleted file mode 100644 index 281e201..0000000 --- a/ios/RNTextSize.podspec +++ /dev/null @@ -1,22 +0,0 @@ -require 'json' -package = JSON.parse(File.read('../package.json')) - -Pod::Spec.new do |s| - s.name = 'RNTextSize' - s.version = package['version'] - s.summary = package['description'] - s.description = <<-DESC - React Native library to measure blocks of text before laying it on screen and get fonts info, - based originally on Airam's react-native-measure-text (support iOS and Android). - DESC - s.homepage = package['homepage'] - s.license = package['license'] - s.author = package['author'] - s.platform = :ios, '9.0' - s.source = { :git => package['repository'], :tag => "v#{s.version}" } - s.source_files = '*.{h,m}' - s.requires_arc = true - - s.dependency 'React' -end - diff --git a/package.json b/package.json index e9dc76c..80e469c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-text-size", - "version": "4.0.0-rc.1", + "version": "4.0.0-rc.2", "description": "Measure text accurately before laying it out and get font information from your App", "main": "index.js", "keywords": [ diff --git a/react-native.config.js b/react-native.config.js new file mode 100644 index 0000000..2fa2adc --- /dev/null +++ b/react-native.config.js @@ -0,0 +1,12 @@ +module.exports = { + dependency: { + platforms: { + android: { + packageImportPath: + "import com.github.amarcruz.rntextsize.RNTextSizePackage;", + packageInstance: "new RNTextSizePackage()", + }, + ios: {}, + }, + }, +}; From 208846c82df9a37cd68701f9e07184425e8894cf Mon Sep 17 00:00:00 2001 From: Szczepan Barszczowski Date: Tue, 19 Sep 2023 16:17:29 +0200 Subject: [PATCH 2/5] Gradle improvements --- RNTextSize.podspec | 18 ------------------ android/build.gradle | 21 ++++++++++++--------- react-native.config.js | 12 ------------ 3 files changed, 12 insertions(+), 39 deletions(-) delete mode 100644 react-native.config.js diff --git a/RNTextSize.podspec b/RNTextSize.podspec index b4f11f5..b217948 100644 --- a/RNTextSize.podspec +++ b/RNTextSize.podspec @@ -1,8 +1,6 @@ require 'json' package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) -folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' - Pod::Spec.new do |s| s.name = 'RNTextSize' s.version = package['version'] @@ -20,21 +18,5 @@ Pod::Spec.new do |s| s.requires_arc = true s.dependency 'React-Core' - - if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then - s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" - s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"", - "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" - } - - s.dependency "React-RCTFabric" - s.dependency "React-Codegen" - s.dependency "RCT-Folly" - s.dependency "RCTRequired" - s.dependency "RCTTypeSafety" - s.dependency "ReactCommon/turbomodule/core" - end end diff --git a/android/build.gradle b/android/build.gradle index 0e4943f..52bc150 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,18 +8,22 @@ def safeExtGet(prop, fallback) { return rootProject.ext.hasProperty(prop) ? rootProject.ext.get(prop) : fallback } -def _buildToolsVersion = safeExtGet('buildToolsVersion', '28.0.3') def _compileSdkVersion = safeExtGet('compileSdkVersion', 30) def _targetSdkVersion = safeExtGet('targetSdkVersion', 30) def _minSdkVersion = safeExtGet('minSdkVersion', 16) buildscript { - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' + // The Android Gradle plugin is only required when opening the android folder stand-alone. + // This avoids unnecessary downloads and potential conflicts when the library is included as a + // module dependency in an application project. + if (project == rootProject) { + repositories { + google() + } + + dependencies { + classpath("com.android.tools.build:gradle:8.0.1") + } } } @@ -43,7 +47,6 @@ android { repositories { mavenLocal() google() - jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" @@ -51,7 +54,7 @@ repositories { } dependencies { - compileOnly 'com.facebook.react:react-native:+' + implementation 'com.facebook.react:react-native:+' } task customClean(type: Delete) { diff --git a/react-native.config.js b/react-native.config.js deleted file mode 100644 index 2fa2adc..0000000 --- a/react-native.config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - dependency: { - platforms: { - android: { - packageImportPath: - "import com.github.amarcruz.rntextsize.RNTextSizePackage;", - packageInstance: "new RNTextSizePackage()", - }, - ios: {}, - }, - }, -}; From 4dcf67684c30c3b1cfebe329ab315d2ba2b47e27 Mon Sep 17 00:00:00 2001 From: Szczepan Barszczowski Date: Tue, 19 Sep 2023 16:31:14 +0200 Subject: [PATCH 3/5] gradle fix --- android/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 52bc150..27889c3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -31,7 +31,6 @@ apply plugin: 'com.android.library' android { compileSdkVersion _compileSdkVersion - buildToolsVersion _buildToolsVersion defaultConfig { minSdkVersion _minSdkVersion From 5e6134e4906792eed516ee8b0e412a1e34e16333 Mon Sep 17 00:00:00 2001 From: Szczepan Barszczowski Date: Tue, 19 Sep 2023 16:55:34 +0200 Subject: [PATCH 4/5] Podspec adjustment --- RNTextSize.podspec => react-native-text-size.podspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename RNTextSize.podspec => react-native-text-size.podspec (84%) diff --git a/RNTextSize.podspec b/react-native-text-size.podspec similarity index 84% rename from RNTextSize.podspec rename to react-native-text-size.podspec index b217948..a10d321 100644 --- a/RNTextSize.podspec +++ b/react-native-text-size.podspec @@ -1,8 +1,8 @@ require 'json' -package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) +package = JSON.parse(File.read('./package.json')) Pod::Spec.new do |s| - s.name = 'RNTextSize' + s.name = 'react-native-text-size' s.version = package['version'] s.summary = package['description'] s.description = <<-DESC @@ -17,6 +17,6 @@ Pod::Spec.new do |s| s.source_files = 'ios/**/*.{h,m,mm,swift}' s.requires_arc = true - s.dependency 'React-Core' + s.dependency 'React' end From 649c7ffe924967311c4644b713f5a81fd7cf214c Mon Sep 17 00:00:00 2001 From: Szczepan Barszczowski Date: Tue, 19 Sep 2023 18:04:02 +0200 Subject: [PATCH 5/5] Podspec adjustment --- react-native-text-size.podspec => RNTextSize.podspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename react-native-text-size.podspec => RNTextSize.podspec (84%) diff --git a/react-native-text-size.podspec b/RNTextSize.podspec similarity index 84% rename from react-native-text-size.podspec rename to RNTextSize.podspec index a10d321..da929db 100644 --- a/react-native-text-size.podspec +++ b/RNTextSize.podspec @@ -2,7 +2,7 @@ require 'json' package = JSON.parse(File.read('./package.json')) Pod::Spec.new do |s| - s.name = 'react-native-text-size' + s.name = 'RNTextSize' s.version = package['version'] s.summary = package['description'] s.description = <<-DESC @@ -12,9 +12,9 @@ Pod::Spec.new do |s| s.homepage = package['homepage'] s.license = package['license'] s.author = package['author'] - s.platform = { :ios => "9.0" } + s.platform = :ios, '9.0' s.source = { :git => package['repository'], :tag => "v#{s.version}" } - s.source_files = 'ios/**/*.{h,m,mm,swift}' + s.source_files = 'ios/*.{h,m}' s.requires_arc = true s.dependency 'React'