iOS架构之路07 -- .framework静态库依赖Coco

2021-09-15  本文已影响0人  YanZi_33
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'FMyCategory' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!
  # Pods for FMyCategory
  pod 'Masonry'

end

target 'FMyCategoryBundle' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for FMyCategoryBundle
end
#!/bin/sh

#  ScriptPod.sh
#  FMyCategory
#
#  Created by liyanyan33 on 2021/9/10.
#  
#!/bin/sh

#工程名
PROJECT_NAME=FMyCategory

#工作空间
WORKSPACE_NAME=${PROJECT_NAME}.xcworkspace

#工程路径
PROJECT_DIR=$(pwd)

#build之后的文件夹路径
BUILD_DIR=$PROJECT_DIR/Build/Products
BUILD_ROOT=$PROJECT_DIR/Build/Products

#打包模式 Debug/Release 默认是Release
development_mode=Release

#
UNIVERSAL_OUTPUTFOLDER=${PROJECT_DIR}/${development_mode}-universal
INSTALL_DIR_A=${PROJECT_DIR}/${PROJECT_NAME}.framework/${PROJECT_NAME}


# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"


# Step 1. Build Device and Simulator versions
xcodebuild -workspace "${WORKSPACE_NAME}" -scheme "${PROJECT_NAME}" -configuration ${development_mode} -sdk iphoneos ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean

xcodebuild -workspace "${WORKSPACE_NAME}" -scheme "${PROJECT_NAME}" -configuration ${development_mode} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean


xcodebuild -workspace "${WORKSPACE_NAME}" -scheme "${PROJECT_NAME}" -configuration ${development_mode} -sdk iphoneos ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" build

xcodebuild -workspace "${WORKSPACE_NAME}" -scheme "${PROJECT_NAME}" -configuration ${development_mode} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" build


# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${development_mode}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"


# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${development_mode}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"

echo "======合成结束======"

# Step 5. Convenience step to copy the framework to the project's directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"

# -f 判断文件是否存在
if [ -f "${INSTALL_DIR_A}" ]
then
echo "======验证合成包是否成功======"
lipo -info "${INSTALL_DIR_A}"
fi

#打开目标文件夹
open "${PROJECT_DIR}"

image.png image.png
#import "SFViewController.h"
#import "Masonry.h"

@interface SFViewController ()

@property(nonatomic,strong)UIImageView *im;

@property(nonatomic,strong)UILabel *label;

@end

@implementation SFViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"FMyCategoryBundle" ofType:@"bundle"]];
    NSString *path = [[bundle resourcePath] stringByAppendingPathComponent:@"sf_navBack_hl"];
    
    self.im = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    self.im.image = [UIImage imageWithContentsOfFile:path];
    [self.view addSubview:self.im];
    
    self.label = [[UILabel alloc]init];
    self.label.text = @"SFViewController vs MASConstraintMaker";
    self.label.textColor = [UIColor redColor];
    self.label.font = [UIFont systemFontOfSize:18];
    [self.view addSubview:self.label];
    //使用Masonry布局
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
    }];
}
@end
image.png image.png
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

use_frameworks!

target 'Test_FrameworkPodsProject' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  
  # Pods for Test_FrameworkPodsProject
  pod 'Masonry'

end
image.png image.png
上一篇下一篇

猜你喜欢

热点阅读