When we look at projects that have AFNetworking look at the project structure

  • 1. There is a Frameworks folder where the various Frameworks of the project are stored
  • 2. Check AFNetworking and find that the Headers file is stored in AFNetworking
  • 3.AFNetworking an executable file

So let’s build a simulation to exercise how to create a Framework library, and do a simple engineering exercise using the project explanation is a continuation of the previous article juejin.cn/post/692616…

Create a file

Make sure the names are the same or link

clang: error: linker command failed with exit code 1

This is essentially a static Framwork library

Link to this framwork

  • 1. Compile test.m into an.o file
Clang -x objective-c-c-fmodules -target x86_64-apple-macos11.1-fobjc-arc - isysroot/Applications/Xcode. App/Contents/Developer/Platforms/MacOSX platform/Developer/SDKs/MacOSX11.1. The SDK -I./Frameworks/TestFramework.framework/Headers -c test.m -o test.oCopy the code
  • Mudule processes.h files
    • The.h file is compiled when import “xxx.h”
    • Clang Mudule precompiles. H files into binary and stores them in the system cache
  • Note that the -i command enters the correct header file path
  • Compile test.o into an executable
Clang-target x86_64-apple-macos11.1 \ -fobjc-arc \ - isysroot/Applications/Xcode. App/Contents/Developer/Platforms/MacOSX platform/Developer/SDKs/MacOSX11.1 SDK \ -f./Frameworks TestFramework test.o -o test //TestExample is actually TestFramework /** Test.o link testExample. framework generates the test executable. -f./Frameworks find the required library file in the subframeworks of the current directory TestExample. Framework dynamic library or static library lookup rule: */ * clang: -x: specifies the language type of the compiled file. -g: specifies the language type of the compiled file. -c: generates the target file, just run preprocess, compile, assemble, no link -o: outputs the file -isysroot: -l <dir> Specify the library file path (.a\.dylib library file) library search path 3. -l<library_name> Specify the linked library file name (.a\.dylib library file) other link flags -lafnetworking -f <directory> Find framework Framework search in the specified directory Path-framework <framework_name> Specifies the framework name of the link other Link flags - Framework AFNetworking */Copy the code
  • The results were successful