Question

J'essaie de compiler du code pour le simulateur d'iphone mais j'obtiens cette erreur:

    /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -O3 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -Os  -O3 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -Os -x objective-c -I../../include  -c version.c      
    In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:29,
                     from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:14,
                     from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:80,
                     from version.c:11:
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:166: error: expected declaration specifiers or ‘...’ before ‘SecPadding’
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:196: error: expected declaration specifiers or ‘...’ before ‘SecPadding’
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:228: error: expected declaration specifiers or ‘...’ before ‘SecPadding’
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:257: error: expected declaration specifiers or ‘...’ before ‘SecPadding’
    make: *** [version.o] Error 1

Cependant, si je compile pour l'iphone actuel, cela fonctionne bien:

    /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -O3 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk  -arch armv6  -Os  -O3 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk  -arch armv6  -Os -x objective-c -I../../include  -c version.c      

Ce problème survient avec un fichier aussi simple que Foundation.h sans autre code:

#import <Foundation/Foundation.h>

Avez-vous des idées sur le sujet? Ce qui est étrange, c’est que j’espère que cela échouera pour iPhone et pour le simulateur.

EDIT: fyi, je n'utilise pas XCode. C'est un grand projet multi-plateforme utilisant des Makefiles. Les commandes que vous voyez ci-dessus ont été émises par le Makefile.

Était-ce utile?

La solution

J'ai vu la même chose. Le correctif consiste à ajouter une directive de compilation -miphoneos-version-min = 3.0.

Autres conseils

Le problème ne survient que si vous utilisez SDK 3.0 avec le simulateur iphone. L'utilisation du SDK 2.0 (avec gcc 4.0) compilera. Cela semble être ce que XCode utilise par défaut.

Il est très étrange que ce problème ne concerne que le simulateur et non l’iphone. Également étrange, c’est que gcc4.2 ne compile pas avec le simulateur SDK 2.0 - vous devez utiliser gcc4.0.

Pour les curieux, j’ai écrit un fichier makefile qui illustre le problème:

IPHONE_GCC_VER    = 4.0
IPHONE_SDK_VER    = 3.0
IPHONE_DEV_PATH   = /Developer/Platforms/iPhoneOS.platform/Developer
IPHONE_SDK        = $(IPHONE_DEV_PATH)/SDKs/iPhoneOS$(IPHONE_SDK_VER).sdk 
IPHONE_GCC        = $(IPHONE_DEV_PATH)/usr/bin/gcc-$(IPHONE_GCC_VER)

SIMULATOR_GCC_VER = 4.0
SIMULATOR_SDK_VER = 2.0
SIMULATOR_DEV_PATH= /Developer/Platforms/iPhoneSimulator.platform/Developer
SIMULATOR_SDK     = $(SIMULATOR_DEV_PATH)/SDKs/iPhoneSimulator$(SIMULATOR_SDK_VER).sdk
SIMULATOR_GCC     = $(SIMULATOR_DEV_PATH)/usr/bin/gcc-$(SIMULATOR_GCC_VER)

TEST_FILE=/tmp/test.m

all: info make-test-file
    $(IPHONE_GCC)    -isysroot $(IPHONE_SDK)    -arch armv6 -c $(TEST_FILE) 
    $(SIMULATOR_GCC) -isysroot $(SIMULATOR_SDK) -arch i386  -c $(TEST_FILE) 

info:
    @echo "iphone gcc   : $(IPHONE_GCC_VER)"
    @echo "iphone sdk   : $(IPHONE_SDK_VER)"
    @echo "simulator gcc: $(SIMULATOR_GCC_VER)"
    @echo "simulator sdk: $(SIMULATOR_SDK_VER)"
    @echo ""

make-test-file:
    echo "#import <Foundation/Foundation.h>" > $(TEST_FILE)

Les valeurs par défaut sont celles qui fonctionnent, mais vous pouvez les remplacer sur la ligne de commande. Par exemple:

$ make -f Makefile.iphone-error-demo SIMULATOR_SDK_VER=3.0 SIMULATOR_GCC_VER=4.0
iphone gcc   : 4.0
iphone sdk   : 3.0
simulator gcc: 4.0
simulator sdk: 3.0

echo "#import <Foundation/Foundation.h>" > /tmp/test.m
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0    -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk     -arch armv6 -c /tmp/test.m 
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -arch i386  -c /tmp/test.m 
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:29,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:14,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:80,
                 from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:166: error: syntax error before ÔSecPaddingÕ
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:196: error: syntax error before ÔSecPaddingÕ
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:228: error: syntax error before ÔSecPaddingÕ
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:257: error: syntax error before ÔSecPaddingÕ
make: *** [all] Error 1

ou

$ make -f Makefile.iphone-error-demo SIMULATOR_SDK_VER=2.0 SIMULATOR_GCC_VER=4.2
iphone gcc   : 4.0
iphone sdk   : 3.0
simulator gcc: 4.2
simulator sdk: 2.0

echo "#import <Foundation/Foundation.h>" > /tmp/test.m
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0    -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk     -arch armv6 -c /tmp/test.m 
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk -arch i386  -c /tmp/test.m 
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:12,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6,
                 from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6,
                 from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include/float.h:8:24: error: float.h: No such file or directory
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/DriverServices.h:32,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:125,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:2,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:8,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:107,
                 from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:29:23: error: xmmintrin.h: No such file or directory
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/DriverServices.h:32,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:125,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:2,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:8,
                 from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:107,
                 from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:216: error: expected specifier-qualifier-list before Ô__m128Õ
make: *** [all] Error 1

Êtes-vous sûr que vos paramètres sont identiques entre les deux projets? Je parie que vous avez accidentellement modifié certains paramètres du simulateur.

Cliquez avec le bouton droit sur la structure, puis cliquez sur Obtenir des informations. Regardez le chemin dans la boîte de dialogue Info. Il doit être court, comme "Système / Bibliothèque / Frameworks /"

.

Si ce n'est pas le cas, utilisez le bouton Choisir pour rechercher la structure située sous le dossier du SDK actuel.

Assurez-vous également que l'option "Par rapport au SDK actuel" est affichée juste en dessous du chemin d'accès. choisi.

Lorsque vous avez ajouté les cadres à votre projet, avez-vous défini la case à cocher sur OUI lorsqu'il vous a été demandé si vous souhaitez copier le cadre dans le dossier du projet. Si tel est le cas, la case à cocher doit être définie sur NO.

Cela se produit-il également si vous créez un nouveau projet et tentez de l'exécuter sans rien ajouter, car il est possible que vous ayez modifié accidentellement les indicateurs de compilation dans ce projet

Ceci devrait être corrigé en l'ajoutant aux options du compilateur:

-D__IPHONE_OS_VERSION_MIN_REQUIRED=30000

J'ai rencontré ce problème lors de la modification d'un projet de SDK 3.2 à 4.1. Il s'avère que la solution changeait la cible de déploiement iOS dans les paramètres de construction de mon projet de 2.0 à 3.0 .

Cliquez avec le bouton droit de la souris sur votre projet en xcode (si vous l’utilisez), dans le volet de construction, sur la cible de déploiement iOS - > 3.0.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top