little-snow-fox / react-native-wechat-lib

🚀 WeChat login, share, favorite and payment for React-Native on iOS and Android
MIT License
646 stars 126 forks source link

ios版本的3.0.x有人集成成功了吗? #257

Open zhonglikui opened 10 months ago

zhonglikui commented 10 months ago

我把demo下载下来iOS版没有没有运行起来,有人运行成功了吗?3.0.x大约什么时候会正式发布呢? "react": "18.2.0", "react-native": "0.72.3",

RabbitNever commented 10 months ago

我把demo下载下来iOS版没有没有运行起来,有人运行成功了吗?3.0.x大约什么时候会正式发布呢? "react": "18.2.0", "react-native": "0.72.3",

他3.0.4的podspec有问题,你需要下下来改了podspec自己发私仓用

izozo commented 10 months ago

你好,请问你集成成功了吗,我也是rn0.72.3 ,pod install之后发现一大堆Undefined symbol: _OBJCCLASS$_SendMessageToWXReq之类的报红

vfasky commented 10 months ago

我的版本是 0.72.4 (M2 机器) 集成成功了,不用复制 /ios/libWeChatSDK.a 到 Xcode 项目根目录

1. 在 Podfile 找到 post_install do |installer| 修改成以下的内容

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )

    #  添加这段,M1/M2 模拟器能跑起来,wechat 小而美!
    installer.pods_project.build_configurations.each do |config|    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end

    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

在最后一行添加

# 安装官方 SDK
pod 'WechatOpenSDK'

2 AppDelegate.h

#import <RCTAppDelegate.h>
#import <UIKit/UIKit.h>
#import "WXApi.h"

@interface AppDelegate : RCTAppDelegate <UIApplicationDelegate, WXApiDelegate>

@end

3 AppDelegate.mm

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"<修改成你的项目名>";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return  [WXApi handleOpenURL:url delegate:self];
}

- (BOOL)application:(UIApplication *)application
  continueUserActivity:(NSUserActivity *)userActivity
  restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> * __nullable
  restorableObjects))restorationHandler {
  // 触发回调方法
  [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
  return [WXApi handleOpenUniversalLink:userActivity
  delegate:self];
}

// ios 9.0+
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
            options:(NSDictionary<NSString*, id> *)options
{
  // Triggers a callback event.
  // 触发回调事件
  [RCTLinkingManager application:application openURL:url options:options];
  return [WXApi handleOpenURL:url delegate:self];
}

@end

祝你好运,逃掉微信折磨。

LuckyEricYz commented 8 months ago

@vfasky 大佬,运行demo的时候报

image

, rn: 0.71.4 , react: 18.1.0, ruby: 2.7.6, pod: 1.13.0, 没麻烦您有时间看下

LuckyEricYz commented 8 months ago
image
Mashirowww commented 7 months ago

@vfasky 大佬,运行demo的时候报 image , rn: 0.71.4 , react: 18.1.0, ruby: 2.7.6, pod: 1.13.0, 没麻烦您有时间看下

+1 我也遇到了

LuckyEricYz commented 7 months ago

@Mashirowww