Home > Software design >  expo run:ios - build fails - errors exist in generated swift files
expo run:ios - build fails - errors exist in generated swift files

Time:01-24

I am following this guide:

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

but when I get to the step that says to run expo run:ios it fails with the following errors:


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

I'm not sure what I'm doing wrong Xcode says the following statement

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

I have the latest expo cli installed

I tried building the project in Xcode directly, the project did build, but it won't launch on the emulator, expo opens but when connecting to the dev server the app just crashes.

I do not understand why running expo run:ios results in a build failure while building in Xcode results in a "success".

CodePudding user response:

The solution is actually kind of silly,

so the reason I was able to build successfully in Xcode vs not build successfully using expo run:ios is because I have two version of Xcode installed on this machine. one version is Xcode 12.3, and xcrun was pointed to that sdk package. I was able to fix this by running sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer double checking xcrun --show-sdk-path should now list the appropriate pathing. for good measure I deleted the pods file and the pod.lock file and rebuilt the app using expo run:ios

  • Related