ios 错误SwiftCompile normal arm64在我的react native app中从objective C迁移到Swift时,正在从项目pod中编译.. in target“”

bmp9r5qi  于 11个月前  发布在  iOS
关注(0)|答案(1)|浏览(441)

我有一个react native sdk,里面所有的代码都是用objective C编写的,现在我们正在将其迁移到swift,我遵循了官方的react native指南如何迁移到swift,做了所有建议,但它不起作用,我将解释主要问题发生在哪里-所以在我的objective c文件中,我的代码是这样写的-

#import <React/RCTBridgeModule.h>
#import <SCDoorway/SCDoorway.h>
#import <SCDoorway/SCDoorway-Swift.h>
#import <Loans/Loans.h>
#import <React/RCTBridge.h>

@interface RCT_EXTERN_MODULE(BigTreeDoorway, NSObject)

//MARK: SDK version helpers
//MARK: SDK setup
RCT_REMAP_METHOD(setConfigEnvironment,
                 envName:(NSString *)envName
                 gateway:(NSString *)gateway
                 isLeprechaunActive: (BOOL *)isLeprechaunActive
                 isAmoEnabled: (BOOL *)isAmoEnabled
                 preProvidedBrokers: (NSArray *)preProvidedBrokers
                 setConfigEnvironmentWithResolver:(RCTPromiseResolveBlock)resolve
                 rejecter:(RCTPromiseRejectBlock)reject) {
    NSInteger environment = EnvironmentProduction;

    if([envName isEqualToString:@"production"]) {
        environment = EnvironmentProduction;
    }
    else if([envName isEqualToString:@"development"]) {
        environment = EnvironmentDevelopment;
    } else {
        environment = EnvironmentStaging;
    }

    GatewayConfig *config = [[GatewayConfig alloc]
                             initWithGatewayName:gateway
                             brokerConfig:preProvidedBrokers
                             apiEnvironment:environment
                             isLeprechaunActive:isLeprechaunActive
                             isAmoEnabled:isAmoEnabled];

    [SCDoorway.shared setupWithConfig: config completion:^(BOOL success,NSError * error) {
        if(success) {
            resolve(@(YES));
        } else {
            NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
            [responseDict setValue:[NSNumber numberWithInteger:error.code]  forKey:@"errorCode"];
            [responseDict setValue:error.domain  forKey:@"errorMessage"];

            NSError *err = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:responseDict];

            reject(@"setConfigEnvironment", @"Env setup failed", err);
        }

    }];
}
//and many more functions ...

字符串
现在,即使在我的objective-C文件中,当我打开SDK的xcode项目时,它也会给我这样的错误-
x1c 0d1x的数据
现在,如果我注解掉那个特定的导入,它开始给我给予错误-



但是在我的react sdk的podspec文件中,我添加了依赖SCDoorway -



继续,当我构建我的react项目时,它都构建得很好,功能工作我通过添加一个与我的objective-C文件同名的swift文件开始迁移到swift- BigTreeDoorway,所以现在我的项目中总共有3个文件,分别是桥接头类,BigTreeDoorway.swift和BigTreeDoorway.m我已经检查了我的objective-C桥接头文件路径,它是正确的
当我把所有的目标函数转换成swift函数时,

import RCTBridgeModule
import Foundation
import SCDoorway
import React
import Loans

@objc(BigTreeDoorway)
class BigTreeDoorway: NSObject {
        
    @objc func setConfigEnvironment(_ envName: String,
                                    gateway: String,
                                    isLeprechaunActive: Bool,
                                    isAmoEnabled: Bool,
                                    preProvidedBrokers: [Any],
                                    resolver resolve: @escaping RCTPromiseResolveBlock,
                                    rejecter reject: @escaping RCTPromiseRejectBlock) {
        
        var environment = EnvironmentProduction

        switch envName {
        case "production":
            environment = EnvironmentProduction
        case "development":
            environment = EnvironmentDevelopment
        default:
            environment = EnvironmentStaging
        }

        let config = GatewayConfig(gatewayName: gateway,
                                   brokerConfig: preProvidedBrokers,
                                   apiEnvironment: environment,
                                   isLeprechaunActive: isLeprechaunActive,
                                   isAmoEnabled: isAmoEnabled)

        SCDoorway.shared.setup(with: config) { success, error in
            if success {
                resolve(true)
            } else {
                var responseDict: [String: Any] = [
                    "errorCode": error?.code ?? 0,
                    "errorMessage": error?.localizedDescription ?? ""
                ]

                let err = NSError(domain: error?.domain ?? "", code: error?.code ?? 0, userInfo: responseDict)
                reject("setConfigEnvironment", "Env setup failed", err)
            }
        }
    }


然后我像这样修改了我的objectiveC文件

#import <React/RCTBridgeModule.h>
#import <SCDoorway/SCDoorway.h>
#import <SCDoorway/SCDoorway-Swift.h>
#import <Loans/Loans.h>
#import <React/RCTBridge.h>

@interface RCT_EXTERN_MODULE(BigTreeDoorway, NSObject)

RCT_EXTERN_METHOD(setConfigEnvironment,
                 envName:(NSString *)envName
                 gateway:(NSString *)gateway
                 isLeprechaunActive: (BOOL *)isLeprechaunActive
                 isAmoEnabled: (BOOL *)isAmoEnabled
                 preProvidedBrokers: (NSArray *)preProvidedBrokers
                 setConfigEnvironmentWithResolver:(RCTPromiseResolveBlock)resolve
                 rejecter:(RCTPromiseRejectBlock)reject)
//many more 
@end


基本上,我将其从RCT_REMAP_METHOD改为RCT_EXTERN_METHOD,并删除了函数定义,仅删除了react本地站点中描述的名称和参数
我仍然在xcode中得到这些导入的错误-

x1c4d 1x的
但后来同样的事情发生在objectiveC文件中,所以我尝试构建我的react项目,它现在不会构建,一旦它开始构建应用程序30秒后,它给了我这个错误-

The following build commands failed:
        SwiftCompile normal arm64 Compiling\ BigTreeDoorway.swift /Users/aadityasingh/../../../node_modules/my-sdk-name/ios/BigTreeDoorway.swift (in target 'my-sdk-name' from project 'Pods')
        SwiftCompile normal arm64 /Users/aadityasingh/../../my sample app name where am trying to integrate the sdk/node_modules/my-sdk-name/ios/BigTreeDoorway.swift (in target 'my-sdk-name' from project 'Pods')
(2 failures)


我卡在这个问题上的最后两个星期了,我不明白如何目标文件与相同的进口工程,但我的swift文件未能做到这一点,请帮助,我尝试了几件事-

  • 我试着在两个示例应用程序中更改“EXCLUDED_ARCHS[sdk=iphonesimulator*]”=“arm 64 i386”,后来我也用我的sdk ios项目尝试了它,构建错误仍然存在
  • 我从我的sdk的ios文件夹中删除了xcode项目,示例应用程序仍然工作得很好,因此只剩下3个文件-桥接头,swift(swift文件为空,只有定义的类)和objc文件
  • 当我导入贷款(这是SCDoorway内部的子模块)在我的sdk的swift文件,它不会抛出任何错误和React项目的建设,但当我取消注解它的功能,涉及使用贷款类(然后我把RCT_EXTERN_METHODS相同的内部objectiveC类注解的一切),它抛出另一个错误-
The following build commands failed:
        CompileC /Users/aadityasingh/Library/Developer/Xcode/DerivedData/sample-app-name-dnrqbqkvgavrbjasjmzapzzrvjtq/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/my-sdk-name.build/Objects-normal/arm64/BigTreeDoorway-5f1feec19880e569a1329e3d7cbede9a.o /Users/aadityasingh/../new/sample app name/node_modules/sdk name/ios/BigTreeDoorway.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'my-sdk-name' from project 'Pods')
(1 failure)


请帮我一下

z31licg0

z31licg01#

当我最终弄清楚出了什么问题时,它与代码正在使用的吊舱的版本有关。
因此,如果您仍然有这些问题,我建议您:

  • 请验证Pod的兼容性,以查看是否是该问题。
  • 卸载后重新安装pod。

  • 删除派生数据。
  • 退出Xcode。
  • 请重新打开Xcode。
  • 干净的组建。
  • 构建
  • 将软件包更新到最新版本
  • 检查框架的存储库是否发布了添加了对arm64支持的版本
  • 升级到适用于您的次版本或最新版本的最高修补程序,然后验证问题是否仍然存在


请访问以下链接:

相关问题