iOS Static Framework Setup: Difference between revisions
From Engineering Client Portal
No edit summary |
NickParrucci (talk | contribs) 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 | ||
=== | === 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.<br> | |||
If static (xc)framework is integrated additional settings should be applied to fix build or runtime issues: | |||
[[File: | ==== Empty Swift file ==== | ||
If static mixed (xc)framework is integrated into pure ObjC application, link issue occurs during building: | |||
< | |||
<p style="color:red;"> | |||
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
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).
-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
Using Objective-C
Add the code
#import <NielsenAppApi/NielsenAppApi.h>
to the View Controller’s header file.