# Is it allowed in iOS - Swift Dynamic Framework - Contains Multiple Static Library

**URL:** <https://forums.swift.org/t/is-it-allowed-in-ios-swift-dynamic-framework-contains-multiple-static-library/70732>\
**Category:** Using Swift\
**Tags:** binary-framework, xcframework\
**Created:** [March 17, 2024, 12:53pm UTC](https://forums.swift.org/t/is-it-allowed-in-ios-swift-dynamic-framework-contains-multiple-static-library/70732 "2024-03-17T12:53:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishnuthoughtfocus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/vishnuthoughtfocus/32/34528_2.png) [@vishnuthoughtfocus](https://forums.swift.org/u/vishnuthoughtfocus)\
**Post date:** [March 17, 2024, 12:53pm UTC](https://forums.swift.org/t/is-it-allowed-in-ios-swift-dynamic-framework-contains-multiple-static-library/70732/1 "2024-03-17T12:53:38Z")

</div>

-1

I have developed a framework for my customer, thats a swift dyanmic framework. For code modularization i have divided this framework features in to multiple static libraries as shown in the diagram below. Currently we have on main swift dynamnic framework and it contains 2 static libraries too. Also the first static library here in turn nested with another static library, Key points to note here is

My static libraries contains other third party iOS frameworks My static libraries using CoccoaPods as the dependency for Alarmofire at the moment.

 ![Static Library Approach](https://global.discourse-cdn.com/swift/original/3X/5/6/56d1b00c3b8fbcf8d7b571d047f8b2b4c29f63ec.png)  
My questios are

Is there any problem in the current architecture , because i heard nested libraries are not supported in iOS . but since we dont have frameworks nested here, all of our second level frameworks are static libraries only. What are link/libary search path guidance we needed to take care to make a successful build.

---

<div class="post-metadata">

**Author:** ![stuchlej](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/stuchlej/32/7751_2.png) [@stuchlej](https://forums.swift.org/u/stuchlej)\
**Post date:** [March 17, 2024, 9:27pm UTC](https://forums.swift.org/t/is-it-allowed-in-ios-swift-dynamic-framework-contains-multiple-static-library/70732/2 "2024-03-17T21:27:20Z")

</div>

I don't know whether I'm completely correct, but I've always checked for `type metadata accessor`s for types in the statically linked libraries. If I have more than one _type metadata accessor_ for given type, might have a problem.

> **Example**
>
> Consider following files:
> 
> ```swift
> // % cat stat.swift
> public struct MyFoo { public init() {} }
> 
> // % cat dyn.swift
> import stat
> public func dyna1foo() -> stat.MyFoo { .init() }
> 
> // % cat dyn2.swift
> import stat
> public func dyna1foo() -> stat.MyFoo { .init() }
> 
> // % cat main.swift 
> import dyn
> import dyn2
> 
> let a = dyn.dyna1foo()
> let b = dyn2.dyna1foo()
> 
> print(type(of: a) == type(of: b))
> 
> ```
> 
> Built using:
> 
> ```swift
> % swiftc -parse-as-library -emit-library -emit-module -static stat.swift
> % swiftc -parse-as-library -emit-library -emit-module -I. -L. -lstat -Xlinker -rpath -Xlinker . dyn.swift
> % swiftc -parse-as-library -emit-library -emit-module -I. -L. -lstat -Xlinker -rpath -Xlinker . dyn2.swift 
> % swiftc -I. -L. -ldyn -ldyn2 -Xlinker -rpath -Xlinker . main.swift   
> 
> ```
> 
> Then if I run `main` in LLDB and do this:
> 
> ```swift
> (lldb) b main
> (lldb) r
> (lldb) image lookup -rn MyFoo #I assume all dynamic libraries are loaded at this time
> 
> ```
> 
> and lldb goes something like this:
> 
> ```swift
> 3 matches found in libdyn.dylib:
> Address: libdyn.dylib[0x0000000000003f18] (libdyn.dylib. __TEXT.__ text + 0)
> Summary: libdyn.dylib`dyn.dyna1foo() -> stat.MyFoo Address: libdyn.dylib[0x0000000000003f2c] (libdyn.dylib. __TEXT.__ text + 20)
> Summary: libdyn.dylib`stat.MyFoo.init() -> stat.MyFoo Address: libdyn.dylib[0x0000000000003f30] (libdyn.dylib. __TEXT.__ text + 24)
> Summary: libdyn.dylib`type metadata accessor for stat.MyFoo
> 3 matches found in libdyn2.dylib:
> Address: libdyn2.dylib[0x0000000000003f18] (libdyn2.dylib. __TEXT.__ text + 0)
> Summary: libdyn2.dylib`dyn2.dyna1foo() -> stat.MyFoo Address: libdyn2.dylib[0x0000000000003f2c] (libdyn2.dylib. __TEXT.__ text + 20)
> Summary: libdyn2.dylib`stat.MyFoo.init() -> stat.MyFoo Address: libdyn2.dylib[0x0000000000003f30] (libdyn2.dylib. __TEXT.__ text + 24)
> Summary: libdyn2.dylib`type metadata accessor for stat.MyFoo
> 
> ```
> 
> I have a problem, because there are two `type metadata accessor for stat.MyFoo`.
> 
> I might not be correct, tho. I would appreciate if anybody would correct me if I'm mistaken.
> 
> Edit:  
> And sometimes you can get warning, for example if you change `MyFoo` from `struct` to `class` you can get this warning: `objc[93532]: Class _TtC4stat5MyFoo is implemented in both /path/libdyn2.dylib (0x1048180d0) and /path/libdyn.dylib (0x1048080d0). One of the two will be used. Which one is undefined.`

---

<div class="post-metadata">

**Author:** ![eskimo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/eskimo/32/13558_2.png) [@eskimo](https://forums.swift.org/u/eskimo)\
**Post date:** [March 18, 2024, 9:29am UTC](https://forums.swift.org/t/is-it-allowed-in-ios-swift-dynamic-framework-contains-multiple-static-library/70732/3 "2024-03-18T09:29:01Z")

</div>

[link](https://developer.apple.com/forums/thread/748419)
