gpt4 book ai didi

ios - 如何在Swift中构建React Native包?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:59:44 25 4
gpt4 key购买 nike

我想在swift中构建react本地ios photoeditor模块。
我只是使用react-native-create-library创建了一个新的库,并像这样修改了ios模块。
现在,我只想推一个简单的uiviewcontroller。
我跟踪了react native的Native Modules Guideline,但在启动应用程序时出错。
我附上了结构的截图,完整的代码和错误日志。
Screenshot

//  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)

我真的不知道下面的错误是什么意思。
ld: symbol(s) not found for architecture arm64
另外,我怎样才能清除这种警告?
ld: warning: Could not find auto-linked library 'swiftUIKit'
有人能告诉我如何为react native编写swift ios库吗?我挣扎了几天,但没有运气。
我很感激你的帮助!谢谢。

最佳答案

您可以使用myhttps://github.com/iyegoroff/make-react-native-packagecli工具构建带有swift/kotlin/typescript的react本机包。

关于ios - 如何在Swift中构建React Native包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54708295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com