5

Trying to run XCTest with my CocoaPods set up using SDWebImage, and I can only see this error as below. Any suggestions?

:0: error: module name "" is not a valid identifier Command /Applications/Xcode8.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

But as soon as I edit the scheme and uncheck the test inside the builds, I am able to run the app on simulator but can't run the tests.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Max
  • 5,380
  • 6
  • 42
  • 66

4 Answers4

13

Always make sure all your test targets has the PRODUCT_MODULE_NAME set to $(PRODUCT_NAME)

Alexander
  • 59,041
  • 12
  • 98
  • 151
Max
  • 5,380
  • 6
  • 42
  • 66
3

I was able to fix the problem by following the steps below while migrating from Xcode 11 to 11.2:

  1. Select the target
  2. Go to Build Settings.
  3. Then scroll down to Packaging
  4. Product module name
  5. If you have spaces in your module name, replace them with underscores
nayan dhabarde
  • 1,734
  • 1
  • 19
  • 38
0

In this case your need to $(PRODUCT_NAME:c99extidentifier) for PRODUCT_MODULE_NAME.

c99extidentifier allows using dashes in the PRODUCT_NAME.

Also this is the default project value which can be inherited in each target.

malex
  • 9,874
  • 3
  • 56
  • 77
0
  1. Locate the macos folder in your Flutter project.
  2. Open the Runner.xcodeproj project file within the macos folder using Xcode.
  3. In Xcode, select the "Runner" project in the project navigator on the left-hand side.
  4. Go to the "Build Settings" tab for the "Runner" target.
  5. Look for the setting named "Product Module Name" under the "Packaging" section. This setting determines the module name for your macOS app.
  6. Verify that the module name is a valid identifier. It should consist of alphanumeric characters and underscores, and it must start with a letter.
  7. If the module name is empty or invalid, provide a valid identifier. You can use the default value "Runner" or choose a different name that suits your project.
  8. Once you've updated the module name, clean your project by selecting "Product" from the Xcode menu, then choose "Clean Build Folder".
  9. Try building and running your macOS app again to see if the error has been resolved.
Ayub Alam
  • 1
  • 2