IOS - Embedding Content with Swift in Objective-C

    If you are building an app that does not use Swift but embeds content such as a framework that does, Xcode will not include these libraries in your app. As a result, your app will crash upon launching with an error message looking as follows:

    dyld: Library not loaded: @rpath/libswiftCoreGraphics.dylib
      Referenced from: /private/var/mobile/Containers/Bundle/Application/696F0EAD-E2A6-4C83-876F-07E3D015D167/<Your_App>.app/Frameworks/<Framework_Name>.framework/<Framework_Name>
      Reason: image not found
    

    where <Your_App> and <Framework_Name> are respectively your app and the framework being embedded in your app.

    To workaround this issue, set the Always Embed Swift Standard Libraries (ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES) build setting to YES in your app as shown in Figure 1. This build setting, which specifies whether a target's product has embedded content with Swift code, tells Xcode to embed Swift standard libraries in your app when set to YES.



    Figure 1: Setting Always Embed Swift Standard Libraries to YES

    Screen-Shot-2018-07-11-at-2.33.54-PM



    Xcode Version : 9.4 (9F1027a)

    Tegan Tang

    Read more posts by this author.

    Kuala Lumpur, Malaysia