문제

iPhone 시뮬레이터 용 코드를 컴파일하려고하지만이 오류가 발생합니다.

    /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

그러나 실제 iPhone을 컴파일하면 잘 작동합니다.

    /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      

이 문제는 다른 코드가없는 Foundation.h를 포함하는 것만 큼 단순한 파일에서 발생합니다.

#import <Foundation/Foundation.h>

이것이 무엇인지에 대한 아이디어가 있습니까? 이상한 것은 이것이 iPhone과 시뮬레이터 모두에 실패 할 것으로 예상한다는 것입니다.

편집 : FYI, Xcode를 사용하지 않습니다. 이것은 makefiles를 사용하는 크고 다중 플랫폼 프로젝트입니다. 위에서 볼 수있는 명령은 makefile에서 방출되었습니다.

도움이 되었습니까?

해결책

나는 같은 것을 보았다. 수정은 -miphoneos-version-min = 3.0 컴파일러 지시문을 추가하는 것입니다.

다른 팁

iPhone 시뮬레이터에서 SDK 3.0을 사용하는 경우에만 문제가 발생합니다. SDK 2.0 (GCC 4.0)을 사용하면 컴파일됩니다. 이것은 Xcode가 기본적으로 사용하는 것으로 보입니다.

이 문제는 아이폰 자체가 아닌 시뮬레이터에만 해당되는 것이 매우 이상합니다. 또한 GCC4.2는 Simulator SDK 2.0으로 컴파일하지 않을 것입니다. GCC4.0을 사용해야합니다.

호기심을 위해, 나는 문제를 보여주는 makefile을 썼습니다.

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)

기본값은 작동하는 기본이지만 명령 줄에서이를 재정의 할 수 있습니다. 예를 들어:

$ 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

또는

$ 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

설정이 두 프로젝트간에 동일하다고 확신합니까? 실수로 시뮬레이터 설정을 변경했습니다.

프레임 워크를 마우스 오른쪽 버튼으로 클릭하고 정보 받기를 클릭하십시오. 정보 대화의 경로를 살펴보십시오. "System/Library/Frameworks/"와 같이 짧아야합니다.

그렇지 않은 경우 선택 버튼을 사용하여 현재 SDK 폴더 아래의 프레임 워크를 찾으십시오.

또한 선택한 "현재 SDK를 기준으로"옵션이 표시되는 경로 바로 아래에 있는지 확인하십시오.

프로젝트에 프레임 워크를 추가했을 때 프레임 워크를 프로젝트 폴더에 복사 할 것인지 물었을 때 확인란을 YES로 설정 했습니까? 그렇다면 확인란은 아니오로 설정해야합니다.

새 프로젝트를 만들고 아무 것도 추가하지 않고 실행하려고 시도하면 이런 일이 발생합니까?

컴파일러 옵션에 이것을 추가하여 해결해야합니다.

-D__IPHONE_OS_VERSION_MIN_REQUIRED=30000

프로젝트를 SDK 3.2에서 4.1로 변경할 때이 문제에 직면했습니다. 솔루션이 바뀌고 있음이 밝혀졌습니다 iOS 배포 대상 내 프로젝트의 빌드 설정에서 2.0 에게 3.0.

Xcode에서 프로젝트를 마우스 오른쪽 버튼으로 클릭하십시오 (사용하는 경우), IOS 배포 대상 -> 3.0을 구축하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top