expo run:ios - build fails -生成的swift文件中存在错误



我遵循这个指南:

https://www.mongodb.com/docs/realm/sdk/react-native/bootstrap-with-expo/

但是当我到达说要运行expo run:ios的步骤时,它失败了,出现以下错误:


› Skipping dev server
› Planning build
› Executing react-native Pods/FBReactNativeSpec » [CP-User] Generate Specs
❌  (node_modules/expo-modules-core/ios/Swift/Functions/AsyncFunctionComponent.swift:94:17)
92 |     }
93 | 
> 94 |     let queue = queue ?? defaultQueue
|                 ^ variable used within its own initial value
95 | 
96 |     queue.async { [body, name] in
97 |       let returnedValue: ReturnType?

❌  (node_modules/expo-modules-core/ios/Swift/Views/ConcreteViewProp.swift:42:52)
40 |     }
41 |     guard let value = try propType.cast(value) as? PropType else {
> 42 |       throw Conversions.CastingException<PropType>(value)
|                                                    ^ variable declared in 'guard' condition is not usable in its body
43 |     }
44 |     setter(view, value)
45 |   }

❌  (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:8:33)
6 |  */
7 | public final class ConcurrentFunctionDefinition<Args, FirstArgType, ReturnType>: AnyFunction {
>  8 |   typealias ClosureType = (Args) async throws -> ReturnType
|                                 ^ consecutive declarations on a line must be separated by ';'
9 | 
10 |   let body: ClosureType
11 | 

❌  (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:8:34)
6 |  */
7 | public final class ConcurrentFunctionDefinition<Args, FirstArgType, ReturnType>: AnyFunction {
>  8 |   typealias ClosureType = (Args) async throws -> ReturnType
|                                  ^ expected declaration
9 | 
10 |   let body: ClosureType
11 | 

❌  (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:56:36)
54 |         // swiftlint:disable force_cast
55 |         let argumentsTuple = try Conversions.toTuple(arguments) as! Args
> 56 |         let returnValue = try await body(argumentsTuple)
|                                    ^ consecutive statements on a line must be separated by ';'
57 | 
58 |         result = .success(returnValue)
59 |       } catch let error as Exception {

❌  (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:94:49)
92 | public func AsyncFunction<R>(
93 |   _ name: String,
> 94 |   @_implicitSelfCapture _ closure: @escaping () async throws -> R
|                                                 ^ expected ',' separator
95 | ) -> ConcurrentFunctionDefinition<(), Void, R> {
96 |   return ConcurrentFunctionDefinition(
97 |     name,

❌  (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:94:62)
92 | public func AsyncFunction<R>(
93 |   _ name: String,
> 94 |   @_implicitSelfCapture _ closure: @escaping () async throws -> R
|                                                              ^ expected ':' following argument label and parameter name
95 | ) -> ConcurrentFunctionDefinition<(), Void, R> {
96 |   return ConcurrentFunctionDefinition(
97 |     name,

❌  (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:109:51)
107 | public func AsyncFunction<R, A0: AnyArgument>(
108 |   _ name: String,
> 109 |   @_implicitSelfCapture _ closure: @escaping (A0) async throws -> R
|                                                   ^ expected ',' separator
110 | ) -> ConcurrentFunctionDefinition<(A0), A0, R> {
111 |   return ConcurrentFunctionDefinition(
112 |     name,

❌  (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:109:64)
107 | public func AsyncFunction<R, A0: AnyArgument>(
108 |   _ name: String,
> 109 |   @_implicitSelfCapture _ closure: @escaping (A0) async throws -> R
|                                                                ^ expected ':' following argument label and parameter name
110 | ) -> ConcurrentFunctionDefinition<(A0), A0, R> {
111 |   return ConcurrentFunctionDefinition(
112 |     name,

❌  (node_modules/expo-modules-core/ios/Swift/Functions/ConcurrentFunctionDefinition.swift:124:55)
122 | public func AsyncFunction<R, A0: AnyArgument, A1: AnyArgument>(
123 |   _ name: String,
> 124 |   @_implicitSelfCapture _ closure: @escaping (A0, A1) async throws -> R
|                                                       ^ expected ',' separator
125 | ) -> ConcurrentFunctionDefinition<(A0, A1), A0, R> {
126 |   return ConcurrentFunctionDefinition(
127 |     name,

... Hundreds of similar errors later...

❌  (node_modules/expo-modules-core/ios/Swift/Views/ViewDefinition.swift:68:3)
66 | public func View<ViewType: UIView>(
67 |   _ viewType: ViewType.Type,
> 68 |   @ViewDefinition<ViewType>.ElementsBuilder _ elements: @escaping () -> [AnyDefinition]
|   ^ struct 'ElementsBuilder' cannot be used as an attribute
69 | ) -> ViewDefinition<ViewType> {
70 |   return ViewDefinition(viewType, elements: elements())
71 | }

❌  (node_modules/expo-modules-core/ios/Swift/Views/ViewManagerDefinitionComponents.swift:19:3)
17 | public func Prop<ViewType: UIView, PropType: AnyArgument>(
18 |   _ name: String,
> 19 |   @_implicitSelfCapture _ setter: @escaping (ViewType, PropType) -> Void
|   ^ unknown attribute '_implicitSelfCapture'
20 | ) -> ConcreteViewProp<ViewType, PropType> {
21 |   return ConcreteViewProp(
22 |     name: name,

❌  (node_modules/expo-modules-core/ios/Swift/Views/ViewManagerDefinitionComponents.swift:34:3)
32 |  */
33 | public func OnViewDidUpdateProps<ViewType: UIView>(
> 34 |   @_implicitSelfCapture _ closure: @escaping (_ view: ViewType) -> Void
|   ^ unknown attribute '_implicitSelfCapture'
35 | ) -> ViewLifecycleMethod<ViewType> {
36 |   return ViewLifecycleMethod(type: .didUpdateProps, closure: closure)
37 | }
› Compiling react-native Pods/React-RCTVibration » RCTVibrationPlugins.mm
› Compiling react-native Pods/React-RCTVibration » RCTVibration.mm
› Compiling react-native Pods/React-RCTVibration » React-RCTVibration-dummy.m
› Compiling react-native Pods/React-RCTSettings » RCTSettingsManager.mm
› Compiling react-native Pods/React-RCTSettings » React-RCTSettings-dummy.m
› Compiling react-native Pods/React-RCTSettings » RCTSettingsPlugins.mm
› Compiling react-native Pods/React-RCTNetwork » React-RCTNetwork-dummy.m
› 104 error(s), and 0 warning(s)

我不知道我做错了什么Xcode说下面的语句

CommandError: Failed to build iOS project. "xcodebuild" exited with error code 65.

我已经安装了最新的expo cli

我尝试直接在Xcode中构建项目,项目确实构建了,但它不会在模拟器上启动,博览会打开,但当连接到开发服务器时,应用程序只是崩溃。

我不明白为什么运行expo run:ios会导致构建失败,而在Xcode中构建会导致"成功"。

这个解决方案其实有点傻,

所以我能够在Xcode中成功构建而不是使用expo run:ios成功构建的原因是因为我在这台机器上安装了两个版本的Xcode。一个版本是Xcode 12.3,xcrun指向那个sdk包。我能够通过运行sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer来修复这个问题,双重检查xcrun --show-sdk-path现在应该列出适当的路径。另外,我还删除了pods文件和pod。并使用expo run:ios

重新构建应用程序