Skip to content

Commit

Permalink
chore: using xcframework for ios
Browse files Browse the repository at this point in the history
  • Loading branch information
jerson committed May 23, 2024
1 parent b47b1a7 commit f1a4eff
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 10 deletions.
48 changes: 48 additions & 0 deletions ios/Rsa.xcframework/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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>librsa_bridge.a</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>librsa_bridge.a</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>librsa_bridge.a</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>librsa_bridge.a</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>
87 changes: 87 additions & 0 deletions ios/Rsa.xcframework/ios-arm64/Headers/librsa_bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* Code generated by cmd/cgo; DO NOT EDIT. */

/* package command-line-arguments */


#line 1 "cgo-builtin-export-prolog"

#include <stddef.h>

#ifndef GO_CGO_EXPORT_PROLOGUE_H
#define GO_CGO_EXPORT_PROLOGUE_H

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
#endif

#endif

/* Start of preamble from import "C" comments. */


#line 3 "main.go"
#include <stdint.h>
#include <stdlib.h>
typedef struct { void* message; int size; char* error; } BytesReturn;

#line 1 "cgo-generated-wrapper"


/* End of preamble from import "C" comments. */


/* Start of boilerplate cgo prologue. */
#line 1 "cgo-gcc-export-header-prolog"

#ifndef GO_CGO_PROLOGUE_H
#define GO_CGO_PROLOGUE_H

typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef size_t GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
#ifdef _MSC_VER
#include <complex.h>
typedef _Fcomplex GoComplex64;
typedef _Dcomplex GoComplex128;
#else
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
#endif

/*
static assertion to make sure the file is being used on architecture
at least with matching size of GoInt.
*/
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef _GoString_ GoString;
#endif
typedef void *GoMap;
typedef void *GoChan;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;

#endif

/* End of boilerplate cgo prologue. */

#ifdef __cplusplus
extern "C" {
#endif

extern BytesReturn* RSABridgeCall(char* name, void* payload, int payloadSize);

#ifdef __cplusplus
}
#endif
Binary file added ios/Rsa.xcframework/ios-arm64/librsa_bridge.a
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* Code generated by cmd/cgo; DO NOT EDIT. */

/* package command-line-arguments */


#line 1 "cgo-builtin-export-prolog"

#include <stddef.h>

#ifndef GO_CGO_EXPORT_PROLOGUE_H
#define GO_CGO_EXPORT_PROLOGUE_H

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
#endif

#endif

/* Start of preamble from import "C" comments. */


#line 3 "main.go"
#include <stdint.h>
#include <stdlib.h>
typedef struct { void* message; int size; char* error; } BytesReturn;

#line 1 "cgo-generated-wrapper"


/* End of preamble from import "C" comments. */


/* Start of boilerplate cgo prologue. */
#line 1 "cgo-gcc-export-header-prolog"

#ifndef GO_CGO_PROLOGUE_H
#define GO_CGO_PROLOGUE_H

typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef size_t GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
#ifdef _MSC_VER
#include <complex.h>
typedef _Fcomplex GoComplex64;
typedef _Dcomplex GoComplex128;
#else
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
#endif

/*
static assertion to make sure the file is being used on architecture
at least with matching size of GoInt.
*/
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef _GoString_ GoString;
#endif
typedef void *GoMap;
typedef void *GoChan;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;

#endif

/* End of boilerplate cgo prologue. */

#ifdef __cplusplus
extern "C" {
#endif

extern BytesReturn* RSABridgeCall(char* name, void* payload, int payloadSize);

#ifdef __cplusplus
}
#endif
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-fast-rsa",
"version": "2.4.2",
"version": "2.4.3",
"description": "library for use RSA",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
7 changes: 2 additions & 5 deletions react-native-fast-rsa.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,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'
shared_lib = File.join(__dir__, "ios/librsa_bridge.a").gsub(/ /, '\ ')

Pod::Spec.new do |s|
s.name = package["name"]
Expand All @@ -16,10 +15,8 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/jerson/react-native-fast-rsa.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}"
s.vendored_libraries = '*.a'
s.xcconfig = { 'OTHER_LDFLAGS' => "-force_load '#{shared_lib}'"}
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.vendored_framework = 'ios/Rsa.xcframework'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }

# 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.
Expand Down
7 changes: 3 additions & 4 deletions scripts/upgrade_bridge_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

REPO="jerson/rsa-mobile"
NAME="librsa_bridge"
PLATFORMS=("android" "ios" )
PLATFORMS=("android" "ios_xcframework" )
OUTPUT_DIRS=("android/src/main" "ios")
OUTPUT_SUB_DIRS=("" "")
OUTPUT_STRIP_DIRS=(1 1)
Expand Down Expand Up @@ -42,12 +42,12 @@ do
OUTPUT_STRIP_DIR=${OUTPUT_STRIP_DIRS[$INDEX]}

FILE_NAME="${NAME}_${PLATFORM}_${VERSION}.tar.gz"
TMP_FILE="$TMP_DIR/$FILE_NAME"
TMP_FILE="$TMP_DIR/$FILE_NAME"
FILE_URL="https://github.com/${REPO}/releases/download/${VERSION}/${FILE_NAME}"

echo "Platform: $PLATFORM"
echo "Downloading: $FILE_URL to $TMP_FILE"
curl -L -o $TMP_FILE "$FILE_URL"
curl -L -o $TMP_FILE "$FILE_URL"

echo "Extracting: $TMP_FILE to $OUTPUT_DIR"
mkdir -p $OUTPUT_DIR
Expand All @@ -60,4 +60,3 @@ do
done
#
echo "All updated"
rm ios/librsa_bridge.h || echo "."

0 comments on commit f1a4eff

Please sign in to comment.