Xcode 5 warns about my architectures setting when

2019-05-11 12:52发布

问题:

I just updated to the newly released Xcode 5. I have an iOS app under development that uses the Google Maps iOS SDK. Back when I was developing in Xcode 4, I changed my Architectures setting in my project settings, as per step 7 of Google's instructions for adding the SDK to the project:

7. Choose your project, rather than a specific target, and open the Build Settings tab. Replace the default value of Architectures with armv7. In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.

Everything was fine in Xcode 4. However, when I open my project in Xcode 5, I see the following warning in the issue navigator:

Validate Project Settings

Update to recommended settings

When I click the warning, Xcode takes me to my project settings and displays a popup with 'Cancel' and 'Perform Changes' buttons, and the following description of the change it wants to make

Project 'Your Project' - Automatically Select Architectures

Project 'Your Project' overrides the Architectures setting. This will remove the settings and allow Xcode to automatically select Architectures based on hardware available for the active platform and deployment target.

I tried clicking 'Perform Changes' and letting Xcode do whatever it wanted to do, and the app still built fine for the simulators. However, when I tried plugging in an iPhone 5 (which supports ARMv7S) and running on it, the app failed to build with the following linker error:

Ld /Users/macmini/Library/Developer/Xcode/DerivedData/Your_App-bmrouudjlblpafdjzhpwcuekzgwu/Build/Products/Debug-iphoneos/Your\ App.app/Your\ App normal armv7s
    cd "/Users/macmini/Documents/Your App"
    setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -L/Users/macmini/Library/Developer/Xcode/DerivedData/Your_App-bmrouudjlblpafdjzhpwcuekzgwu/Build/Products/Debug-iphoneos -F/Users/macmini/Library/Developer/Xcode/DerivedData/Your_App-bmrouudjlblpafdjzhpwcuekzgwu/Build/Products/Debug-iphoneos -F/Users/macmini/Documents/Your\ App -filelist /Users/macmini/Library/Developer/Xcode/DerivedData/Your_App-bmrouudjlblpafdjzhpwcuekzgwu/Build/Intermediates/Your\ App.build/Debug-iphoneos/Your\ App.build/Objects-normal/armv7s/Your\ App.LinkFileList -dead_strip -ObjC -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.1 -framework SystemConfiguration -framework MapKit -framework QuartzCore -framework OpenGLES -lz -licucore -lc++ -framework ImageIO -framework GLKit -framework CoreText -framework CoreLocation -framework AVFoundation -framework CoreData -framework UIKit -framework Foundation -framework CoreGraphics -framework GoogleMaps -Xlinker -dependency_info -Xlinker /Users/macmini/Library/Developer/Xcode/DerivedData/Your_App-bmrouudjlblpafdjzhpwcuekzgwu/Build/Intermediates/Your\ App.build/Debug-iphoneos/Your\ App.build/Objects-normal/armv7s/Your\ App_dependency_info.dat -o /Users/macmini/Library/Developer/Xcode/DerivedData/Your_App-bmrouudjlblpafdjzhpwcuekzgwu/Build/Products/Debug-iphoneos/Your\ App.app/Your\ App

ld: file is universal (2 slices) but does not contain a(n) armv7s slice: /Users/macmini/Documents/Your App/GoogleMaps.framework/GoogleMaps file '/Users/macmini/Documents/Your App/GoogleMaps.framework/GoogleMaps' for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Once I reverted the automatic changes Xcode had made, my app compiled fine for iPhone 5 again - but of course I had the warning back.

How can I satisfy Xcode and get rid of the warning while still allowing my app to build successfully for iPhone 5?

回答1:

Oops - as it happened it only took me a few seconds of experimentation after posting this question to find the answer myself:

  1. Click the 'Validate Project Settings' warning in the Issue Navigator.
  2. Uncheck the checkbox to the left of the 'Automatically Select Architectures' suggested change.
  3. Click 'Done' (or 'Perform Changes' if there are other changes left on the list that you actually want to make - in my case, this was the only one).

Now your settings are as they were before, and you can build for iPhone 5, but the warning is gone.

I feel a bit dim now for having spent my time posting this question, but I'm leaving the question and this answer here in case it helps anyone in the future.



回答2:

Google Maps SDK v1.5 now supports ARMv7S. From the v1.5 release notes:

The Google Maps SDK for iOS now ships with an armv7s slice. (Issue 4745)

Supporting ARMv7S in your app will improve performance, so the best course of action to take if you see the warning described in the question is to update your version of the Google Maps SDK to v1.5 (or later, if you are reading this in the future) and then double-click the warning and allow Xcode to change your architecture settings back to the default.



回答3:

The linker is giving you an error because the GoogleMaps framework that you are using doesn't support the armv7s architecture. Maybe the latest version of the GoogleMaps framework has such support or maybe you'll have to wait for an update from Google.