“Do Not Embed”, “Embed & Sign”, “Embed Without Signing”. What are they?. What they do?

后端 未结 3 592
醉梦人生
醉梦人生 2020-12-07 23:58

We have 3 new options in \"Frameworks, Libraries, and Embedded Content\" section of Xcode11 Beta for adding libraries.

Xcode Libraries section screenshot

相关标签:
3条回答
  • 2020-12-08 00:26

    Basically in XCode 10 in project settings (upon clicking on .xcodeproj file, with the blue icon) you had two framework-oriented sections visible - Embedded Binaries and Linked Frameworks and Libraries. Now they are merged into one.

    Do Not Embed option is basically Linking given .framework into project.

    Embed & Sign and Embed Without Signing is old Embedding option.

    I am not entirely sure what is the functional difference between the last two, apart from the fact that framework will or will not be signed during assembly. If you want to know the difference between Linking and Embedding then here you can find SO answer on this.

    Pics:

    0 讨论(0)
  • 2020-12-08 00:29

    It is a part of Dependency management [About]

    [Pre Xcode v11 Link Binary and Embed binary]

    Xcode v11 has Frameworks, Libraries, and Embedded Content.

    Embedding

    Do Not Embed

    Static Linker at compile time tries to copy code from a static library into the executable object file using Build Settings -> Framework Search Paths

    Do Not Embed is a mirror of Build Phases -> Link Binary With Libraries. Sign is a mirror of Code Sign On Copy

    If you do not add a static framework to this section you will get a compile error[No such module]

    Embed

    It adds a copy of the framework into your finish bundle. After that Dynamic linker :dyld at load or run time tries to find the embedded framework using @rpath[About] If it is not found the error will occur [dyld: Library not loaded]

    Embed is a mirror of Build Phases -> Embed Frameworks. Here you can setup bundle's folder and Subpath.

    Result:

    • static library
    • static framework - Do Not Embed
    • dynamic framework - Embed

    [When use Link and Embed]

    [Vocabulary]

    0 讨论(0)
  • 2020-12-08 00:44

    As already stated by @przemyslaw-jablonski, this is similar to what was in XCode 10, but in only one screen (which I personally like!).


    Embedding

    Do not embed static frameworks and libraries (linking happens at build time), only shared ones (dynamic linking happens at run time, so they need to be in your bundle).

    file frameworkToLink.framework/frameworkToLink will return:

    • current ar archive: static library, select Do not embed
    • Mach-O dynamically linked: shared library, select Embed

    Signing (only if shared/embedded)

    Not required if it already has a proper signature (adhoc doesn't count).

    codesign -dv frameworkToLink.framework will return:

    • code object is not signed at all or adhoc: select Embed and sign
    • anything else: already properly signed, select Embed Without Signing
    0 讨论(0)
提交回复
热议问题