web-dev-qa-db-fra.com

Erreur Xcode: "_main", référencée depuis: entrée implicite/début pour l'exécutable principal

Je reçois l'erreur suivante, qui semble provenir de quelque chose dans le bas qui concerne "_main". 

Ld /Users/jianglin/Library/Developer/Xcode/DerivedData/TownHall_iPhone-bdlgipvgaapgjhglhromfvcubbxz/Build/Products/Debug-iphonesimulator/TownHall\ iPhone.app/TownHall\ iPhone normal i386
    cd "/Users/jianglin/Desktop/TownHall iPhone"
    export IPHONEOS_DEPLOYMENT_TARGET=8.1
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -L/Users/jianglin/Library/Developer/Xcode/DerivedData/TownHall_iPhone-bdlgipvgaapgjhglhromfvcubbxz/Build/Products/Debug-iphonesimulator -F/Users/jianglin/Library/Developer/Xcode/DerivedData/TownHall_iPhone-bdlgipvgaapgjhglhromfvcubbxz/Build/Products/Debug-iphonesimulator -filelist /Users/jianglin/Library/Developer/Xcode/DerivedData/TownHall_iPhone-bdlgipvgaapgjhglhromfvcubbxz/Build/Intermediates/TownHall\ iPhone.build/Debug-iphonesimulator/TownHall\ iPhone.build/Objects-normal/i386/TownHall\ iPhone.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -ObjC -lPods-AFNetworking -lPods-Masonry -lPods-SDWebImage -framework CoreGraphics -framework Foundation -framework ImageIO -framework MobileCoreServices -framework Security -framework SystemConfiguration -framework UIKit -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=8.1 -lPods -Xlinker -dependency_info -Xlinker /Users/jianglin/Library/Developer/Xcode/DerivedData/TownHall_iPhone-bdlgipvgaapgjhglhromfvcubbxz/Build/Intermediates/TownHall\ iPhone.build/Debug-iphonesimulator/TownHall\ iPhone.build/Objects-normal/i386/TownHall\ iPhone_dependency_info.dat -o /Users/jianglin/Library/Developer/Xcode/DerivedData/TownHall_iPhone-bdlgipvgaapgjhglhromfvcubbxz/Build/Products/Debug-iphonesimulator/TownHall\ iPhone.app/TownHall\ iPhone

Undefined symbols for architecture i386:
  "_main", referenced from:
     implicit entry/start for main executable
     (maybe you meant: _OBJC_IVAR_$_PostTableViewCell._mainTextView, _OBJC_IVAR_$_ConfirmationViewController._mainLabel , _OBJC_IVAR_$_SignInViewController._mainLabel , _OBJC_IVAR_$_SignUpViewController._mainLabel )
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Toute aide serait très appréciée. 

8
John

J'ai vérifié votre projet. Le problème est simple: dans votre projet, il n’existe pas de fichier main.m. Je pense que vous avez accidentellement supprimé cela.

Ajoutez un nouveau fichier .m à votre projet, nommez-le principal.

Et ajoutez le code suivant:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

Également dans votre projet, l'info.plist est également manquant, vous devez donc en ajouter un nouveau.

16
Midhun MP

ajouter @UIApplicationMain à l'AppDelegate

4
bartosss

Mon cas était très similaire, mais légèrement différent. La réponse de @ Midhun-MP ci-dessus a en partie incité la solution.

Dans mon cas, j'avais ajouté une version tvOS de mon application. Après avoir ajouté la nouvelle cible, cependant, main.m n'a pas été sélectionné sous Appartenance à la cible (donc, les messages d'avertissement concernant Undefined symbols for architecture x86_64: "_main"). Coche ça et bam - je suis GTG.

Merci @ Midhun-MP.

 main.m

1
Drew

Si j'ai raison, vous utilisez un simulateur pour exécuter l'application. Pour exécuter l'application sur iOSSimulator, le support de l'architecture i386 est nécessaire. L'erreur indiquant, par exemple, que votre cadre binaire pour la liaison ne prend pas en charge l'architecture i386. Cela peut être le framework 'SDWebImage' (je suppose). Veuillez essayer d’exécuter l’application dans un périphérique réel et non dans un simulateur, ou essayez de télécharger le framework contenant des points d’entrée i386.

Une autre possibilité est: vérifiez que "AppDelegate" existe dans la source compilée. J'espère que ceci vous aidera ..

0
rejusss