124

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

Xcode Libraries section screenshot

enter image description here

Can anyone explain what they do?

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
Shreeram Bhat
  • 2,849
  • 2
  • 11
  • 19
  • 1
    I guess "embed" means "copy into app bundle". I also guess the "sign" bit really means "re-sign" using your credentials. – trojanfoe Aug 28 '19 at 07:40

4 Answers4

69

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
shim
  • 9,289
  • 12
  • 69
  • 108
agirault
  • 2,509
  • 20
  • 24
  • If result of `file` is `Mach-O universal binary`, what should be the right choice? – wzso Mar 26 '20 at 02:52
  • 2
    As to `codesign`, I found that if the framework is signed with a `adhoc` signature, it'll still be necessary to sign it, or else the app can't be launched. – wzso Mar 26 '20 at 03:20
  • @Mint: universal binary means it has different architectures underneath. The architectures underneath should tell you if they are archives or dynamic libraries – agirault Mar 26 '20 at 22:44
  • 3
    Does this also apply to standard frameworks such as the **AdSupport.framework** or should they be set to "Do not Embed" as they are already present on the device? – cauende May 19 '20 at 09:23
  • 1
    Good question. That framework isn't static? I believe you should not embed it if you know it will be available on the target system, even if it's shared. The best way to know is to test without embedding it, and it will complain at runtime if it can't load that library. Please let us know so we can edit the answer accordingly! – agirault May 20 '20 at 19:48
15

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:

Xcode 10

Xcode 11

shim
  • 9,289
  • 12
  • 69
  • 108
  • Earlier under "Linked Frameworks and Libraries" the options were "Required" and "Optional" Is "Required" same as "Do not Embed" ? – RBz Feb 10 '20 at 04:07
  • 2
    @RBz no, `optional` status for supporting earlier versions as weak dependencies. Check the manual: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html – dimpiax Mar 01 '20 at 19:33
14

Xcode v11. Frameworks, Libraries, and Embedded Content plus Frameworks and Libraries with Embed vs Do Not Embed

enter image description here

History

Embedded Binaries, Linked Frameworks and Libraries -> Frameworks, Libraries, and Embedded Content

[Xcode pre-v11. Embedded Binaries, Linked Frameworks and Libraries] existed till to Xcode v11 section in General tab

It is a part of Dependency management [About]

Xcode v11 has:

  • App target - Frameworks, Libraries, and Embedded Content
  • Framework or App extension target - Frameworks and Libraries

Embedding

Embed

It adds a copy of the framework into your final 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.

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]

Result:

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

*Please note that Embedding has bigger priority than Mach-O Type[About]

  • Application's Frameworks, Libraries... is Embed and Framework's Mach-O is Static Library - result dynamic framework.
  • Application's Frameworks, Libraries... is Do Not Embed and Framework's Mach-O is Dynamic Library and - result error dyld: Library not loaded[About]
App's Embed (Dynamic) -> Framework's Mach-O Static - Dynamic
App's Do Not Embed(Static) -> Framework's Mach-O Dynamic - error

[Static vs Dynamic linker]
[When use Link and Embed]
[Vocabulary]

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
11

The complete story holyswift

enter image description here

for more details

Mashal
  • 119
  • 1
  • 5