iOS Static Framework Setup: Difference between revisions

From Engineering Client Portal

No edit summary
No edit summary
 
(One intermediate revision by one other user not shown)
Line 25: Line 25:
* Nielsen App SDK
* Nielsen App SDK
* iOS security framework
* iOS security framework
=== Using Swift ===
=== Mixed Nielsen SDK static (xc)frameworks integration errors ===
To import a set of Objective-C files in the same app target as your Swift code, you rely on an Objective-C bridging header to expose those files to Swift. Xcode offers to create this header file when you add a Swift file to an existing Objective-C app, or an Objective-C file to an existing Swift app.
Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.<br>
*Select File/New File/Objective-C File
If static (xc)framework is integrated additional settings should be applied to fix build or runtime issues:
*Xcode will prompt you to create a bridging header.
 
[[File:bridgingheader 2x.png|600px|center|link=]]
==== Empty Swift file ====
Once this file has been created, you need to add the following:
If static mixed (xc)framework is integrated into pure ObjC application, link issue occurs during building:
<syntaxhighlight lang="swift">
 
#import <NielsenAppApi/NielsenAppApi.h>
<p style="color:red;">
</syntaxhighlight>
Undefined symbol: _OBJC_CLASS_$__TtCs12_SwiftObject<br>
Undefined symbol: nominal type descriptor for Dispatch.DispatchSpecificKey<br>
Undefined symbol: Dispatch.DispatchSpecificKey.init() -> Dispatch.DispatchSpecificKey<A><br>
Undefined symbol: static (extension in Dispatch):__C.OS_dispatch_queue.getSpecific<A>(key: Dispatch.DispatchSpecificKey<A>) -> A?<br>
Undefined symbol: (extension in Dispatch):__C.OS_dispatch_queue.label.getter : Swift.String<br>
Undefined symbol: _swift_weakDestroy<br>
Undefined symbol: _swift_deallocObject<br>
Undefined symbol: type metadata accessor for Network.NWPathMonitor<br>
Undefined symbol: Network.NWPathMonitor.init() -> Network.NWPathMonitor<br>
Undefined symbol: _swift_weakInit<br>
...<br>
</p>
 
To fix it an empty file with .swift extension should be added into the Application project target(s).
 
[[File:Screen Shot 2022-02-22 at 12.34.12.png|frame|center]]
 
==== -ObjC linker flag ====
Static library doesn't automatically load every source code entity. This leads to the runtime exception kind of:
<p style="color:red;">
unrecognized selector sent to class 0x1087b7a50, AppApiExceptionName=NSInvalidArgumentException
</p>
 
This is a known swift issue:
https://bugs.swift.org/browse/SR-6004
 
To fix:<br>
Build Settings → Other Linker flags -> -ObjC
 
[[File:Screen Shot 2022-02-22 at 12.45.15.png|frame|center]]
 
=== Using Objective-C ===
=== Using Objective-C ===
Add the code  
Add the code  

Latest revision as of 12:15, 20 July 2023

Engineering Portal / Digital / DCR & DTVR / DCR Video iOS SDK / iOS Static Framework Setup

Configuring Xcode Development Environment for Static Framework

Importing Frameworks

The first step is to ensure that the following frameworks and libraries are imported into the Frameworks folder of the Xcode project before creating an instance of the Nielsen App SDK object.

  • UIKit.framework
  • Foundation.framework
  • AdSupport.framework
  • JavascriptCore.framework
  • WebKit.framework
  • SystemConfiguration.framework
  • Security.framework
    • Nielsen Analytics framework makes use of a number of functions in this library.
  • AVFoundation.framework
  • NielsenAppApi.framework
  • libc++.tbd (as SDK contains Objective C++ source file)
    • Alternatively, include -lstdc++ in Build Settings → Other Linker Flag of the Xcode project

Example

  • Extract “NielsenAppApi.Framework” from the Nielsen App SDK sample app and copy it to Frameworks folder of the Xcode project.
  • Add the code -#import NielsenAppApi/NielsenAppApi.h to the View Controller’s header file.

Ensure that the following are included in the Linked Frameworks and Libraries list (located in the project’s Summary settings).

  • Nielsen App SDK
  • iOS security framework

Mixed Nielsen SDK static (xc)frameworks integration errors

Starting from 8.2.0.0 release framework is build from the mixed (swift + objc) source code.
If static (xc)framework is integrated additional settings should be applied to fix build or runtime issues:

Empty Swift file

If static mixed (xc)framework is integrated into pure ObjC application, link issue occurs during building:

Undefined symbol: _OBJC_CLASS_$__TtCs12_SwiftObject
Undefined symbol: nominal type descriptor for Dispatch.DispatchSpecificKey
Undefined symbol: Dispatch.DispatchSpecificKey.init() -> Dispatch.DispatchSpecificKey<A>
Undefined symbol: static (extension in Dispatch):__C.OS_dispatch_queue.getSpecific<A>(key: Dispatch.DispatchSpecificKey<A>) -> A?
Undefined symbol: (extension in Dispatch):__C.OS_dispatch_queue.label.getter : Swift.String
Undefined symbol: _swift_weakDestroy
Undefined symbol: _swift_deallocObject
Undefined symbol: type metadata accessor for Network.NWPathMonitor
Undefined symbol: Network.NWPathMonitor.init() -> Network.NWPathMonitor
Undefined symbol: _swift_weakInit
...

To fix it an empty file with .swift extension should be added into the Application project target(s).

Screen Shot 2022-02-22 at 12.34.12.png

-ObjC linker flag

Static library doesn't automatically load every source code entity. This leads to the runtime exception kind of:

unrecognized selector sent to class 0x1087b7a50, AppApiExceptionName=NSInvalidArgumentException

This is a known swift issue: https://bugs.swift.org/browse/SR-6004

To fix:
Build Settings → Other Linker flags -> -ObjC

Screen Shot 2022-02-22 at 12.45.15.png

Using Objective-C

Add the code

#import <NielsenAppApi/NielsenAppApi.h>

to the View Controller’s header file.