IOS (13)

IOS | UIBezierPath rounded corners don’t show all problems and solutions

Sg. Jianshu. IO/p/f936bb30f…

The default RADIUS display is at most half the width and height, but you can make radius display more by moving the mask’s y. Note that the layer height of the mask is >= 2* RADIUS about Module

  1. Using modules makes the original #import file contain a semantic import.

When creating a framework, a header file with the same name as the framework is automatically created, and the Module mechanism is enabled by default. After packaging, a module.moduleMap file is generated.

  1. Once I enable the Module mechanism in Xcode, the original #import in the program is automatically converted to @import.

A project’s Module mechanism is enabled by default, allowing us to import the system framework without manually adding dependent libraries

  1. Modules can be compiled once and used everywhere. This saves compilation time and eliminates the need for the PCH mechanism to compile files. With PCH, it is impossible to determine what dependencies the current module has, and it also makes the code less portable.

  2. You can use #import moduleName/header.h to reference your own header file in your module’s internal project. A folder can be abstracted as a module through the module.modulemap file. github.com/drekka/Alch…

  3. You can customize module. moduleMap in the project and use @import in the test project

Github.com/drekka/Alch…

ref: Modular framework, creating and using them

  1. Use modules.
Replace #import <Cocoa/Cocoa.h> with @import Cocoa;
You can also import just one header with this notation:
@import iAd.ADBannerView;
Copy the code

The submodules autocomplete for you in Xcode.

Stackoverflow.com/questions/1…

The pros and cons of the Module mechanism

Semantic import

Modules improve access to the API of software libraries by replacing the textual preprocessor inclusion model with a more robust, more efficient semantic model. From the user’s perspective, the code looks only slightly different, because one uses an import declaration rather than a #include preprocessor directive:

import std.io; // pseudo-code; see below for syntax discussion
Copy the code

However, this module import behaves quite differently from the corresponding #include <stdio.h>: when the compiler sees the module import above, it loads a binary representation of the std.io module and makes its API available to the application directly. Preprocessor definitions that precede the import declaration have no impact on the API provided by std.io, because the module itself was compiled as a separate, standalone module. Additionally, any linker flags required to use the std.io module will automatically be provided when the module is imported [1] This semantic import model addresses many of the problems of the preprocessor inclusion model:

  • Compile-time scalability: The std.io module is only compiled once, and importing the module into a translation unit is a constant-time operation (independent of module system). Thus, the API of each software library is only parsed once, reducing the M x N compilation problem to an M + N problem.
  • Fragility: Each module is parsed as a standalone entity, so it has a consistent preprocessor environment. This completely eliminates the need for __underscored names and similarly defensive tricks. Moreover, the current preprocessor definitions when an import declaration is encountered are ignored, so one software library can not affect how another software library is compiled, eliminating include-order dependencies.
  • Tool confusion: Modules describe the API of software libraries, and tools can reason about and present a module as a representation of that API. Because modules can only be built standalone, tools can rely on the module definition to ensure that they get the complete API for the library. Moreover, modules can specify which languages they work with, so, e.g., one can not accidentally attempt to load a C++ module into a C program.

Problems modules do not solve

Many programming languages have a module or package system, and because of the variety of features provided by these languages it is important to define what modules do not do. In particular, all of the following are considered out-of-scope for modules:

  • Rewrite the world ‘s code: It is not realistic to require applications or software libraries to make drastic or non-backward-compatible changes, nor is it feasible to completely eliminate headers. Modules must interoperate with existing software libraries and allow a gradual transition.
  • Versioning: Modules have no notion of version information. Programmers must still rely on the existing versioning mechanisms of the underlying language (if any exist) to version software libraries.
  • Namespaces: Unlike in some languages, modules do not imply any notion of namespaces. Thus, a struct declared in one module will still conflict with a struct of the same name declared in a different module, just as they would if declared in two different headers. This aspect is important for backward compatibility, because (for example) the mangled names of entities in software libraries must not change when introducing modules.
  • Binary distribution of modules: Headers (particularly C++ headers) expose the full complexity of the language. Maintaining a stable binary module format across architectures, compiler versions, and compiler vendors is technically infeasible.

WWDC: From the WWDC slides:

* Imports complete semantic description of a framework
* Doesn't need to parse the headers
* Better way to import a framework’s interface
* Loads binary representation
* More flexible than precompiled headers
* Immune to effects of local macro definitions (e.g. #define readonly 0x01)
* Enabled for new projects by default
Copy the code

Ref:clang.llvm.org/docs/Module…

Swift uses the module mechanism to use the C library

Getting Started Using C Libraries from Swift
Creating Objective-C modules
Private module map for a framework
Importing CommonCrypto in a Swift framework
github:
Copy the code

Github.com/onmyway133/…

Github.com/tiger8888/J…

About modules and PCH

For modern iOS and OS X, people should be using Modules. This is enabled by default for new projects, and importing/inclusion is accomplished using @import. Modules allow the compiler to create an intermediate representation of the contents of a module (e.g. a framework’s headers). Much like a PCH, this intermediate representation may be shared across multiple translations. But modules take this one step further because a module is not necessarily target specific, and their declarations need not be localized (to a *.pch). This representation can save you a ton redundant compiler work.

Using modules, you do not need a PCH, and you probably should just do away with them entirely — in favor of using @import local to the dependency. In that case, a PCH is only saving you from typing inclusions local to dependencies (which IMO you should be doing anyway).

Ref:stackoverflow.com/questions/2…

Xcode Precompile Prefix Header

1. If you want to use prefix header, first add PCH file in the project, and then set the following in build Setting:

2. Using PCH files has two advantages: one is to save the compilation time of header files, and the other is to make all files can directly use the PCH file header files.

Xcode8 has prefix header turned off by default. In Xcode 6, Precompile Prefix Header is removed for the following reasons: (1) Remove the automatically imported system framework class library Header file, which can improve the reuse of the original file and facilitate migration. (2) A fat Prefix Header will greatly increase Build Time.

Xcode8 module mechanism is enabled by default.

5. Drawbacks of PCH files:

Xcode Precompiled Headers: 4 Ways They Cripple Your Code

Ref :Xcode Precompile Prefix Header – Jymn_Chen – CSDN.NET

About the difference between groups and folders

NSBundle (Custom Bundle) NSBundle (Custom Bundle

The files in Xcode’s group are packed and placed in the root directory. And files that are in folders, they’re still in folders. Then the way they quote will be different.

Displays information such as environment variables in Xcode

Xcodebuild-project TESTCordovaLib. Xcodeproj -target "TESTCordovaLib" -showbuildSettings / / display information about the workspace, such as Scheme information xcrun xcodebuild - list - workspace HealthMonitorApp. Xcworkspace / / display the information about the pod in the workspace Xcrun xcodebuild showBuildSettings - workspace HealthMonitorApp. Xcworkspace - scheme Pods - HealthMonitorApp some commonly used environment variables: Suppose a Project has a path of XXX/ProjectX. $SRCROOT: XXX/ProjectXCopy the code

ref: Xcode Build Settings – Products Path

A workaround for the following error in Xcode

I had similar issue ad problem was there was an info.plist file in one of the folder in framework that i downloaded from GitHub , deleting it fixed the issue.

In fact, there are many reasons for the above problems, and the above is only one solution.

copypng emitted errors but did not return a nonzero exit code to indicate failure

Build Phases -> Copy Bundle Resources, Any fileName is red color?

Or

Convert Logo Retina.png or Create it again, maybe it’s an encoding\format issue.

Or

Rename “Logo Retina.png” to “LogoRetina.png”.

Or It also happens when you have multiple images with the same name in TARGET->Build Phases->Copy Bundle Resources. If there are pictures with the same file name, delete the redundant pictures

XCode uses regular expressions to find replacement characters

To replace a string like [UIColor hx_colorWithHexRGBAString:@”#000000″] with a custom macro. Such as HEXCOLOR (0 x000000).

Select Replace\Regular Expression in XCode Replace and fill in the corresponding re

\[UIColor hx_colorWithHexRGBAString:@ "#(.*)\"\] replace HEXCOLOR(0x$1)Copy the code

$1 is the character that the re matches.

XCode uses XConfig to configure multiple urls

1. Set the corresponding Config in the project

2. Create different macros in PreProcessors Macro in build Setting according to different config and add different Macro definitions in User-defined. Then in the project’s global header file:

# ifdef SERVERKIND_DEMO / / Demo environment Demo # define kServerUrl @ # "http://api.demo.lifesea.com/" elif SERVERKIND_EXHIBITION / / 828 Exhibition environment Exhibition # define kServerUrl @ # endif "http://172.16.105.222:8006/"Copy the code

3. Set a reference to user-defined in the target Info, for example, the Bundle Display Name

4. Add Scheme to Scheme in XCode and select config from Build Configuration under run. Implement one-to-one mapping between Scheme and Config. In the future, when running the project, select the corresponding Scheme.

[000] Usage of XCConfig Usage of XCConfig

Open the APP Document Folder Folder installed in the emulator:

Set and hit a breakpoint in the app, and write the following in the console:

po NSHomeDirectory()
Copy the code

Then in Finder hit CMD+G, paste the path returned above and hit enter.

Or the following method can be used:

Open up Terminal.app and run:

xcrun simctl get_app_container booted [app identifier]
Copy the code

You can even setup an alias to change to the directory, like:

alias cdmyapp='cd $(xcrun simctl get_app_container booted com.mycompany.myapp)'
Copy the code

Ref:stackoverflow.com/questions/3…

One way to keep Xcode8 using the original plug-in.

  1. Compile MakeXcodeGr8Again and export its product (more on MakeXcodeGr8Again below).

  2. Exit Xcode8, run MakeXcodeGr8Again which you just exported, drag Xcode8 into it, and wait for some time (3-10 minutes).

  3. When the Daisy is finished, an XcodeGr8 application will be generated in the application folder, Run the command sudo xcode – select – s/Applications/XcodeGr8. The app/Contents/Developer will point to just generate XcodeGr8 xcode development path. Verify that the generated XcodeGr8 works properly. If normal delete to the original Xcode. App. The name of newly generated XcodeGr8 to Xcode, app, and then run the sudo Xcode – select – s/Applications/Xcode. The app/Contents/Developer.

Then start installing a plug-in, plug-in installed in/Users/taivex2 / Library/Application Support/Developer/Shared/Xcode/plug-ins directory.

  1. Now that the Xcode8 signature has been removed, you can continue to fix the broken plug-in code above. The code is as follows:

find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID

ref:medium.com/@vong9262/%…

Codesign for the IOS Framework

From reading the linked thread on the Carthage repo it seems relatively simple. If you are distributing the binary framework you need to code sign it and if you are distributing the source via carthage or cocoa pods you do not as those tools take care of this via different methods. The reason you need to code sign it when you distribute the binary framework is that Xcode won’t produce a framework binary without code signing it. If you attempt to not code sign the binary framework you get this error:

Code signing is required for product type ‘Framework’ in SDK ‘iOS 8.1’

It doesn’t matter which identity you code sign the framework with (iPhone Developer or iPhone Distribution) because, as you point out, the framework will be re-codesigned with the “code sign on copy” setting. This means that your framework will be re-codesigned by the appropriate certificate from the framework consumer’s developer profile when your framework is copied into their application. This means there will be no issues with the App Store as it will only see the final code signature from the framework consumer.

In the end of the day, you might as well code sign your .framework binary as you don’t want to have to maintain an exotic build process, and as Xcode will only output signed frameworks you shouldn’t move too far away from the defaults. It doesn’t really matter anyway because the end consumer will be re-signing it.

Ref:stackoverflow.com/questions/3…

The framework containing a Simulator Slice cannot be submitted to the App Store

Github.com/lionheart/o…

About IOS Framework

1. If you want the Framework to be referenced as a module, then in the Framework project:

Module.modulemap file will be generated in the generated framework:

2. Modularity in SWIFT

https://github.com/drekka/Alchemic Creating Objective - C modules Wrapping a C Library, in a Swift Framework Colin, DrakeCopy the code

3. Detailed process of framework production: github.com/tiger8888/i…

4. For resource management, you can add a bundle target and drag it to the Framework target to copy the Bundle resource.

demo:https://github.com/tiger8888/iOS-Framework
Copy the code

5. Generate a general framework using the Xcode Library Universal Shell Script

About IOS Framework making and Cocopods

  1. The podfile for the YohunlUtilsLib Framework project is shown below.
Platform: ios, '7.0' inhibit_all_warnings! target 'YohunlUtilsLib' do pod 'AFNetworking' end target 'YohunlUtilsLibTests' do endCopy the code

The AFNetworking library is not included in the framework. If the yohunlutilslib. framework is used by others, they should add AFNetworking to the project. Otherwise, an error message will be displayed.

Cocoapods application Part 1 – Xcode creation. Framework Related – Yohunl column – blog channel – CSDN.NET3

The difference between Optional(weak reference) and Required(strong reference) of iOS developer. Framework

Strongly-referenced frameworks are always loaded into memory, but weakly-referenced frameworks are loaded into memory only when needed, which saves a lot of time for larger frameworks in the initial loading process.

To clarify, some libraries, such as Social. Framework and adsupport. framework, were introduced after iOS6, and some have been updated with new features that are only available on iOS6+. When you add a framework to your project, they are strongly referenced by default. However, when you finally configure the application on a device running 5.0, you will find that it will not pass the most common load because these libraries are not supported by iOS5.0. We need to change the references to these libraries to Optional.

Second, if you come across this error: duld:Library not found……………… Indicate that you have an existence that should not be strongly referenced

2. Link command

Weak_framework PassKit If you’d want weak-link it, use-weak_framework PassKit, weak_framework PassKit, weak_framework PassKit, weak_framework PassKit, weak_framework PassKit, weak_framework PassKit

Ref:stackoverflow.com/questions/1…

Xcode6 Framework Missing SubModule XXX warning

Starting with xcode6, iOS can create the generated framework directly

Such as: Create a Framework project, The tfKit. framework automatically generates tfKit. h and then we add our own classes and provide tfa. h, tfb. h so we need to import #import from tfKit. h <TFKit/ tffb.h > <TFKit/ tfkit. h> <TFKit/ tfkit. h> <TFKit/ tfkit. hCopy the code

Ref: Create and use the bundle target

1. After setting up the Bundle target, go to Build Settings to set parameters

"Base SDK" set to "IOS Latest SDK" (Xcode 6.3.2 as an example) "Build Active Architecture Only" set to "YES" "Debug Information Format" Set "DWARF with dSYM File" "OS X Deployment Target" to "Compiler Default "and delete "Skip Install" to "YES" "Strip Debug" "Symbols During Copy" in "Release" mode set to "YES", "IOS Deployment Target" set to "IOS 7.0", "COMBINE_HIDPI_IMAGES" set to "NO"Copy the code

Why is Skip Install set to YES?

Set the setting Skip Install to Yes for any static library or bundle target that you create. Check all the targets that are dependencies of your application project. If the option is No then you will be unable to build an archive of the project containing the target dependencies. Xcode will create a Generic Xcode Archive, which cannot be shared adhoc, validated, or submitted.

2. Generally speaking, a separate bundle is required to create a static library. The framework already contains the structure of the resources.

2. Use resources from the bundle

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle) *)nibBundleOrNil {//FDResidentSelectVC self = [super initWithNibName:@"FDResidentSelectVC" bundle:[BundleTools getBundle]]; return self; } // get the resource bundle NSString *resourceBundlePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"DTPinLockController" ofType:@"bundle"]; NSBundle *resourceBundle = [NSBundle bundleWithPath:resourceBundlePath]; // load View Controller from that UIViewController *vc = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:resourceBundle]; // load image from resource bundle UIImage *image = [UIImage imageNamed:@"DTPinLockController.bundle/Image.png"]; // get a string NSString *string = NSLocalizedStringFromTableInBundle(@"Set Passcode", @"DTPinLockController", resourceBundle, @"PinLock"); oneCopy the code

About preserVE_paths in the POD Spec file

In general, except for the sources, resources, and so on specified in the PodSpec that are added to the project, everything else is removed. If you want to preserve some additional files, you can specify ‘Clean’ in the preserve path that it will delete the files that should be ‘cleaned’. For example if you have a directory with a few files

  • source.h
  • source.m
  • readme.md
  • other.txt

If you just specify the source files as *.{h,m} then those will be added to the project and readme.md and other.txt will be removed. If you for some reason wanted the user to be able to access one of those files you would add it to the Preserve_paths so it order to not get the delete. Ref: stackoverflow.com/questions/1…

If you cannot specify public_headers in a subspec, use preserve_paths to specify headers. I managed to add the static library as a subspec. I prefer this approach because it uses the build shipped with my pod by default, and also enables users to provide their own build if they so desire. As mentioned, the static library is OpenSSL but the following applies to any static library. I’m using the following directory structure:

Libraries/openssl - e/include / 1.0.1 openssl / * h libraries/openssl - e/LICENSE 1.0.1 libraries/openssl - e/lib / * 1.0.1. ACopy the code

The resulting subspec would be:

S.s ubspec 'OpenSSL' do | OpenSSL | OpenSSL. Preserve_paths = 'libraries/OpenSSL - e/include / 1.0.1 OpenSSL / * h', 'libraries/openssl - 1.0.1 e/include/LICENSE' openssl. Vendored_libraries = 'libraries/openssl - e/lib/libcrypto 1.0.1. A', 'libraries/openssl - e/lib/libssl 1.0.1. A' openssl. Libraries = 'SSL', 'crypto' openSSL.xcconfig = {'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/libraries/ openSSL-1.0.1e /include/**"} endCopy the code

Line by line:

Openssl. Preserve_paths = 'libraries/openssl - e/include / 1.0.1 openssl / * h', 'libraries/openssl - 1.0.1 e/include/LICENSE'Copy the code

Preserve headers and the license file. We will use the headers below.

Openssl. Vendored_libraries = 'libraries/openssl - e/lib/libcrypto 1.0.1. A', 'libraries/openssl - e/lib/libssl 1.0.1. A'Copy the code

Tell CocoaPods that we are shipping the above static libraries in the pod. This will preserve the files, as well as modifying LIBRARY_SEARCH_PATHS accordingly.

openssl.libraries = 'ssl', 'crypto'
Copy the code

Includes the libraries in “Other Linker Flags”.

Openssl.xcconfig = {'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/libraries/ openSSL-1.0.1e /include/**"}Copy the code

Tells the project where to find the headers. We cannot use public_header_files because this is a subspec.

About the Cocoa Pods private library

Cocoapods Apps Part 2 – Private Libraries – Yohunl’s column – blog channel – CSDN.NET

About SDK writing experience:

2. Make a good resource management strategy, and distinguish NSBundle.

3. Try not to use Precompiled headers

4. Do not import files from the header file unless necessary. Use @class instead.

5. If you use the prefix header you need spec. In cocoapods prefix_header_file = ‘iphone/include/prefix. PCH’ specified.

About Cocoapods Project Principle 1: Dependencies

1. The Cocoapods main project has a dummy target which is used to compile other targets in the project:

2. The user project is set to find the reference path, which is the path of the target generated in the previous step, to reference the target needed in the POD.

Link command:

About Cocoapods Project Principle 2: Engineering configuration

1. Related compilation and configuration of POD in the main project is completed through xconfig file:

How to create a project based on Pod Spec management

See the pod Spec: Podspec file

1. Create the template project pod lib create podTestLibrary

Special note: When writing the podSpec file, because you did not create a private pod by: Establish a local Private repos official reference Private http://guides.cocoapods.org/making/private-cocoapods.html Private Pods write very detailed, and also gives a example $pod repo Add REPO_NAME SOURCE_URL where REPO_NAME is the name of the private repO we want to add, followed by the address, note that this is just created in the ~/.cocoapods/repos directory A folder has been added to the directory, but not a spec file has been added to it, causing you to write something like the following in your podSpec file: s.dipendency 'AJKFrame' pod 'AJKFrame', :path => '.. /.. /MVVM/AJKFrame' /MVVM/AJKFrame' /MVVM/AJKFrame' /MVVM/AJKFrame' /MVVM/AJKFrame' "sqlite3","iconv"Copy the code

2. Add the class file, run the Example project, and commit it to Git

$ git add . $ git commit -s -m "Initial Commit of Library" $ git remote add origin [email protected]: wtlucky/podTestLibrary. Git add remote warehouse # $git push origin master # submitted to the remote warehouse Because podspec file access to the Git version control project also need the tag number, $git tag -m "first release" 0.1.0 $git push --tags #Copy the code

3. Run pod lib Lint to check for errors

However, there are some non-syntactic errors that do not give a reason for the error. You can use “–verbose” to view the verbose validation process to help locate errors.

pod spec lint LPPushService.podspec –verbose

Use –verbose to find the cause of the following errors.

- > LPPushService (1.0.0) - ERROR | (iOS) Encountered an unknown ERROR (The 'Pods' target from The transitive dependencies that include static binaries: (/private/var/folders/jz/b_m3k7ln47524cm__h3__mk00000gn/T/CocoaPods/Lint/Pods/BPushSDK/LibBPush/libBPush.a)) during validation.Copy the code

This error is caused by the dependency library including a static library. This does not affect the use of the Pod, but authentication is not passable. This can be done using –use-libraries.

pod spec lint LPPushService.podspec –verbose –use-libraries

The use of –use-libraries in this case will not result in errors, but will sometimes result in waring warnings that will not be validated. Allow warnings with –allow-warnings.

pod spec lint LPPushService.podspec –verbose –use-libraries –allow-warnings

4. If you already have an existing project, you need to create a PodSpec file for that project. To create this file, you need to execute another command from Cocoapods

$ pod spec create PodTestLibrary [email protected]:wtlucky/podTestLibrary.git

5. Submit to Cocoapods official:

Trunk registration:

Pod Trunk Register [email protected] 'Your name' --description='macbook Pro' --verbose pod Trunk me Check registration informationCopy the code

Run pod Trunk Push in the path of your PodSpec file

After running Pod Setup to update your Pods dependency tree, use pod Search YXYNumberAnimationLabel to find the newly added dependency named YXYNumberAnimationLabel

, if can’t find the directory ~ / Library/Caches/CocoaPods /, the following files to delete, pod again search can be found:

Ref: Cocoapods: Make your own Pods

Handling of resources in pod Spec files 1.

General resources can be passed as follows:

s.resources='HealthMonitor/Assets/**/*.png','HealthMonitor/Assets/**/*.jpg','HealthMonitor/Classes/**/*.xib', 'HealthMonitor/Classes/**/*.storyboard' to contain the required resources, but it is important to note that when referencing this resource in a Pod Spec project, you need to use [NSBundle bundleForClass:[self Class]] to explicitly specify bundle. 1. Quotes: self.iconImageView.image = [UIImage imageNamed:@"list_rengong" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil]; NSBundle* bundle=[NSBundle bundleForClass:[self class]]; BloodPressureViewController *controller = [[UIStoryboard storyboardWithName:@"HealthMonitor" bundle:bundle] instantiateViewControllerWithIdentifier:@"BloodPressureViewController"]; 3. Reference xiB file: BodyFatRatioDetailViewController *BloodVC = [[BodyFatRatioDetailViewController alloc]initWithNibName:@"BodyFatRatioDetailViewController" bundle:[NSBundle bundleForClass:[self class]]];Copy the code

Ref :iOS Framework usage record – LeiYinchun’s blog

All resources in pod Spec files are managed in bundles

Add the following to the POD Spec file:

s.resource_bundles = {
'HealthMonitorLib' => ['HealthMonitor/Assets/**/*.png',
                    'HealthMonitor/Assets/**/*.jpg',
                    'HealthMonitor/Classes/**/*.xib',
                    'HealthMonitor/Classes/**/*.storyboard'
                   ]
}
Copy the code

The app package generated by the User Target contains HealthMonitorLib.bundle. Then access the resources:

NSBundle* bundle=[NSBundle bundleForClass:[self class]]; Nsstrings * resourcePath = [pathForResource: @ "HealthMonitorLib ofType:" @ "bundle"]; NSBundle* resourceBundle=[NSBundle bundleWithPath:bundle]; self.iconImageView.image = [UIImage imageNamed:@"list_shebeiluru" inBundle:resourceBundle compatibleWithTraitCollection:nil];Copy the code

Ref: Adds a resource file to Pod

How to write a POD Spec file

1. Explanation of the POD Spec file

Epage: the main page address, such as Github address, s. ricense: License S.Thor: Author S.social_media_URL: Social Networking site s.platform: Platform S.ource: Git repository address, for example, adding. Git to the end of the Github address is the Git repository address. The common format is s.resource files: source files to be included. Dependency libraries. Do not rely on unpublished libraries. If there are multiple dependency libraries, write s.equires_arc: whether ARC is requiredCopy the code

2. Common syntax of S. source_files

"Directory1 / *" "Directory1 Directory2 / *. {h, m}" "Directory1 / / *. * * h" * * "*" matches all file "*. {h, m}" means to match all. H and. M at the end of the file * "* *" Matches all subdirectoriesCopy the code

Error: Include of Non-Modular Header inside Framework Module error: Include of Non-Modular Header inside Framework Module error: Include of non-modular Header inside Framework Module Include of non-modular header inside Framework Module Include of non-Modular Header inside Framework Module

s.pod_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES'
}
Copy the code

The steps to find the above configuration are:

1. Locate the configuration

2. Select it and copy it. Paste it into another text file to get the compilation options for this configuration

Podfile template

Platform: ios, '9.0' inhibit_all_warnings! Target 'MyApp' do pod 'ObjectiveSugar', '~> 0.5' target "MyAppTests" do inherit! :search_paths pod 'OCMock', '~ > 2.0.1' end end post_install do | installer | installer. Pods_project. The targets. Each do | target | puts "# {target. The name}" end  endCopy the code

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Platform :ios,'7.0' workspace' w.cworkspace 'abstract_target 'W' do #pod 'ObjectiveSugar', Target 'Main' do project 'Main/Main' pod 'TMCache','2.1.0' pod 'ReactiveCocoa', '2.4.7' end target 'Lib' do project 'Lib/Lib' inherit! :search_paths # Inherit only the header search path end endCopy the code

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Platform :ios,'7.0' workspace' w.workspace 'abstract_target 'W' do # 'ReactiveCocoa', '2.4.7' target 'Main' do # This is a dependency on pod 'MBProgressHUD','0.9.1' project 'Main' end target 'Lib' do project 'the Lib/Lib inherit! :search_paths end endCopy the code

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Pod Install vs. POD Update

1. When a project is first initialized with pod, pod Install should be used, which generates a podfile.lock file. This file records the exact version number of the dependencies used by the project. When another user initializes the project with the same Podfile, Cocoapods can install the same version of dependencies from the records in Podfile.lock. This ensures the consistency of development. That is, pod Install will always use the records in podfile.lock for existing dependencies

2. Pod Install should be used when adding or removing dependencies from podfiles

3. From the above, we can see that podfile. lock should also be submitted to SVN.

4. When we need to update podfile. lock or dependencies in Podfile, we can use pod update to update specific dependencies, or we can update all dependencies without parameters, and podfile. lock will be updated accordingly.

5. You can use Pod outdated to see which dependencies in your current podfile. lock are outdated, that is, they have a new version.

6. You cannot achieve the effect of podfile.lock by specifying a specific version in your podfile. A.podspec as dependency ‘A2’, ‘~> 3.0 ‘Run pod Install at different times to install different dependencies.

Ref:app.yinxiang.com/shard/s7/nl…

About the pod search

The pod list and pod search commands only search for all third-party libraries that exist in the local ~/.cocoapods folder and do not connect to the remote server. If you want to update the description file of a local third-party library from the server, you can:

$ pod repo update master
Copy the code

Pod Setup is used to initialize the Spec description files of the local third-party library. All the Spec files are stored in the ~/.cocoapods directory.

Common commands about Cocoapods Common commands about Cocoapods

Pod list to list all of the available third-party libraries pod search query search contains query third-party libraries Note: these two commands search only exists in local/Users/yohunl /. Cocoapods/of files If the search network, to update the local pod Repo update master, then search for pod lib create frameworkName to create a Framework project POD Spec Lint -- to verify that pod Spec is used locally Create the podspec file that you added (however, this command usually shows 2 out of 2 specs failed validation. Pod lib lint This is used to verify the validity of the spec of the lib project created by pod lib create (this command can also be used in the first case after checking). Podinstall --no-repo-update error --no-repo-update tells Cocoapods not to update the REPo. Do you feel that pod install is slow every time because the local repO is updated first? With this parameter, the process is skipped and soon pod init can create an empty Podfile to create pod spec file pod Spec Create The class name http://www.theonlylars.com/blog/2013/01/20/cocoapods-creating-a-pod-spec/ pod install command will cause many operations. To learn more about how to execute this command, add --verbose to the end of the command to delete the private library we added. Pod repo remove yohunl pod repo remove yohunlSpecs Run the pod repo add yohunlSpecs command on the terminal [email protected]: yohunl/yohunlSpecs. Git or pod repo add yohunlSpecs https://github.com/yohunl/yohunlSpecs.git It is best to use HTTP mode for git address, but I tried, both are ok, after executing the command in.cocoapods directoryCopy the code

See, there’s our own private warehouse, yohunlSpecs, which is empty

Ref: Cocoapods Apps Part 2 – Private libraries – Yohunl’s column – blog channel – CSDN.NET

The pod Search repository version is lower than github repository version

When we use Cocoapods to do third-party open source library management, we sometimes find that

$ pod search XXX
Copy the code

Version below the latest repository release on Github (note: XXX is the repository name)

Solution: upgrade the Cocoapods version Check the Cocoapods version of the current system. Run the pod –version command

Upgrade Method To uninstall cocopods, run sudo gem uninstall cocoapods -v

$ sudo gem update --system $ gem sources --remove https://rubygems.org/ $ gem sources -a https://ruby.taobao.org/ $ sudo Gem install Cocoa Pods # Sudo gem install -n /usr/local/bin cocoapods $pod setupCopy the code

Among them

$ gem sources --remove https://rubygems.org/ 
$ gem sources -a https://ruby.taobao.org/ 
Copy the code

These two sentences can be omitted, but we in China, or better to add. If you use rubygems.org/, sudo gem install cocoapods will intermittently fail to connect to the resource files stored on Amazon S3. After the upgrade, pod –version again, and you will find that the version number of Cocoapods is higher than the previous version, and the upgrade is successful. Once again,

$ pod search XXX
Copy the code

OK, the latest version of the Github repository is already available.

Problem after: [HeshamMegid/HMSegmentedControl# 77) (github.com/HeshamMegid…).

The solution to the following problem is to find OTHER_LDFLAGS in the project and press Enter until the black highlight of the option disappears. Then update the Pod again.

[!]  The `Lib [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `.. /Pods/Target Support Files/Pods-Lib/Pods-Lib.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target. [!]  The `Lib [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `.. /Pods/Target Support Files/Pods-Lib/Pods-Lib.release.xcconfig'. This can lead to problems with the CocoaPods installationCopy the code

The solution to the following problem is pod Search Not Work JSON ParserError

Delete ~ / Library/Caches/CocoaPods/search_index json, search again

Manage different libraries through sub-projects

1. Create a folder by creating an.xcworkspace file. Then create the main project. Xcodeproj file directly in this folder, library project. Xcodeproj file. 2. Drag the.xcodeproj file for the main project and the.xcodeproj file for the library project into the.xcworkspace. And set up the main project reference library project.

2.1 Lib Framework export header Settings note:

3. In the directory where the.xcworkspace file is located, create Podfile. Note that because of the library project, both are referenced in the main project. So the same third party can only appear once

Platform :ios,'7.0' workspace' u.cworkspace 'target' Main 'do pod 'TMCache','2.1.0' project' Main/Main 'end target 'Lib' do pod 'ReactiveCocoa', '2.4.7' project 'Lib/Lib' endCopy the code

4. Normally, only one instance of an APPLICATION can be opened on the MAC. To open a new instance of an APPLICATION, run the open-n -a “APPLICATION NAME “command www.cnet.com/news/how-to…

Update: When running pod install –verbose Integrating client project Integrating target Pods (AIYOCore.xcodeproj project) [!] The use of implicit sources has been deprecated. To continue using all of the sources currently on your machine, Add the following to the top of your Podfile: source ‘github.com/CocoaPods/S… ‘[!] The Project [Debug] target overrides the OTHER_LDFLAGS build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig’. This can lead to problems with the CocoaPods installation

  • Use the $(inherited) flag, or
  • Remove the build settings from the target.

[!] The Project [Release] target overrides the OTHER_LDFLAGS build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig’. This can lead to problems with the CocoaPods installation

  • Use the $(inherited) flag, or
  • Remove the build settings from the target.

It seems like you don’t have $(inherited) in OTHER LINKER FLAGS. Please post output of the pod install

Stackoverflow.com/questions/2…

There is a conflict between your build settings and the default build settings that Cocoapods wants. To see the Cocoapods build settings, view the file at Pods/Pods.xcconfig in your project. For me this file contains:

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/Commando"
OTHER_LDFLAGS = -ObjC -framework Foundation -framework QuartzCore -framework UIKit
PODS_ROOT = ${SRCROOT}/Pods
Copy the code

If you are happy with the Cocoapods settings, then go to Build Settings for your project, find the appropriate setting and hit the Delete key. This will use the setting from Cocoapods. On the other hand, if you have a custom setting that you need to use, then add $(inherited) to that setting.

Stackoverflow.com/questions/1…

2. Can I ignore xccheckout in SVN?

If it is a single project, in a single repository, it can be ignored. You should check in an Xcode 5. Xccheckout file; if your project is a workspace that contains multiple repositories, You should not omit it. in general, files in xcshareddata should be committed.

An .xccheckout file contains metadata about what repositories are used in a workspace. For a single project in a single repository that doesn’t make much difference. But if you’re using a workspace that has multiple projects from different repositories, the presence of an .xccheckout file in the workspace allows Xcode to know what all of the components that make up a The workspace are and where to get them. Stackoverflow.com/questions/1…

1. Set the ignore attribute on the SVN:

svn propset svn:ignore xcuserdata path/to/my/folder/MyProject.xcodeproj

Or modify the configuration file:

global-ignores = *.o *.lo .la .. rej .rej .~ ~ .# .DS_Store *~.nib .mode .pbxuser CVS _.java *.perspective .LSOverride *.xcuserdatad

Blog.csdn.net/houseq/arti…