Flutter导入flutter_video_compress遇到的问题

flutter_video_compressFlutter的一个视频压缩插件,用swift实现的,在导入过程中,出现了不少问题,在这里记录起来。

报错1:Undefined symbol: OBJC_CLASS$_BMKLocationManager

根据import插件的步骤,在profile文件设置 use_frameworks! ,Xcode build 之后出现这个报错:

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_BMKLocationManager", referenced from:
      objc-class-ref in FlutterBaiduMapPlugin.o
  "_OBJC_CLASS_$_BMKLocationAuth", referenced from:
      objc-class-ref in FlutterBaiduMapPlugin.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Showing All Messages
:-1: Undefined symbol: _OBJC_CLASS_$_BMKLocationManager

Showing All Messages
:-1: Undefined symbol: _OBJC_CLASS_$_BMKLocationAuth

BMKLocationManager 是百度地图定位插件,一开始以为是这个插件不支持swift,找了很久原因,后面尝试不导入 flutter_video_compress,开启 use_frameworks!,百度定位的插件也没有报错,问题还是出在flutter_video_compress 插件上。

解决方法:有时候 pod install ,旧插件没有完全删除,会出现很多奇怪问题,彻底删除 pod 并重新 install是个好方法:

  • 删除iOS目录下 PodsApp名.xcworkspace目录 和 Podfile.lock文件:
    image.png
  • ios路径下执行:
pod install --verbose --no-repo-update
报错2:Regift.swift:251:45: Missing argument label 'preferredTimescale

确定重新 pod install 后,Xcode build 的时候又出现新的问题:

项目路径/ios/Pods/Regift/Regift/Regift.swift:251:45: Missing argument label 'preferredTimescale:' in call

有几个地方的代码出现报错,双击报错的地方,下面都有个 fix 按钮,点击之后代码的报错消失。

方法来源:https://github.com/flutter/flutter/issues/37447#issuecomment-518478400

报错3:Undefined symbol: protocol descriptor for Swift.Error

继续 build ,出现一大堆 swift 报错,吓了我一跳,还以为
上面的处理有问题,继续找解决方法:

Showing All Messages
:-1: Could not find auto-linked library 'swiftCoreFoundation'

:-1: Could not find auto-linked library 'swiftSwiftOnoneSupport'

:-1: Could not find auto-linked library 'swiftCore'

:-1: Could not find auto-linked library 'swiftQuartzCore'

:-1: Could not find auto-linked library 'swiftCoreGraphics'

:-1: Could not find auto-linked library 'swiftUIKit'

:-1: Could not find auto-linked library 'swiftDarwin'

:-1: Could not find auto-linked library 'swiftFoundation'

:-1: Could not find auto-linked library 'swiftsimd'

:-1: Could not find auto-linked library 'swiftObjectiveC'

:-1: Could not find auto-linked library 'swiftMetal'

:-1: Could not find auto-linked library 'swiftDispatch'

:-1: Could not find auto-linked library 'swiftCoreMedia'

:-1: Could not find auto-linked library 'swiftAVFoundation'

:-1: Could not find auto-linked library 'swiftCoreImage'

:-1: Could not find auto-linked library 'swiftCoreAudio'

:-1: Undefined symbol: protocol conformance descriptor for Swift.Int : Swift._ObjectiveCBridgeable in Foundation

:-1: Undefined symbol: protocol descriptor for Swift.Error

:-1: Undefined symbol: protocol conformance descriptor for Swift.Int : Swift.BinaryInteger in Swift

:-1: Undefined symbol: protocol conformance descriptor for Swift.Int32 : Swift.SignedInteger in Swift

:-1: Undefined symbol: protocol conformance descriptor for Swift.Int32 : Swift.FixedWidthInteger in Swift

:-1: Undefined symbol: protocol conformance descriptor for CoreGraphics.CGFloat : Swift.SignedNumeric in CoreGraphics

:-1: Undefined symbol: protocol conformance descriptor for CoreGraphics.CGFloat : Swift.Comparable in CoreGraphics

:-1: Undefined symbol: _swift_getTupleTypeMetadata2

:-1: Undefined symbol: Swift.Float.init(Swift.Float) -> Swift.Float

:-1: Undefined symbol: _swift_projectBox

:-1: Undefined symbol: Foundation.URL.pathExtension.getter : Swift.String

:-1: Undefined symbol: (extension in Foundation):__C.NSNumber.init(integerLiteral: Swift.Int) -> __C.NSNumber

:-1: Undefined symbol: static (extension in ObjectiveC):__C.NSObject.== infix(__C.NSObject, __C.NSObject) -> Swift.Bool

:-1: Undefined symbol: type metadata for Swift.Float

:-1: Undefined symbol: protocol witness table for Swift.Float : Swift.TextOutputStreamable in Swift

:-1: Undefined symbol: Swift.Dictionary.init(dictionaryLiteral: (A, B)...) -> [A : B]

:-1: Undefined symbol: Swift.print(_: Any..., separator: Swift.String, terminator: Swift.String) -> ()

:-1: Undefined symbol: type metadata for Foundation.Data

:-1: Undefined symbol: type metadata for Swift.Double

:-1: Undefined symbol: Swift.Dictionary.subscript.getter : (A) -> B?

:-1: Undefined symbol: static Swift.String.== infix(Swift.String, Swift.String) -> Swift.Bool

:-1: Undefined symbol: type metadata for Swift.Bool

:-1: Undefined symbol: Swift.String.init<A where A: Swift.CustomStringConvertible, A: Swift.TextOutputStreamable>(describing: A) -> Swift.String

:-1: Undefined symbol: _swift_beginAccess

:-1: Undefined symbol: _swift_deallocObject

:-1: Undefined symbol: value witness table for Builtin.Int64

:-1: Undefined symbol: protocol descriptor for Swift.Equatable

:-1: Undefined symbol: method descriptor for static Swift.Equatable.== infix(A, A) -> Swift.Bool

:-1: Undefined symbol: protocol descriptor for Swift.ExpressibleByArrayLiteral

:-1: Undefined symbol: type metadata for Swift.Int32

:-1: Undefined symbol: associated type descriptor for ArrayLiteralElement

:-1: Undefined symbol: base conformance descriptor for Swift.OptionSet: Swift.SetAlgebra

:-1: Undefined symbol: method descriptor for Swift.OptionSet.init(rawValue: A.RawValue) -> A

:-1: Undefined symbol: method descriptor for Swift.RawRepresentable.rawValue.getter : A.RawValue

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.init() -> A

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.union(__owned A) -> A

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.intersection(A) -> A

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.insert(__owned A.Element) -> (inserted: Swift.Bool, memberAfterInsert: A.Element)

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.update(with: __owned A.Element) -> A.Element?

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.formIntersection(A) -> ()

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.subtracting(A) -> A

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.isDisjoint(with: A) -> Swift.Bool

:-1: Undefined symbol: _swift_allocBox

:-1: Undefined symbol: _swift_getObjectType

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.isSuperset(of: A) -> Swift.Bool

:-1: Undefined symbol: protocol witness table for Swift.Float : Swift.CustomStringConvertible in Swift

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.isEmpty.getter : Swift.Bool

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.init<A where A1: Swift.Sequence, A.Element == A1.Element>(__owned A1) -> A

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.subtract(A) -> ()

:-1: Undefined symbol: type metadata accessor for Swift.Dictionary

:-1: Undefined symbol: (extension in CoreMedia):__C.CMTime.seconds.getter : Swift.Double

:-1: Undefined symbol: base conformance descriptor for Swift.SetAlgebra: Swift.Equatable

:-1: Undefined symbol: _swift_unknownObjectRetain

:-1: Undefined symbol: type metadata for Swift.AnyObject

:-1: Undefined symbol: _swift_dynamicCast

:-1: Undefined symbol: Swift._forceBridgeFromObjectiveC_bridgeable<A where A: Swift._ObjectiveCBridgeable>(A._ObjectiveCType, A.Type) -> A

:-1: Undefined symbol: (extension in Swift):Swift.Collection< where A.Iterator == Swift.IndexingIterator<A>>.makeIterator() -> Swift.IndexingIterator<A>

:-1: Undefined symbol: (extension in Foundation):Swift.StringProtocol.replacingOccurrences<A, B where A1: Swift.StringProtocol, B1: Swift.StringProtocol>(of: A1, with: B1, options: __C.NSStringCompareOptions, range: Swift.Range<Swift.String.Index>?) -> Swift.String

:-1: Undefined symbol: protocol conformance descriptor for Swift.UInt : Swift.FixedWidthInteger in Swift

:-1: Undefined symbol: Foundation.Data.write(to: Foundation.URL, options: __C.NSDataWritingOptions) throws -> ()

:-1: Undefined symbol: method descriptor for Swift.SetAlgebra.formUnion(__owned A) -> ()

:-1: Undefined symbol: (extension in Swift):Swift.SetAlgebra.subtract(A) -> ()

:-1: Undefined symbol: value witness table for Builtin.UnknownObject

:-1: Undefined symbol: (extension in Swift):Swift.SetAlgebra.subtracting(A) -> A

:-1: Undefined symbol: (extension in Swift):Swift.OptionSet< where A.RawValue: Swift.FixedWidthInteger>.formSymmetricDifference(A) -> ()

:-1: Undefined symbol: (extension in Swift):Swift.OptionSet< where A == A.Element>.update(with: A) -> A?

:-1: Undefined symbol: Foundation.Data._bridgeToObjectiveC() -> __C.NSData

:-1: Undefined symbol: (extension in Swift):Swift.OptionSet.union(A) -> A

:-1: Undefined symbol: Foundation.URL.absoluteString.getter : Swift.String

:-1: Undefined symbol: associated type descriptor for Element

:-1: Undefined symbol: type metadata accessor for Swift.Array

:-1: Undefined symbol: _swift_errorRelease

:-1: Undefined symbol: _swift_release

:-1: Undefined symbol: _swift_getForeignTypeMetadata

:-1: Undefined symbol: Swift.Double.init(Swift.Double) -> Swift.Double

:-1: Undefined symbol: type metadata for Swift.Int

:-1: Undefined symbol: type metadata for Any

:-1: Undefined symbol: type metadata accessor for Swift.Optional

:-1: Undefined symbol: _swift_retain

:-1: Undefined symbol: Swift._allocateUninitializedArray<A>(Builtin.Word) -> ([A], Builtin.RawPointer)

:-1: Undefined symbol: protocol witness table for Swift.String : Swift.Hashable in Swift

:-1: Undefined symbol: static Swift.Array._allocateBufferUninitialized(minimumCapacity: Swift.Int) -> Swift._ArrayBuffer<A>

:-1: Undefined symbol: (extension in Swift):Swift.SignedInteger< where A: Swift.FixedWidthInteger>.init<A where A1: Swift.BinaryInteger>(A1) -> A

:-1: Undefined symbol: (extension in Swift):Swift.OptionSet< where A.RawValue: Swift.FixedWidthInteger>.formUnion(A) -> ()

:-1: Undefined symbol: (extension in Swift):Swift.OptionSet< where A.RawValue: Swift.FixedWidthInteger>.init() -> A

:-1: Undefined symbol: type metadata for CoreGraphics.CGFloat

:-1: Undefined symbol: Swift.== infix<A where A: Swift.RawRepresentable, A.RawValue: Swift.Equatable>(A, A) -> Swift.Bool

:-1: Undefined symbol: (extension in Swift):Swift.SetAlgebra< where A.ArrayLiteralElement == A.Element>.init(arrayLiteral: A.ArrayLiteralElement...) -> A

:-1: Undefined symbol: (extension in Foundation):Swift.String.Encoding.rawValue.getter : Swift.UInt

:-1: Undefined symbol: Foundation.URL.init(fileURLWithPath: __shared Swift.String) -> Foundation.URL

:-1: Undefined symbol: protocol conformance descriptor for [A] : Swift.RangeReplaceableCollection in Swift

:-1: Undefined symbol: (extension in Foundation):Swift.StringProtocol.components<A where A1: Swift.StringProtocol>(separatedBy: A1) -> [Swift.String]

:-1: Undefined symbol: Swift.abs<A where A: Swift.Comparable, A: Swift.SignedNumeric>(A) -> A

:-1: Undefined symbol: (extension in Swift):Swift.OptionSet< where A == A.Element>.remove(A) -> A?

:-1: Undefined symbol: generic specialization <Swift.String> of Swift.Array.count.getter : Swift.Int

:-1: Undefined symbol: (extension in Swift):Swift.RangeReplaceableCollection< where A: Swift.BidirectionalCollection>.removeLast() -> A.Element

:-1: Undefined symbol: type metadata for Swift.Int64

:-1: Undefined symbol: (extension in Swift):Swift.SetAlgebra.init<A where A1: Swift.Sequence, A.Element == A1.Element>(__owned A1) -> A

:-1: Undefined symbol: _swift_getExistentialTypeMetadata

:-1: Undefined symbol: type metadata accessor for Swift.IndexingIterator

:-1: (86 additional undefined symbols are shown in the transcript

解决办法也有点特别,但确实有效:

  • 1、在Xcode打开 ios/App名.xcodeproj;(这个目录跟 RunnerPods 在同一级目录下,不能同时打开,我是关闭工程,再用Xcode 打开新项目)
  • 2、右键项目名(我的是 Runner),新建一个swift 文件,文件名随意,也不需要写内容, Xcode 提示 Create Bridging Header 的话点击(我的没有提示,应该是之前已经新建过了);
  • 3、不要删除新建的.swift文件,重新 build 项目,就成功了。

方法来源:https://github.com/mxcl/PromiseKit/issues/1059#issuecomment-493925940

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,088评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,715评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,361评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,099评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 60,987评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,063评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,486评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,175评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,440评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,518评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,305评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,190评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,550评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,880评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,152评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,451评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,637评论 2 335

推荐阅读更多精彩内容