框架只能在模拟器上运行,而不能在设备上运行 [英] Framework can only work on simulator, but not device

查看:414
本文介绍了框架只能在模拟器上运行,而不能在设备上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode版本7.2(7C68)。

I'm using Xcode Version 7.2 (7C68).

我在将DTCoreText项目构建为框架后遇到了问题。
DTCoreText.framework在ios模拟器上工作正常,但是当我想在设备上测试它时,出现以下问题:

I met a problem after I build DTCoreText project as framework. DTCoreText.framework works fine on ios simulator, but when i want to test it on device, the following problem showed up:

我已经检查了最新的构建设置 DTCoreText-1.6.17 项目:

I've checked the build settings in the latest DTCoreText-1.6.17 project:

目标: DTCoreText(iOS)

ARCHS: armv7,arm64

ONLY_ACTIVE_ARCH:

ONLY_ACTIVE_ARCH: NO

VALID_ARCHS: arm64,armv7,armv7s

VALID_ARCHS: arm64, armv7, armv7s

我认为这些设置都可以。按下Shift + CMD + i,比我构建分析。

I think these settings are OK. Than I "Build for Profiling" by pressing Shift+CMD+i.



  • 使用模拟器构建:

  • Build using simulator:

我注意到我刚刚用于构建的当前设备是模拟器
(iPhone 6加)
即可。我在
Release-iphonesimulator 文件夹下找到了DTCoreText.framework。通过这样做,DTCoreText.framework只能在使用iphone模拟器时正常工作,但
不适用于真实设备。

I noticed the current device i just used for building is Simulator (iPhone 6 Plus). And I find the DTCoreText.framework under the Release-iphonesimulator folder. by doing this, the DTCoreText.framework only works fine when using iphone simulator, but not on real device.


  • 使用设备构建:

  • Build using device:

比我尝试使用相同的构建
设置重建DTCoreText.framework,但使用通用iOS设备真实设备(例如:
iPhone 6s)
。我在
Release-iphoneos 文件夹下获得了DTCoreText.framework。通过这样做,DTCoreText.framework只能在使用真实设备时正常工作,但不能在iphone模拟器上工作。

Than I tried to rebuild DTCoreText.framework with the same build settings, but using "Generic iOS Device" or "Real Device (eg: iPhone 6s)". I got the DTCoreText.framework under Release-iphoneos folder. By doing this, the DTCoreText.framework only works fine when using real device, but not on iphone simulator.

我不知道为什么会这样。
如何为模拟器和真实设备构建DTCoreText.framework?

I don't know why it is happening. How to build DTCoreText.framework for both simulator and real device?

推荐答案

解决问题!!!

我需要为i386 x86_64 armv7 arm64制作FAT框架!

What I need is making a "FAT" Framework for "i386 x86_64 armv7 arm64"!

如何导出脂肪 Cocoa Touch Framework(适用于模拟器和设备)?

这篇文章对我有很大的帮助!

This post helps me a lot!

只需使用 lipo -info 命令检查ARCHS,例如:

Just use "lipo -info" command to CHECK the ARCHS, for example:

admins-MacBook-Pro:~ admin$
admins-MacBook-Pro:~ admin$ lipo -info /Users/admin/Desktop/DT/device/DTCoreText.framework/DTCoreText
Architectures in the fat file: /Users/admin/Desktop/DT/device/DTCoreText.framework/DTCoreText are: armv7 arm64
admins-MacBook-Pro:~ admin$
admins-MacBook-Pro:~ admin$ lipo -info /Users/admin/Desktop/DT/simulator/DTCoreText.framework/DTCoreText
Architectures in the fat file: /Users/admin/Desktop/DT/simulator/DTCoreText.framework/DTCoreText are: i386 x86_64
admins-MacBook-Pro:~ admin$

我们可以看到:


  • 使用模拟器构建时,xcode使用ARCHS生成框架 i386,x86_64

  • 使用设备构建时,xcode生成fr使用ARCHS的amework armv7,arm64

  • When build using simulator, xcode generate framework using ARCHS "i386, x86_64"
  • When build using device, xcode generate framework using ARCHS "armv7, arm64"

要将两个框架组合在一起,请使用以下命令,例如:

To Combine the two framework together, use the following command, for example:

admins-MacBook-Pro:~ admin$ lipo -create /Users/admin/Desktop/DT/device/DTCoreText.framework/DTCoreText /Users/admin/Desktop/DT/simulator/DTCoreText.framework/DTCoreText -output /Users/admin/Desktop/DTCoreText

现在您可以在桌面上找到DTCoreText二进制文件。使用lipo cmd再次检查:

Now you can find the "DTCoreText" binary file on your desktop. Use lipo cmd to check it again:

admins-MacBook-Pro:~ admin$ lipo -info /Users/admin/Desktop/DTCoreText
Architectures in the fat file: /Users/admin/Desktop/DTCoreText are: i386 x86_64 armv7 arm64

是的! ARCHS i386 x86_64 armv7 arm64

Yes! the ARCHS are "i386 x86_64 armv7 arm64"

将DTCoreText二进制文件放在DTCoreText.framework中并替换旧文件!

Put the "DTCoreText" binary file inside DTCoreText.framework and replace the old one!

完成!

现在我们应该能够为设备和模拟器使用框架了!

Now we should able to use the framework for both device and simulator!

但是

这只是为了方便测试目的,如果您想将应用程序提交到应用程序商店。由于包含模拟器切片的iOS框架无法提交到App Store,苹果将拒绝它

This is only for the convenience of testing purpose, If you want to submit your app to app store. apple will reject it due to "iOS frameworks containing simulator slices can't be submitted to the App Store".

请阅读这篇文章:
创建iOS / OSX框架:是否有必要在分发给其他开发人员之前对其进行编码?

这篇关于框架只能在模拟器上运行,而不能在设备上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆