Ios 如何在Swift中构建React本机包?

Ios 如何在Swift中构建React本机包?,ios,swift,xcode,react-native,Ios,Swift,Xcode,React Native,我想在Swift中构建React原生iOS PhotoEditor模块 我只是使用iOS模块创建了一个新的库,并对其进行了如下修改 现在,我只想推一个简单的UIViewController。 我遵循React Native,但在启动应用程序时出错。 我附上了结构截图、完整代码和错误日志 我真的不知道下面的错误是什么意思 ld:未找到架构arm64的符号 另外,如何清除此类警告 ld:警告:找不到自动链接库“swiftUIKit” 有人能告诉我如何为React Native编写Swift iOS

我想在Swift中构建React原生iOS PhotoEditor模块

我只是使用iOS模块创建了一个新的库,并对其进行了如下修改

现在,我只想推一个简单的UIViewController。 我遵循React Native,但在启动应用程序时出错。 我附上了结构截图、完整代码和错误日志

我真的不知道下面的错误是什么意思

ld:未找到架构arm64的符号

另外,如何清除此类警告

ld:警告:找不到自动链接库“swiftUIKit”

有人能告诉我如何为React Native编写Swift iOS库吗?我挣扎了几天,但运气不好


我将感谢任何帮助!谢谢。

您是否在“将二进制文件与库链接”中链接了静态库(.a文件)??当然,这不是链接错误。您的库是否依赖于其他框架?不,启动UIViewController是一个简单的库。您能否在生成设置中验证框架搜索路径和标头搜索路径中的内容?
//  RNPhotoEditor.swift
//  RNPhotoEditor
//
//  Created by Gang on 2/13/19.
//  Copyright © 2019 Facebook. All rights reserved.
//

import Foundation
import UIKit

@objc(RNPhotoEditor)
class RNPhotoEditor: NSObject {

    @objc func Edit(props: NSDictionary, onDone: RCTResponseSenderBlock, onCancel: RCTResponseSenderBlock) -> Void {
        let editorVC = PhotoEditorViewController()
        getRootVC().present(editorVC, animated: true, completion: nil)
    }

    func getRootVC() -> UIViewController {
        var root = UIApplication.shared.keyWindow?.rootViewController

        while root?.presentedViewController != nil {
            root = root?.presentedViewController
        }

        return root!
    }
}


//
//  RNPhotoEditorBridge.m
//  RNPhotoEditor
//
//  Created by Gang on 2/13/19.
//  Copyright © 2019 Facebook. All rights reserved.
//

#import <React/RCTBridgeModule.h>

@interface RCT_EXTERN_MODULE(RNPhotoEditor, NSObject)

RCT_EXTERN_METHOD(Edit:(nonnull NSDictionary *)props onDone:(RCTResponseSenderBlock)onDone onCancel:(RCTResponseSenderBlock)onCancel)

@end


//
//  RNPhotoEditor-Bridging-Header.h
//  RNPhotoEditor-Bridging-Header
//
//  Created by Gang on 2/13/19.
//  Copyright © 2019 Facebook. All rights reserved.
//  Use this file to import your target's public headers that you would like to expose to Swift.
//

#import <React/RCTBridgeModule.h>
ld: warning: directory not found for option '-L/Users/gang/Library/Developer/Xcode/DerivedData/app-ezczldbbkpyqcxaeyxheyjdtqbth/Build/Products/Debug-iphoneos/React'
ld: warning: object file (/Users/gang/Library/Developer/Xcode/DerivedData/app-ezczldbbkpyqcxaeyxheyjdtqbth/Build/Products/Debug-iphoneos/libLRDRCTSimpleToast.a(UIView+Toast.o)) was built for newer iOS version (9.3) than being linked (9.0)
ld: warning: object file (/Users/gang/Library/Developer/Xcode/DerivedData/app-ezczldbbkpyqcxaeyxheyjdtqbth/Build/Products/Debug-iphoneos/libLRDRCTSimpleToast.a(LRDRCTSimpleToast.o)) was built for newer iOS version (9.3) than being linked (9.0)
ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find auto-linked library 'swiftFoundation'
ld: warning: Could not find auto-linked library 'swiftMetal'
ld: warning: Could not find auto-linked library 'swiftDarwin'
ld: warning: Could not find auto-linked library 'swiftUIKit'
ld: warning: Could not find auto-linked library 'swiftObjectiveC'
ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find auto-linked library 'swiftDispatch'
ld: warning: Could not find auto-linked library 'swiftCoreImage'
ld: warning: Could not find auto-linked library 'swiftQuartzCore'
ld: warning: Could not find auto-linked library 'swiftCore'
ld: warning: Could not find auto-linked library 'swiftSwiftOnoneSupport'
Undefined symbols for architecture arm64:
  "value witness table for Builtin.UnknownObject", referenced from:
      full type metadata for RNPhotoEditor.PhotoEditorViewController in libRNPhotoEditor.a(PhotoEditorViewController.o)
      full type metadata for RNPhotoEditor.RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
  "(extension in Foundation):Swift.String._bridgeToObjectiveC() -> __C.NSString", referenced from:
      RNPhotoEditor.PhotoEditorViewController.init(nibName: Swift.String?, bundle: __C.NSBundle?) -> RNPhotoEditor.PhotoEditorViewController in libRNPhotoEditor.a(PhotoEditorViewController.o)
  "static (extension in Foundation):Swift.String._unconditionallyBridgeFromObjectiveC(__C.NSString?) -> Swift.String", referenced from:
      @objc RNPhotoEditor.PhotoEditorViewController.init(nibName: Swift.String?, bundle: __C.NSBundle?) -> RNPhotoEditor.PhotoEditorViewController in libRNPhotoEditor.a(PhotoEditorViewController.o)
  "(extension in Foundation):Swift.Array._bridgeToObjectiveC() -> __C.NSArray", referenced from:
      reabstraction thunk helper from @callee_unowned @convention(block) (@unowned __C.NSArray?) -> () to @escaping @callee_guaranteed (@guaranteed [Any]?) -> () in libRNPhotoEditor.a(RNPhotoEditor.o)
  "Swift._fatalErrorMessage(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never", referenced from:
      RNPhotoEditor.RNPhotoEditor.getRootVC() -> __C.UIViewController in libRNPhotoEditor.a(RNPhotoEditor.o)
  "type metadata for Any", referenced from:
      reabstraction thunk helper from @callee_unowned @convention(block) (@unowned __C.NSArray?) -> () to @escaping @callee_guaranteed (@guaranteed [Any]?) -> () in libRNPhotoEditor.a(RNPhotoEditor.o)
  "__swift_FORCE_LOAD_$_swiftCoreFoundation", referenced from:
      __swift_FORCE_LOAD_$_swiftCoreFoundation_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftCoreFoundation_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCoreFoundation_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftCoreGraphics", referenced from:
      __swift_FORCE_LOAD_$_swiftCoreGraphics_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftCoreGraphics_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCoreGraphics_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftCoreImage", referenced from:
      __swift_FORCE_LOAD_$_swiftCoreImage_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftCoreImage_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCoreImage_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftDarwin", referenced from:
      __swift_FORCE_LOAD_$_swiftDarwin_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftDarwin_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftDarwin_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftDispatch", referenced from:
      __swift_FORCE_LOAD_$_swiftDispatch_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftDispatch_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftDispatch_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftFoundation", referenced from:
      __swift_FORCE_LOAD_$_swiftFoundation_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftFoundation_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftFoundation_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftMetal", referenced from:
      __swift_FORCE_LOAD_$_swiftMetal_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftMetal_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftMetal_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftObjectiveC", referenced from:
      __swift_FORCE_LOAD_$_swiftObjectiveC_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftObjectiveC_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftObjectiveC_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftQuartzCore", referenced from:
      __swift_FORCE_LOAD_$_swiftQuartzCore_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftQuartzCore_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftQuartzCore_$_RNPhotoEditor)
  "__swift_FORCE_LOAD_$_swiftUIKit", referenced from:
      __swift_FORCE_LOAD_$_swiftUIKit_$_RNPhotoEditor in libRNPhotoEditor.a(PhotoEditorViewController.o)
      __swift_FORCE_LOAD_$_swiftUIKit_$_RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftUIKit_$_RNPhotoEditor)
  "_swift_allocObject", referenced from:
      @objc RNPhotoEditor.RNPhotoEditor.Edit(props: __C.NSDictionary, onDone: ([Any]?) -> (), onCancel: ([Any]?) -> ()) -> () in libRNPhotoEditor.a(RNPhotoEditor.o)
  "_swift_bridgeObjectRelease", referenced from:
      RNPhotoEditor.PhotoEditorViewController.init(nibName: Swift.String?, bundle: __C.NSBundle?) -> RNPhotoEditor.PhotoEditorViewController in libRNPhotoEditor.a(PhotoEditorViewController.o)
      outlined consume of Swift.String? in libRNPhotoEditor.a(PhotoEditorViewController.o)
      reabstraction thunk helper from @callee_unowned @convention(block) (@unowned __C.NSArray?) -> () to @escaping @callee_guaranteed (@guaranteed [Any]?) -> () in libRNPhotoEditor.a(RNPhotoEditor.o)
  "_swift_bridgeObjectRetain", referenced from:
      outlined copy of Swift.String? in libRNPhotoEditor.a(PhotoEditorViewController.o)
      reabstraction thunk helper from @callee_unowned @convention(block) (@unowned __C.NSArray?) -> () to @escaping @callee_guaranteed (@guaranteed [Any]?) -> () in libRNPhotoEditor.a(RNPhotoEditor.o)
  "_swift_deallocObject", referenced from:
      l_objectdestroy in libRNPhotoEditor.a(RNPhotoEditor.o)
      l_objectdestroy.2 in libRNPhotoEditor.a(RNPhotoEditor.o)
  "_swift_getInitializedObjCClass", referenced from:
      type metadata accessor for RNPhotoEditor.PhotoEditorViewController in libRNPhotoEditor.a(PhotoEditorViewController.o)
      RNPhotoEditor.RNPhotoEditor.getRootVC() -> __C.UIViewController in libRNPhotoEditor.a(RNPhotoEditor.o)
      type metadata accessor for RNPhotoEditor.RNPhotoEditor in libRNPhotoEditor.a(RNPhotoEditor.o)
  "_swift_getObjCClassFromMetadata", referenced from:
      __C.UIViewController.__allocating_init() -> __C.UIViewController in libRNPhotoEditor.a(RNPhotoEditor.o)
  "_swift_isaMask", referenced from:
      RNPhotoEditor.RNPhotoEditor.Edit(props: __C.NSDictionary, onDone: ([Any]?) -> (), onCancel: ([Any]?) -> ()) -> () in libRNPhotoEditor.a(RNPhotoEditor.o)
  "_swift_release", referenced from:
      @objc RNPhotoEditor.RNPhotoEditor.Edit(props: __C.NSDictionary, onDone: ([Any]?) -> (), onCancel: ([Any]?) -> ()) -> () in libRNPhotoEditor.a(RNPhotoEditor.o)
  "_swift_retain", referenced from:
      @objc RNPhotoEditor.RNPhotoEditor.Edit(props: __C.NSDictionary, onDone: ([Any]?) -> (), onCancel: ([Any]?) -> ()) -> () in libRNPhotoEditor.a(RNPhotoEditor.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)