iOS simulator on mac is running i386 architecture, not armv7? - iphone

I've got some static libraries I've built for use on armv7 architectures. When I try to use them in a iOS project which I testrun on the iphone 5.0 simulator, I get errors telling me about undefined symbols for architecture i386 in my static libraries.
So I guess this means the iphone simulator wants libraries compiled for i386? What is the point of the simulator then - why dosn't it emulate armv7 architecture as well?
So the only way I can test my static libraries is to connect a physical iOS device and run it?
Or did I get it wrong?

So I guess this means the iphone simulator wants libraries compiled
for i386? What is the point of the simulator then - why dosn't it
emulate armv7 architecture as well?
You've answered your own question. It's a simulator, not an emulator. Therefore it is a Mac OSX program, running on i386 architecture. If you compile your static libraries for i386 as well you will be able to use them on the simulator.

I am not very sure but i386 is for Simulator and armv7 is for Devices that you have connected to your Machine.

You can actually compile the app through Xcode command line tool using i386 architecture (there is also a way to run it in Xcode UI by modifying the build settings).
xcodebuild -sdk iphonesimulator6.1 -arch i386 VALID_ARCHS="i386 armv7 armv7s" clean install
Run this command in the directory that you have the projectName.xcodeproj file.
Here's a break down of the script:
-sdk iphonesimulator6.1 // Build the app on iPhone simulator 6.1
-arch i386 // Build your app using i386 architecture
VALID_ARCHS="i386 armv7 armv7s" // Specify these architectures are valid
clean install // Clean all the builds then re-build and install

If you want to try simulators with i386 just go for =< iPhone 5.

Related

Unable to build for simulators while working for actual device

While facing no issue with actual iPhone device, my project does not build for simulators. I get this error (which occurres for many fies):
ld: warning: ignoring file /Users/stephanedeluca/Library/Developer/Xcode/DerivedData/AladdinWorkspace-afneoinpxpyfmofvnattjgylgxgo/Build/Products/Debug-iphonesimulator/GoogleDataTransport.o, building for iOS Simulator-arm64 but attempting to link with file built for unknown-x86_64
Which sounds like mixing ARM and 86 architectures.
My VALID_ARCHS is set to arm64 arm64e armv7 armv7s i386
I tried to remove VALID_ARCHS value as stated in the following answer without success:
Xcode 13 failing building with "entry point (_main) undefined. for architecture arm64"
I also tried to delete the DerivedData folder without success either.
[UPDATE] I forgot to mention that there is no more PODs in my workspace as I replaced them by the corresponding g Swift packages.
Any idea?
I found the solution: for some reasons, the architecture for macOS being ˋi386ˋ was not longer right, as I had to change it for x86_64.
Finally, my valid architectures are now:
arm64 arm64e armv7 armv7s x86_64

iPhone: how to make a fat library containing armv7s support?

I have external libraries for armv6, armv7, i386 and armv7s. When I try to put all together using lipo, I got an error message like so, saying armv7s isn't supported:
lipo: known architecture flags are: any little big ppc64 x86_64 ppc970-64 ppc i386 m68k hppa sparc m88k i860 veo arm ppc601 ppc603 ppc603e ppc603ev ppc604 ppc604e ppc750 ppc7400 ppc7450 ppc970 i486 i486SX pentium i586 pentpro i686 pentIIm3 pentIIm5 pentium4 m68030 m68040 hppa7100LC veo1 veo2 veo3 veo4 armv4t armv5 xscale armv6 armv7 armv7f armv7k
How to solve this problem?
You are possibly trying to use an older version of lipo that does not support armv7s. You should try that with the lipo version bundled with Xcode 4.5.
You would need the sources and compile it with armv7s support. Also, armv7 should work just fine on the armv7s devices too.

The Google Analytics SDK for iOS isn't built for the armv7s architecture while instaling app on iPhone

When i am trying to install my application on iPhone/iPad I am getting the following error. I am using new Xcode 4.5. What should I do to remove this error. I need to test my app on device.
file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/nishijain/Desktop/Backup SecondPrism/mobile/apps/SecondPrism/SecondPrism/Google Analytics SDK/libGoogleAnalytics.a for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks
You need to download the latest version of the SDK, according to the Changelog there is support for armv7s in Version 1.5.1.
If the error still happens try an older version of Xcode (probably Xcode 4.4.1) which has no clue of armv7s and throws no error.
EDIT:
This should work too:
In your Build Settings remove armv7s from Valid Architectures.

iPhone Static Library Issues With Simulator

So I have an iPhone static library that I am trying to build. I've got the script that was used in this question (http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4), but the issue I've hit is that I'm seemingly still unable to successfully build the static library for the simulator. When I build in the static library project, I get the follow warnings:
warning: no rule to process file '$(PROJECT_DIR)/GDInAppStore/GDInAppStore.m' of type sourcecode.c.objc for architecture i386
warning: no rule to process file '$(PROJECT_DIR)/GDInAppStore/SKProduct+priceAsString.m' of type sourcecode.c.objc for architecture i386
warning: no rule to process file '$(PROJECT_DIR)/GDInAppStore/VerificationControllerPBK.m' of type sourcecode.c.objc for architecture i386
I believe this issue is causing the problem that is leading to the universal library I get from the build script causing this error in my other project
ld: warning: ignoring file /Users/abotkin/Projects/Static Libraries/GDInAppStore/libGDInAppStore.a, missing required architecture i386 in file
"_OBJC_CLASS_$_GDInAppStore", referenced from:
objc-class-ref in SubscribeNowInAppController.o
ld: symbol(s) not found for architecture i386
I'm using Xcode 4.3.2 and have set the flags in the static library Xcode project so that i386 is included in the Architecture and Valid Architectures. Any tips?
Make sure you are building for the simulator if you are compiling for i386. Basically, your arch parameter has to match your sdk parameter. i.e.
xcodebuild -project proj.xcodeproj -arch armv64 -sdk iphoneos8.1 build
and
xcodebuild -project proj.xcodeproj -arch i386 -sdk iphonesimulator8.1 build
I was able to do a workaround this issue by using Karl's iOS Universal Framework that he mentioned in the other topic here https://stackoverflow.com/a/5721978/497718
That said, if anyone could point me into what I may have been doing wrong in using the script in that same topic, I'd love to learn how to do it the right way.
With Xcode 6, Apple has added iOS framework support to their build tools.
Using Apple's framework target for all new projects, as it is less hacky and is supported by Apple themselves.

No architectures to compile for core plot iphone

I'm trying out a core plot iphone example and I get:
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=i386, VALID_ARCHS=armv6 armv7).
Under project settings -> architecture, the only options are standard, optimized, and native arch.
Any ideas?
Thank you.
Add i386 to Valid Architectures
I was getting the same error while trying to run some older sample code... It turns out that the project build settings get changed (by the iOS 4.1 SDK?). Anyway, changing these settings back worked for me:
ORIG PROJECT "BUILD" SETTINGS:
Architecture: $(NATIVE_ARCH)
and
Valid Architectures: i386
NEW SETTINGS:
Architectures: armv6 armv7
and
Valid Architectures: armv6 armv7 i386
Just like magic...
~Paul