• 主页
  • 系列总集
  • OpenCV
  • CMake
  • iOS
  • Java
  • 前端
所有文章 关于我

  • 主页
  • 系列总集
  • OpenCV
  • CMake
  • iOS
  • Java
  • 前端

模块化与Framework(22):常见真机调试崩溃Crash

2017-07-22

模拟器不报错真机报错

有些情况下,由于Xcode的工作机制,会给人对Embedded配置带来一些困扰,比如在同一个Workspace中同时存在

1
2
3
4
5
Playground.workspace
-----Playground.xcodeproj
-----Alpha.xcodeproj
-----Beta.xcodeproj
-----SharedLib.xcodeproj

如果此时我在 Playground.app的Target中仅仅配置 Alpha.framework 和 Beta.framework 在使用模拟器运行时不会出错,但是真机运行会报错

1
dyld: Library not loaded: @rpath/SharedLib.framework/SharedLib

模拟器不报错原因是由于:

  1. 在模拟器的情况下存在一个Build目录
  2. Xcode会将 Playground.app自身用到的Framework和 Framework所用到的Framework都Build一遍,放入这个工作目录
  3. 所以模拟器在启动后的动态加载SharedLib.framework的过程中,可以找到SharedLib.framework

例如

1
/Users/XXXXX/Library/Developer/Xcode/DerivedData/Playground-gcaboylfavdygfdrsxaefouaxqcy/Build/Products/Debug-iphonesimulator/SharedLib.framework

而真机报错的原因在于

  1. 真机不存在一个公用的Build目录
  2. 真机使用的是 Playgorund.app 的包目录内的Framework
  3. 根据Framework的配置原理 Playground.app需要一步拷贝Framework的过程
  4. 没有Embed SharedLib.framework,则不会拷贝至App的包目录
  5. 由于framework是运行后加载,Build成功后,运行中找不到所需文件,抛出运行时错误

包目录一般存在于

1
/Users/XXXXX/Library/Developer/Xcode/DerivedData/Playground-gcaboylfavdygfdrsxaefouaxqcy/Build/Products/Debug-iphoneos/Playground.app/Frameworks

未知的 Mach-O header

会出现在两种情况,需要检查那个Static Framework的Mach-O文件在伪装成Bundle时没有删除

  1. Debug时的日志输出
  2. Archive时无法导出
1
2
1. unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A
2. Found an unexpected Mach-O header code: 0x72613c21

其中 0x72613c21 是 x86 架构下的 Static Framework的文件头4个字节,可以使用命令行查看

1
od -H -A n -N 8 static.framework/static

Library not found for -lswiftSwiftOnoneSupport

这个错误代表着工程里没有Swift的基本库,一般在加入Swift代码时会Xcode会帮你自动添加,但是如果使用了 Static Framework,就不会执行这一步

1
2
Library not found for -lswiftSwiftOnoneSupport for architecture arm64

解决方案: Target.app 里随便新建一个Swift文件,并且写一个函数

Swift 静态编译

在Xcode 9.1 之前, Swift是不支持编译成 Static Mach-O问文件的,改用更高的版本即可

1
2
CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
CompileSwift normal armv7

Unexpected CFBundleExecutable Key

这个问题很常见,就是plist里的key值和实际的Bundle不符合,在伪装Bundle里有 defaults delete “../Info.plist” CFBundleExecutable 来删除,出现说明脚本有问题

1
2
ERROR ITMS-90535: "Unexpected CFBundleExecutable Key. The bundle at 'Payload/StaticFramework.bundle' does not contain a bundle executable. If this bundle intentionally does not contain an executable, consider removing the CFBundleExecutable key from its Info.plist and using a CFBundlePackageType of BNDL. If this bundle is part of a third-party framework, consider contacting the developer of the framework for an update to address this issue."

赏

请问老板还招人么(/ω\)

支付宝
微信
  • iOS
  • IDE
  • Xcode
  • Compiler
  • Framework
  • Tutorial

扫一扫,分享到微信

微信分享二维码
模块化与Framework(23):StaticLib混合引用测试
模块化与Framework(21):引用非Framework模块Include of non-modular header
© 2021 Alan Li
Hexo Theme Yilia by Litten
  • 所有文章
  • 关于我

tag:

  • iOS
  • Java
  • Collection
  • Python
  • Shell
  • CMake
  • Memory
  • JavaScript
  • Architecture
  • AnchorPoint
  • Android
  • Web
  • Annotation
  • AFNetworking
  • Window
  • ViewController
  • AutoLayout
  • Dozer
  • CoreAnimation
  • Cycle Retain
  • Block
  • UI
  • IDE
  • FrontEnd
  • CSS
  • Category
  • TableViewCell
  • Security
  • Net
  • JSP
  • Spring
  • C
  • MyBatis
  • Date
  • React
  • GCD
  • UITouch
  • Gesture
  • UIControl
  • Git
  • HTML
  • HTTPS
  • HTTP
  • Servlet
  • Server
  • DataBase
  • MySQL
  • Linux
  • Tutorial
  • Ajax
  • Type
  • JQuery
  • JSON
  • Exception
  • Parameter
  • Reflect
  • Thread
  • Sort
  • KVO
  • MKMapKit
  • Overlay
  • Maven
  • Configure
  • Tips
  • Transaction
  • Swift
  • NavigationBar
  • Nginx
  • Runtime
  • OpenCV
  • Property
  • Playground
  • Protocol
  • Redux
  • ScrollView
  • Session
  • Cookie
  • Shiro
  • Error
  • Singleton
  • RegEx
  • StackView
  • StatusBar
  • Base64
  • Socket
  • TCP
  • IP
  • TextField
  • CALayer
  • UILabel
  • View
  • Animation
  • Xcode
  • Hexo
  • Terminal
  • OC
  • Device
  • Log
  • Image
  • JUnit
  • Oval
  • Archive
  • XSS
  • Compiler
  • Aspect
  • Responder
  • Class
  • FireWall
  • RetainCount
  • Const
  • Frame
  • String
  • Symbols
  • Framework
  • CocoaPods
  • Unity
  • Message
  • Button
  • AuthorizationStatus
  • Struct
  • XCTest
  • NSNotification
  • Contact

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

我写的,大概率是错的。。。。。