简体   繁体   中英

iOS framework works for iPhone 5s, 6, and 6 Plus but does not compile for other iPhone or iPad simulators

I created a very simple iOS framework in Xcode 6.1 using Swift (just one class with one method) and referenced it in a test project. I can compile the test project with iPhone 5s, 6, and 6 Plus simulators but I get the following compiler error for all other simulators (iPhone 4s and 5 and all iPad):

'TestClass' is unavailable: Cannot find Swift declaration for this class

Has anyone seen this issue? Thanks.

You have to create library with multiple architectures to run for simulator and device.
In Xcode, check if you are building for device and using it for app in simulator.
Usually when creating a library, you have to write a macro during build that will generate a FAT library that has i386, x86, armv7, armv7s, arm64 etc so that it works with all the iOS versions on all devices & simulator.
If you have generated two libraries one for simulator (say libFirst.a) and one for device (say libSecond.a), the command

lipo -info libFirst.a libSecond.a

prints the architecture of those libraries which you have created.


Then use the command to generate FAT library

lipo -create libFirst.a libSecond.a -o libCombined.a

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM