iOS 中 framework 和 bundle 的制作

iOS打包静态库framework,.a文件及bundle资源包的创建及使用 1.打包framework静态库 之前打包静态库好多步骤记不太清楚了,发现网上给的资料各种各样,好多坑不清楚,而且不太全面,所以自己整理了下资料,供大家参考,细节不足之处还望指正. 设置 Build Setting 中的 COMBINE_HIDPI_IMAGES 为 NO,否则 Bundle 中的图片就是 tiff 格式了。编译生成 Bundle 文件 • 我们分别选择 Generic iOS D....................................... 阅读详情

我的博客原文地址

Framework

Framework 是资源的集合,将静态库和其头文件包含到一个结构中,让 Xcode 可以方便地把它纳入到你的项目中。

在运行时,库中按你的想法暴露需要的头文件,整个工程都可以调用暴露出来的接口和参数,这样减少了内存消耗,提高了系统的性能。

为什么使用 framework

与别人分享自己开发的组件,有两种方式。

  • 直接提供源代码。
  • 将组件代码编译成静态库,供他人调用。

第一种方式容易被人看到具体实现的细节,这些可能是你不想暴露出来的。此外,开发者也可能并不想看到你的所有代码,而仅仅是希望将功能的一部分植入到自己的应用中。

因此很多组件的封装采用第二种方式,这也是下文介绍的主要内容。

配置静态库工程

步骤1:打开 Xcode ,依次点击 Create a new Xcode project → iOS → Cocoa Touch Framework,在 Product Name 中填写名称。(注:这就是最后 framework 的名称。)

步骤2:假如你的项目依赖某些系统库,那么需要通过点击 Targets → Build Phases → Link Binary with Libraries,点击 + 符号将它们添加到工程中。

步骤3:修改 Project 中的 iOS Deployment Target 版本号,选择你的框架最低支持的 iOS 版本。

步骤4:如果组件中存在 .xib 文件,请确保 TARGETS → Build Phases → Copy Bundle Resources 下存在该 xib 文件。

步骤5:将封装好的组件文件夹拖入到项目目录下,选择你要公开的头文件。

步骤6:依次点击 TARGETS → Build Phases → Headers,目录下有:

  • Public:存放公开的头文件,给外部调用。
  • Private:存放私有的 Header,但头文件在编译之后还会存在。一般用来存放项目中需要调用但又不想给别人看到其内部实现的文件。
  • Project:隐藏的文件。

导出 framework

选中 Scheme 选择当前项目,然后右边设备依次选中 Generic iOS Device(通用真机版本)和任一模拟器,分别编译(command + B),成功将会自动跳转到打出的 .framework 文件相应的目录下。

合成 framework

为了让用户能统一调用一个 framework ,还需要将二者合成为一个 framework 。这里介绍一种简单的方法:

1、新建一个 target,依次点击 TARGETS 左下角的加号按钮 → Cross-platform → Other 下的 Aggregate。

2、点击工程文件,选 TARGETS → 刚才创建的 Aggregate → Build Phases → + → New Run Script Phases。在当前栏目里会多出一个 Run Script ,在里面输入以下脚本:

#!/bin/sh
#要build的target名
TARGET_NAME=${PROJECT_NAME}
if 
ios 自制Framework 获取指定bundle并读取里面的资源 应用中某些模块需要组件化,组件化后的工程最后会做二进制化处理,打包成.framework文件。 今天简单聊一下在主工程或其他组件中是如何访问自制组件.framework中的bundle,及其中资源的。 访问应用资源 我们知道苹果应用是基于沙盒机制, 打包生成.ipa后的资源会被放到沙盒的根目录下。通常在主工程中我们是这样访问资源的: NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"plist"] 阅读详情

相关推荐

iOS中.a和.framework静态库的创建与.bundle资源包的使用详解

主要给大家介绍了关于在iOS中.a和.framework静态库的创建与.bundle资源包的使用的相关资料,文中介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。

别再傻傻分不清!Synopsys DC综合中link/target/symbol/synthetic四大库的保姆级配置指南

本文详细解析了Synopsys DC综合中link_library、target_library、symbol_library和synthetic_library四大库的配置方法,帮助工程师避免常见错误。通过实战示例和调试技巧,指导如何正确设置工艺库与IP库,提升数字芯片设计效率。

weixin_42562079的博客 423

从CTFShow靶场实战,聊聊Node.js原型链污染漏洞的几种利用姿势(附详细复现步骤)

本文深入剖析Node.js原型链污染漏洞的原理与实战利用,通过复现CTFShow靶场题目(web338-web341),详细演示五种高级利用技巧,包括基础污染、多级污染、模板引擎RCE等,并提供防御方案与最佳实践,帮助开发者提升Web应用安全性。

weixin_30791095的博客 446

手机摄影新宠:In-line Hardware EIS如何让你的4K视频稳如鸡头(附实测对比)

本文深入解析了手机摄影中的In-line Hardware EIS(硬件级行内电子图像稳定)技术。通过对比传统软件EIS,阐述了其通过硬件管道实时处理实现极低延迟、减少画面裁切和有效抑制果冻效应的核心优势,并结合4K视频的日夜间实测,展示了该技术如何让手持拍摄的视频“稳如鸡头”,显著提升创作体验与成片质量。

tree的博客 994

康耐视CogPMAlignTool模板匹配详解

康耐视CogPMAlignTool是一款基于边缘特征的模板匹配工具,适用于工业视觉检测。该工具提供PatMax、PatQuick、PatFlex等不同算法,分别对应高精度、快速匹配和柔性表面等应用场景。关键参数包括特征粒度(粗糙/精细)、边缘阈值、弹性范围等,支持旋转缩放匹配和极性忽略功能。工具操作流程包括图像采集、参数设置、模板训练和运行检测,通过调整查找概数、接收阈值等参数可优化识别效果。配套的卡尺工具(CogCaliperTool)通过一维投影和边缘筛选实现精准定位,适用于高精度尺寸测量场景。

2502_92473474的博客 1318

告别C盘空间焦虑!Miniforge环境路径精准配置全攻略

本文深入解析Miniforge虚拟环境默认占用C盘空间的根本原因,即未正确配置`.condarc`文件中的`envs_dirs`路径优先级。通过详细的诊断步骤与配置命令,指导用户将环境路径精准迁移至指定磁盘(如D盘),并分享禁用自动激活、使用`--prefix`参数等高阶技巧,帮助开发者彻底告别C盘空间焦虑,实现虚拟环境的整洁与可控管理。

weixin_28831399的博客 238

华为OD机试双机位C卷-用户入网定期复评(C/C++/Py/Java/Js/Go)

华为OD机试(机考)双机位C卷 【用户入网定期复评】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【用户入网定期复评】。

qq_45776114的博客 837

多智能体强化学习MATD3算法完整复现与分析

多智能体强化学习MATD3算法复现与分析摘要 MATD3算法是多智能体深度强化学习领域的重要进展,通过改进MADDPG算法,引入双Q学习、延迟策略更新和目标策略平滑等技术,显著提升了算法稳定性。本文完整复现了MATD3算法,详细解析了其数学原理,包括部分可观测马尔可夫博弈模型和TD3核心思想。在实现层面,设计了集中式Critic和分布式Actor的神经网络架构,采用PyTorch框架构建了Actor-Critic网络模块,包含精心设计的权重初始化和训练流程。该算法有效解决了多智能体环境中的非平稳性、信用分配

max500600的博客 529

计算机网络基础:认识网络硬件与传输介质

计算机网络基础:认识网络硬件与传输介质,在计算机网络的庞大体系中,网络硬件与传输介质犹如坚实的骨架与脉络,支撑并承载着信息的流动。从家庭中的小型网络,到企业复杂的办公网络,再到覆盖全球的互联网,各类网络硬件设备各司其职,不同的传输介质发挥着独特的传输作用。它们相互协作,使得数据能够在不同设备之间快速、准确地传输,为人们的日常沟通、工作办公、娱乐休闲等活动提供了基础保障。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 3万+

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: iOS进阶之巧用IBInspectable属性和IB_DESIGNABLE宏定义
下一篇: 【译】Fucking SwiftUI
FiTeen
博客等级 码龄10年 9粉丝 23原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值