# Swift4动态获取命名空间

**URL:** <https://www.shiqidu.com/t/topic/288>\
**Category:** 开发调优\
**Tags:** Swift\
**Created:** [2017 年11 月 19 日 15:46 UTC](https://www.shiqidu.com/t/topic/288 "2017-11-19T15:46:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
发布日期： [2017 年11 月 19 日 15:46 UTC](https://www.shiqidu.com/t/topic/288/1 "2017-11-19T15:46:52Z")

</div>

```swift
// 动态获取命名空间  
guard let namespace = Bundle.main.infoDictionary![&quot;CFBundleExecutable&quot;] as? String else {  
    myLog(&quot;获取命名空间失败&quot;)  
    return  
}  

```
