以编程方式在项目中获取框架数组 - Xcode

时间:2014-11-09 19:57:47

标签: ios objective-c iphone xcode swift

我想以编程方式获取Xcode项目中的框架或当前文件的数组。我需要用什么代码才能做到这一点?

1 个答案:

答案 0 :(得分:4)

要列出框架,您可以使用[NSBundle allFrameworks]

  

返回的数组包括在构建应用程序时链接到应用程序的框架和用于动态创建的框架的包。

for (NSBundle *framework in [NSBundle allFrameworks]) {
    printf("%s : %s\n",
        framework.bundleURL.lastPathComponent.UTF8String,
        framework.bundleIdentifier.UTF8String
    );
}

在iOS模拟器中运行裸“单视图应用程序”模板的结果

CoreUI.framework : com.apple.CoreUI
Accounts.framework : com.apple.Accounts
lib : (null)
AggregateDictionary.framework : com.apple.AggregateDictionary
CoreTelephony.framework : com.apple.coretelephony
CommonUtilities.framework : com.apple.commonutilities
QuartzCore.framework : com.apple.QuartzCore
CoreText.framework : com.apple.CoreText
system : (null)
ConstantClasses.framework : com.apple.ConstantClasses
OpenGLES.framework : com.apple.opengles
AudioToolbox.framework : com.apple.audio.toolbox.AudioToolbox
IMFoundation.framework : com.apple.imfoundation
Foundation.framework : com.apple.Foundation
CoreVideo.framework : com.apple.CoreVideo
SimulatorClient.framework : com.apple.iphonesimulator.SimulatorClient
CoreMedia.framework : com.apple.CoreMedia
TelephonyUtilities.framework : com.apple.TelephonyUtilities
TextInput.framework : com.apple.TextInput
BackBoardServices.framework : com.apple.BackBoardServices
AVFoundation.framework : com.apple.avfoundation
PrintKit.framework : com.apple.framework.PrintKit
AppSupport.framework : com.apple.AppSupport
UIFoundation.framework : com.apple.UIFoundation
MobileAsset.framework : com.apple.MobileAssets
introspection : (null)
JavaScriptCore.framework : (null)
CommunicationsFilter.framework : com.apple.communicationsfilter
CFNetwork.framework : com.apple.CFNetwork
MobileCoreServices.framework : com.apple.MobileCoreServices
AddressBook.framework : com.apple.AddressBook
CoreImage.framework : com.apple.CoreImage
FrontBoardServices.framework : com.apple.FrontBoardServices
WebKitLegacy.framework : com.apple.WebKitLegacy
DataMigration.framework : com.apple.datamigration
ProofReader.framework : com.apple.ProofReader
DictionaryServices.framework : com.apple.DictionaryServices
PlugInKit.framework : com.apple.pluginkit.framework
UIKit.framework : com.apple.UIKit
BaseBoard.framework : com.apple.BaseBoard
SpringBoardServices.framework : com.apple.SpringBoardServices
GraphicsServices.framework : com.apple.GraphicsServices
vecLib.framework : com.apple.Accelerate.vecLib
FontServices.framework : com.apple.FontServices
MediaToolbox.framework : com.apple.MediaToolbox
OAuth.framework : com.apple.OAuth
CoreData.framework : com.apple.CoreData.PersistenceTesting
WebCore.framework : com.apple.WebCore
FaceCore.framework : com.apple.vision.FaceCore
AssetsLibraryServices.framework : com.apple.AssetsLibraryServices
DataAccessExpress.framework : com.apple.dataaccess.dataaccessexpress.framework
PhysicsKit.framework : com.apple.PhysicsKit
CoreFoundation.framework : com.apple.CoreFoundation
AssertionServices.framework : com.apple.AssertionServices
DTDDISupport.framework : com.apple.DTDDISupport
Celestial.framework : com.apple.Celestial