Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities

See the essence through the problem!!

Some potholes encountered during CocoaPod library production

1. The remote authentication fails

Local private repository authentication passes, but private repository authentication on remote repository fails

  1. Wrong path
Error[iOS] file patterns: The `source_files` pattern did not match any
Copy the code

Solution: Re-open the xxx.podspec file and edit it to make sure the shared file path is correct, then upload it to Github for verification.

  1. Remote validation failed when uploading XXX. Podspec to Github in the wrong order: you must first upload all files from your local folder to Github
git add .
git commit -m"add all"
git push origin master
Copy the code

Then tag your podspec and upload it

Git tag -m "git pushCopy the code

2. Pod library relies on the static library of the framework

When your POD library relies on include. When using the Framework’s POD library, an error will be reported when executing the pod install and when using the library.

Es: This error also occurs when creating a pod library directly dependent on Autonavi’s POD library, including s.source_files configuration. Does not contain s.source_files does not have this error

[!]  The 'Pods-Test' target has transitive dependencies that include static binaries: (/Users/admin/Desktop/Test/Pods/AMap3DMap/MAMapKit.framework, /Users/admin/Desktop/Test/Pods/AMapLocation/AMapLocationKit.framework, and /Users/admin/Desktop/Test/Pods/AMapSearch/AMapSearchKit.framework)Copy the code

Solution: Add the following sentence to your project’s podfile:

target 'CLTSwiftLib_Example' do
    ......
    pre_install do |installer| 
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    end
end
Copy the code

3. Related classes, attributes and methods of Swift library cannot be accessed

When creating the POD library for Swift, the classes, attributes, and methods that need to be exposed need to be modified with public, otherwise they cannot be accessed in the project. Another big hole.

4. Search cannot be shared by POD library warehouse and engineering warehouse

Both local and remote authentication passed and the push was successful, but pod Search could not find it.

Solution: in the production of private POD library, it is necessary to separate the warehouse and the project to establish, otherwise there will be verification passed, but can not find the library problem, this paper made private library is to separate the POD warehouse and project warehouse, easy to manage.

5. Using the encapsulated POD library, the report class is implemented in two places

Use directly dependent on Autonavi POD library, package their own POD library, when used in the project will report

Class AMapInitRequestReformer is implemented in both /Users/admin/Library/Developer/CoreSimulator/Devices/3D47A858-C1C7-40D2-8D92-139E3E403BE0/data/Containers/Bundle/Applica tion/2C044E8E-6927-4EAD-B6D3-8BCEBDFE69DA/podMap_Example.app/Frameworks/podMap.framework/podMap (0x1035eae10) and /Users/admin/Library/Developer/CoreSimulator/Devices/3D47A858-C1C7-40D2-8D92-139E3E403BE0/data/Containers/Bundle/Applica tion/2C044E8E-6927-4EAD-B6D3-8BCEBDFE69DA/podMap_Example.app/podMap_Example (0x1014dd7a0). One of the two will be used. Which one is undefined.Copy the code

6. When encountering functions that cannot be realized in SWIFT, OC and SWIFT can be combined.