我试图访问Main NSBundle以检索版本和构建信息.事情是,我想在swift中尝试它,我知道如何在Objective-C中检索它Build.text = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];.但我不知道从哪里开始使用swift,我试图用新的语法编写它,但没有用.
我正在尝试创建一个捆绑故事板的框架.我已经检查过,创建的.framework包含我的.storyboard文件(作为.storyboardc文件),并且已经获得了在运行时加载故事板的框架.然而,这是一个框架,我希望代码尽可能多样化,我觉得我目前的解决方案有点hacky.目前,我正在使用以下代码加载故事板:
let mainBundlePath: String = NSBundle.mainBundle().resourcePath
let frameworkBundlePath = mainBundlePath.stringByAppendingPathComponent("Frameworks/AuthenticationManager.framework")
let frameworkBundle = NSBundle(path: frameworkBundlePath)
let storyboard = UIStoryboard(name: "Storyboard", bundle: frameworkBundle)
Run Code Online (Sandbox Code Playgroud)
我注意到的一些事情可能是:
Frameworks/)的路径可能会在未来发生变化,而不应该依赖它?NSBundle框架,就无法获得产品名称?可能还有其他问题,上述问题的解决方案,或者上述问题可能不是问题,但我无法想到它们.
这个问题可能更适合Code Review,但我觉得它也适合这里.如果它需要移动到那里,请随意这样做或告诉我这样做.