My project runs fine when I run it using the iPhone simulator, and when I run it on a device. When I try to archive it for submission, I get this error:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This was directly before the error and I'm not sure if it's related:
ld: file is universal (2 slices) but does not contain a(n) armv7s slice: /Volumes/Macintosh HD/Users/dog94a/Google Drive/Capstone/Backups/Approach/Approach/GMaps/GoogleMaps.framework/GoogleMaps for architecture armv7s
The default behavior of the Debug build configuration is to only build the active architecture (Build Active Architecture Only build setting is YES). This is not the case for the Release build configuration, which will build all architectures supported by your Valid Architectures build setting. What this means is that you're likely not targeting an armv7s device during your Debug builds (iPhone 5, latest iPad, etc), so you're not attempting to build that architecture until you do an archive which uses the Release build configuration by default.
The error indicates that your project is configured to create a binary that has armv7s instructions for when it runs on devices of that type, but the GoogleMaps.framework binary you're trying to link against was not built with an armv7s slice. To fix this, you either have to update to the latest version of the GoogleMaps.framework and hope they built it with armv7s enabled, or remove armv7s from your Valid Architectures build setting (obviously the former is preferable).
Once I have included a framework and at compile time nagged the linker for armv7. Now you have armv7s, which is the iphone5?
Solution to my problem it was: remove all files from that framework.
Compile that framework ( double check at Valid architectures settings to be there the desired architecture
Re-add the newly compiled framework.
Try and maybe it helps or even solve your problem too!
Related
I'm seeing errors in my logs like
MT5209 ignoring file libmono-native-unified.a file is universal (armv7,armv7s,arm64) but does not contain the x86_64 architecture Native linking
However I'm trying to build the project for iOS in debug mode, so it should be using arm64 as the architecture, so I'm not sure why it's trying to use x86_64 at all. This implies it's building for a simulator instead of the selected device.
As you can see my debug iPhone configuration is set to ARM64 (correct)
And only the simulator is set to x86
SOLUTION - If I swap the build configuration from 'Debug' to 'Debug|iPhone' it compiles just fine, e.g.
FROM
TO
So why 'Debug' and platform 'iPhone' doesn't work and 'Debug|iPhone' does I'm not sure.
I am building a static library to be used with another project I'm working on, and eventually it will be included in a framework I'm developing. When I bring the library into my project, the arm builds work fine, but the simulator builds fail with missing symbols for the x86_64 build. I have set the build architectures in the library to
arm64 arm64e armv7 armv7s x86_64
I have tried various settings, like $(ARCHS_STANDARD) to no avail. I have also tried all of the potential solutions I could find on SO, most of which are pretty old.
Any and all suggestions would be greatly appreciated.
As mentioned in the comments and the edit, you have to build a fat library, but there are steps missing in all of the answers and many of them are badly out of date. Hopefully this will help.
Build a version of the static library for iPhoneOS and iPhoneSimulator.
On the command line, cd to the derived data directory for your project.
You will see directories for the OS and simulator libraries.
Execute the lipo command as below
lipo -create -output [desired fat library name] [path to iPhoneOS library] [path to iPhoneSimulator library]
Drag the fat library from finder to your target project.
You can probably automate this with a build script, but I was under a deadline so it was faster to just build and drag. If you come up with a good script, feel free to post it here.
P.S. The script presented in the Agile Warrior post did not work.
I have recently updated to Xcode 7 and now receive the following warning when I compile:
ld: warning: -read_only_relocs cannot be used with x86_64
I don't think I changed anything in the build settings or code to create this. Does anyone know what is causing this warning and how to remove it?
I have found the problem for those interested. As mentioned in the comment, I'm using the Twilio API and if you install this via cocoapods it adds the -read_only_relocs flag to the Other Linker Flags in Xcode (found under Build Settings). Not only does this generate the warning above (on the simulator) but it wont compile on an actual device because you can't have both BITCODE = YES and this flag. If you want to compile, you will need to set Enable Bitcode to No in the Build Options.
Building a unified API app (after migration) with Armv7 + Arm64 architecture works fine, and the app runs well on iPhone 5 and iPhone 6. but it fails to run on iPhone 4S due to incompatible architecture.
Trying to build it with only Armv7 architecture fails.
These are the errors I get:
Error MT5210: Native linking failed, undefined symbol: _res_9_init. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5210)
Error MT5210: Native linking failed, undefined symbol: _xmlDocGetRootElement. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5210)
And 6 more like these...
how can I compile this on Armv7 only?
The solution:
Armv7 build failed due to missing link flags in the Oyala binding linkWith file.
After fixing the flags (LinkerFlags="-lstdc++ -lz -lxml2 -lresolv") the Armv7 build was completed with no errors.
It still doesn't explain why Armv7+Arm64 (the fat build) did not fail.
It just skipped the Oyala build.
This is probably a Xamarin bug.
This looks like a bug in Xamarin.iOS, it's not including certain libraries in the fat (armv7+arm64) build, while those (problematic) libraries cause problems in the armv7-only build.
That said, I believe the build problems will be solved by adding -gcc_flags -lxml to the additional mtouch arguments in the project's iOS Build options.
In addition I recommend filing a bug (http://bugzilla.xamarin.com) for the difference in the fat vs thin builds.
I'm working on a game that has cocos2d with ARC.
The game builds & runs fine in Simulator, but when I build for device I get Apple Mac-O Linker Errors, saying that I'm missing the libraries for libcocos2d.a etc.
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libcocos2d.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libCocosDenshion.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/libkazmath.a'
clang: error: no such file or directory: '/Users/aleksandartrpeski/Library/Developer/Xcode/DerivedData/jellyfish-fsomqwhqasishxcfzhgvccrdvzpt/Build/Products/Debug-iphoneos/liblibpng.a'
When I go to the folder where the file is missing I only see jellyfish.app.
I don't have much experience in this kind of issues & I'm not clear why this happens,
I checked how to start the project from TinyTimGames & LearnCocos2D, still not clear what I'm doing wrong.
I've solved the issue, the builds for the binaries were somehow ignored by XCode because they were for another architecture, by settings the build settings for the cocos2d target Build For Active Architectures Only to NO, the issue dissapeared.
Sounds like you'll have to add these libraries to the Link Binary With Libraries build phase.
See my tutorial on Enabling ARC for Cocos2D projects for details.
It's strange that it would work for the Simulator though, since it's using the same target. I wouldn't rule out that the device is incompatible, you'll have to have at least a 3rd generation (iPhone 3GS) device running iOS 4.0 or higher.