react / react/react-native

Unknown type name 'import'

Open
#50,073 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Author Provided Repro Needs: Attention
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

AwesomeProject.zip

Description

After switching to AppDelegate.swift xcode started giving this error

Steps to reproduce
  1. Update rn version from 0.76 to 0.77/0.78
  2. Update AppDelegate.mm file to AppDelegate.swift
  3. Delete main.m and AppDelegate.h
  4. build via xcode
React Native Version

0.78.0

Affected Platforms

Build - MacOS

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.2
  CPU: (8) arm64 Apple M1
  Memory: 89.20 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.0
    path: ~/.nvm/versions/node/v18.18.0/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/local/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.0/bin/npm
  Watchman:
    version: 4.7.0
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2020.3 AI-203.7717.56.2031.7583922
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.78.0
    wanted: 0.78.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Stacktrace or Logs
AppDelegate.swift:1:1: error: unknown type name 'import'
    1 | import UIKit
AppDelegate.swift:1:13: error: expected ';' after top level declarator
    1 | import UIKit
Reproducer

git repo

Screenshots and Videos

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproducer and the AppDelegate.swift migration, then compare it with the removed AppDelegate.mm, main.m, and AppDelegate.h files. Build the project through Xcode and trace why the Swift file is being parsed as another source type; done means the React Native 0.78 project builds without the reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, react-native, swift
Domain
build-system, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.