如何在Xcode 8.3中导入私有框架而不获取“未定义的架构arm64符号” [英] How to import a private framework in Xcode 8.3 without getting "Undefined symbols for architecture arm64"

查看:127
本文介绍了如何在Xcode 8.3中导入私有框架而不获取“未定义的架构arm64符号”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用_CDBatterySaver打开低功耗模式,只需使用

I am trying to use _CDBatterySaver to turn on low power mode simply using

    [[_CDBatterySaver batterySaver] setMode:1];

我知道目前的Xcode与目录类型不同,所以这些方法不起作用。

I know there isn't the same type of directory as previous Xcode so those methods don't work.

我也试过导入.h文件,但这不起作用。

I have also tried just importing the ".h" file but that doesn't work.

它是CoreDuet框架的一部分(从GitHub下载)

It is part of the CoreDuet framework (downloaded from GitHub)

谢谢

推荐答案

你需要一个 .tbd 文件来链接。

You will need a .tbd file to link against.

Apple停止向私有框架发送这些文件iOS 9.3 SDK,但您可以通过一些努力自己生成它们:

Apple stopped shipping these for private frameworks starting with the iOS 9.3 SDK, but you can generate them yourself with a bit of effort:


  1. 获取最新iOS版本的IPSW( ipsw.me iPhone wiki 有很好的列表。)

  2. 解压缩IPSW并挂载根文件系统( .dmg 多个GB)。

  3. /System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm* <中查找您的体系结构的共享库缓存/ code>。

  4. 使用各种工具之一(我更喜欢 jtool ),从中提取 CoreDuet ,例如:

  1. Get an IPSW for some recent iOS version (ipsw.me or the iPhone wiki have nice lists).
  2. Unzip the IPSW and mount the root file system (the .dmg that is multiple GB).
  3. Find the shared library cache for your architecture in /System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm*.
  4. Using one of various tools (I prefer jtool), extract CoreDuet from it, with e.g.:

jtool -e CoreDuet /path/to/dyld_shared_cache


  • 可选:对多个体系结构执行步骤4,然后将提取的文件合并为胖二进制文件:

  • Optional: Do step 4 for multiple architectures, then combine the extracted files to a fat binary:

    lipo -output CoreDuet dyld_shared_cache_*.CoreDuet
    


  • 使用 machotbd 或我自己的工具, tbdump notes ,从库/框架创建一个 .tbd 文件你刚提取,例如:

  • Using either machotbd or my own tool, tbdumpnotes, create a .tbd file from the library/framework you just extracted, e.g.:

    tbdump CoreDuet > CoreDuet.tbd
    

    notes 1.我写了它,所以我是显然是附属的。

      &NBSP; &NBSP; &NBSP; 2.这是一个测试版,它目前有点过于热心的符号,打印甚至是
      &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;它不应该 - 但到目前为止,它一直很适合我。

    notes 1. I wrote it, so I'm obviously affiliated.
            2. It's a beta, and it's currently a bit over-zealous with symbols, printing even
                the ones it shouldn't - but so far it has always worked fine for me.

    创建一个像这样的文件夹结构:

    Create a folder structure like so:

    some_path/
        CoreDuet.framework/
            CoreDuet.tbd
    


  • 将CoreDuet.framework添加到XCode中的框架,或者使用这些编译器标志:

  • Either add CoreDuet.framework to your frameworks in XCode, or use these compiler flags:

    -Fsome_path -framework CoreDuet
    


  • 利润。

  • Profit.

    另外,如果步骤1-6对您来说太麻烦了你只需要 _CDBatterySaver 符号,然后你可以将它用于你的 CoreDuet.tbd 并完成它:

    Also, if steps 1-6 are too troublesome for you and you merely need the _CDBatterySaver symbol, then you can just use this for your CoreDuet.tbd and be done with it:

    ---
    archs:           [ armv7, armv7s, arm64 ]
    platform:        ios
    install-name:    /System/Library/PrivateFrameworks/CoreDuet.framework/CoreDuet
    exports:
      - archs:           [ armv7, armv7s, arm64 ]
        objc-classes:    [ __CDBatterySaver ]
    ...
    

    这篇关于如何在Xcode 8.3中导入私有框架而不获取“未定义的架构arm64符号”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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