preface

We can find libraries on Cocoapods that either see the source code or expose only the framework and.h. Following on from the previous article, we can see the source code after we publish it. Next, we will look at how to make the private library Framework without exposing the source code.

process

Create a project

I import the source code to be packaged and import the source code dependencies using Cocoapods



Build Phases->Headers public: The.h file is to be made public, so that it can be accessed from the following Project

In the directory nrBaseFramework. h can be imported so that the caller can import all classes by simply importing nrBaseFramework. h

#import <NRBaseFramework/UtilsMacros.h>
...
Copy the code

Build Settings->Linking

Change the supported version

Add ignore ARM64, Build Active Architecture Only = NO

Support bitcode (I support bitcode here, the method is as follows)

Build Settings -> DEPLOYMENT_POSTPROCESSING = YES Build Settings -> Compiler Flags Adds the -fembed-bitcode parameter Build Settings -> Enable Bitcode is YESCopy the code

Edit Scheme Run Release, then command+B in Any iOS Device and Any emulator respectively. Open the Products framework in the directory and right-click Show in Finder to see two folders

Note that the path of the following two files is to the NRBaseFramework file under the framework, directly drag from the folder to the terminal: Lipo-create is followed by the NRBaseFramework file from the framework underneath iphones plus the NRBaseFramework -output path from the framework underneath iphonesCopy the code

Make a copy of the framework under the iPhone above and replace the NRBaseFramework file under the framework with the merged NRBaseFramework file so that the current framework is the merged framework

The process for creating the sample project is the same as the previous private libraryCocoapods private libraryPut the framework into Classes under Pod. Then the dependency libraries in podSpec need to be introduced. The framework needs to use s.endored_frameworks. Of course, you can also put it directly in the directory, the introduction of the correct path.

Example below pod install check if you have any questions, then pod spec lint, pod repo push, pay attention to the need to use – here the skip – import – validation, otherwise can’t pass

The problem

If Build Active Architecture Only = NO is set to Debug, third-party libraries cannot be found

Just change the Scheme Run to Release. I see a lot of packaging scripts also have Release versions. There are also third-party library code into the source code, packaged together into the Framework is also a way to refer to: package their own Framework contains third-party library solutions divided into CocoaPods and manual import two ways

reference

How does The iOS Framework support Bitcode and bitcode detection Xcode12 fit The Linked library is missing one or more architectures required by this Target problem