Multi-Project engineering application based on CocoaPods

One, the main project Project

1) Create  App  Project 

2) Add  the Podfile  of CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
platform:ios,'10.0'

workspace 'WorkSpaceDemo'

def commonPods
    pod 'AFNetworking', '~> 4.0.1'
    pod 'YYKit','~> 1.0.9'
    pod 'MJExtension', '~> 3.1.0'
end

target "WorkSpaceDemo" do
project './WorkSpaceDemo/WorkSpaceDemo.xcodeproj'
    commonPods
    pod 'SDWebImage'
end

3) cd to the directory where the Podfile is located, and pod install implements the pod dependencies of the project

pod install --no-repo-update

2. Module/subproject Project

1)创建 Framework Project(Framework / Static Library / App)

2) Mach-O Type in Build Setting  is changed from Dynamic Library to  Static Library , use static library to build mach-o

3) To provide the ability for external use in the Framework Project,  the Target Membership of the class header file  is set to Public , otherwise an error will be reported when externally referenced

4) Select the Scheme corresponding to Framework Target, Build - Any iOS Device  to build a static Framework

5) The default Build Configuration is Debug, and the framework package provided for the external production environment needs to be changed to Release and then built and exported

6) Import the main project, Embed remains the default ( Do Not Embed )

7) Add the pod configuration of Framework Target, and pod install implements the corresponding pod dependencies

target "FlowerKit" do
project './FlowerKit/FlowerKit.xcodeproj'
    commonPods
    pod 'SSZipArchive'
end

target "LeavesKit" do
project './LeavesKit/LeavesKit.xcodeproj'
    commonPods
    pod 'SDWebImage'
end

target "FruitKit" do
project './FruitKit/FruitKit.xcodeproj'
    commonPods
end

8) Project directory distribution 

3. API calls

1) Add the class declaration provided for external use in the .h file corresponding to the Framework

#import <Foundation/Foundation.h>
#import <FlowerKit/FlowerAPITest.h>
#import <FlowerKit/FlowerUtils.h>

//! Project version number for FlowerKit.
FOUNDATION_EXPORT double FlowerKitVersionNumber;

//! Project version string for FlowerKit.
FOUNDATION_EXPORT const unsigned char FlowerKitVersionString[];

2) Introduce the .h file declaration corresponding to the Framework into the project to realize the call of the specific API

#import "AppDelgate.h"
#import <FlowerKit/FlowerKit.h>

@implementation AppDelgate

- (void)test {
    FlowerAPITest *apiTest = [FlowerAPITest new];
    [apiTest test];
}

@end

Guess you like

Origin blog.csdn.net/z119901214/article/details/129834387