Errors and Solutions - salmdoo/NearRestaurant-FrontEnd-iOS GitHub Wiki

Undefined symbols for architecture arm64: "___llvm_profile_runtime"

Issue

inker command failed with exit code 1 (use -v to see invocation)

----------------------------------------

LinkDylibError: Failed to build BigCircle.swift

Linking failed: linker command failed with exit code 1 (use -v to see invocation)

ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator'
Undefined symbols for architecture arm64:
  "___llvm_profile_runtime", referenced from:
      ___llvm_profile_runtime_user in Pods_NearRestaurant(Pods-NearRestaurant-dummy.o)
     (maybe you meant: ___llvm_profile_runtime_user)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution To solve this problem, you may want to add -fprofile-instr-generate to Build Settings > Linking > Other Linker Flags.

This flag is an option used for coverage output. With this setting in the environment, we succeeded in enabling the preview while enabling the coverage.

References: https://stackoverflow.com/questions/58127940/undefined-symbols-llvm-profile-runtime


Can't ignore UserInterfaceState.xcuserstate

Issue Using Git for project code management. The "UserInterfaceState.xcuserstate" is explicitly added, but Git it did not ignore it.

Solution

  • Git is probably already tracking the file.
  • Use this, replacing [project] and [username] with your info:
git rm --cached [project].xcodeproj/project.xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate
git commit -m "Removed file that shouldn't be tracked"
  • Commit the code changed

References: https://stackoverflow.com/questions/6564257/cant-ignore-userinterfacestate-xcuserstate)


Check CocoaPods Dependencies

Solution

  1. Run pod deintegrate in your project's directory to remove all Cocoapods-related configurations.
  2. Delete the Podfile.lock file.
  3. Run pod install to install the dependencies again.

Undefined symbols for architecture arm64: "NoBuildableEntriesError: Active scheme does not build this file"

Issue NoBuildableEntriesError: Active scheme does not build this file

Select a scheme that builds a target which contains the current file, or add this file to a target that is built by the current scheme.

Undefined symbols for architecture arm64: "NoActiveSchemeError: No selected scheme Select a scheme from the scheme picker in the toolbar"

Issue NoActiveSchemeError: No selected scheme Select a scheme from the scheme picker in the toolbar

In Preview class: Instance member 'mapRegion' cannot be used on type 'MapScreen_Previews

Root cause: In SwiftUI, static previews are meant to create instances of the view for preview purposes, and you cannot access instance properties within the static context

Solution

struct MapScreen_Previews: PreviewProvider {
    static let mapRegion = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.5, longitude: -0.12), span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2))
    
    static var previews: some View {
        MapScreen(longitude: 51.5, latitude: -0.12, name: "London", mapRegion: mapRegion)
    }
}

When building the project, it has an error message. It is "Target 'NearRestaurant' (project 'NearRestaurant') has Swift tasks not blocking downstream targets."

Multiple commands produce '...NearRestaurant.build/Objects-normal/arm64/RestaurantListViewModel.stringsdata'

Issue It is because there are more than one file which have the same name as RestaurantListViewModel

Solution Step 1. Remove the duplicated files

  1. Choose the Project name
  2. Choose the target ( here it is NearRestaurant)
  3. In Build Phases, search RestaurantListViewModel, it should have 2 or more files named RestaurantListViewModel
  4. Only keep a file and delete the rest one

Step 2. Add the new files to Compile Sources

  1. Click + in Compile Sources section
  2. Add the new file to the target
  3. Build and run, the issue should be fixed