Tag Archives: ios

In IOS development, there is an error: Apple mach-o linker error

Small make up in a small demo letter about ring, ring of import letter SDK (EaseMobSDK), the connection of the error, as shown in the figure below:

solution is in general, the following figure, respectively, in the absence of label arrow to add compiler needs. M files and the necessary framework:

and the small make up the problem here is not more than compile files and framework problem, the solution is,

in the third arrow to add: -obJC, and then you just recompile.

Error:kCFStreamErrorCodeKey=-2102 Domain=kCFErrorDomainCFNetwork Code=-1001 – iOS

Some new data fields were added to the interface that had been called before due to the new business overlay. Later, when I was debugging the interface again, the following exception occurred when the request waiting was delayed until the timeout was set:

[discovery] errors encountered while discovering extensions: 
            Error Domain=PlugInKit Code=13 "query cancelled" 
            UserInfo={NSLocalizedDescription=query cancelled}

Task <C0BF69B6-6E49-44ED-B1E1-3E03212496EE>.<1> finished with error - code: -1001
Task <C0BF69B6-6E49-44ED-B1E1-3E03212496EE>.<1> load failed with error Error 
      Domain=NSURLErrorDomain 
      Code=-1001 "The request timed out." 
      UserInfo={_kCFStreamErrorCodeKey=-2102, 
                NSUnderlyingError=0x6000011ad8f0 {Error Domain=kCFErrorDomainCFNetwork 
                                                  Code=-1001 "(null)" 
                                                  UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}
                }, 
      _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <C0BF69B6-6E49-44ED-B1E1-3E03212496EE>.
<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalUploadTask <C0BF69B6-6E49-44ED-B1E1-3E03212496EE>.<1>"), 
     NSLocalizedDescription=The request timed out., 
     NSErrorFailingURLStringKey=https://testEnvironment.xxx.org.cn/cres-api/api/account/app/2a258832847d3c8669755bae6c415b, 
     NSErrorFailingURLKey=https://testEnvironment.xxx.org.cn/uums-api/api/account/app/2a258832847d3c8669755bae6c415b, 
     _kCFStreamErrorDomainKey=4} [-1001]

First of all, from the appearance, I initially suspected that the account timeliness had expired and the authentication of the server had not passed, so I tried to log in the account again, submit the modification again and initiate the request, but still threw back the above exception. Then confirm with the server that the service is in a normal state of activation. Since the interface also has a call somewhere else, it tries to go to another page to make a request for what… Callback successful OMG…
second, start to find the cause of the problem again, because both places need to call the interface, the request method is already packaged for two separate calls, all since there is a business can be successfully called, first of all, eliminate the problem of method packaging;
secondly, because there are some new fields in the new business logic, the interface state is also in normal state before the new fields are added, then try whether there is a correlation between them in turn. After deleting some fields, try to initiate the request again, and receive the callback state in seconds… A flash of insight seems to get something going on, so keep trying this way;
finally, it was found that the callback status could not be returned before the request timeoutInterval due to the server mailbox field validation taking too long. The interface was judged as timeout exception handling by default… After relaxing the timeout period again, it was found that the data could be normally received, but the duration was longer… After feedback to the server for optimization, we have solved…
ย 
The solution
It’s a little bit more about troubleshooting, but the process of fumbling is interesting;
through the above analysis, the solution is as follows:
1. 2. Try to delay the timeout of timeoutInterval to try whether the interface callback state can be received normally; 3. The server checks whether there is a long validation or similar related business logic in the fields transmitted in the receiving front end, which leads to the slow callback time and ultimately the request timeout.


That’s all we have to share. There are a variety of exceptions and there may still be exceptions that are not covered. Please add more

iOS Frequent Error Domains = NSURLErrorDomain Code = -1005 “Network Connection Lost.”

Reference links: https://stackoverflow.com/questions/25372318/error-domain-nsurlerrordomain-code-1005-the-network-connection-was-lost
Java code:

response.setHeader("Connection", "Keep-Alive");
response.setHeader("Keep-Alive", "timeout=60000");

If you are satisfied, please send the amount of money to the director of the blog. If you are interested, add the blogger WeChat when transferring money to WeChat. Please leave a comment below and feel free to discuss it with the bloggers.

Error:Your request produced an error.[newNullResponse]

The reason for this error when entering the AppStore may be that the system time has been manually modified. The solution is to change Settings – general – Date and time – back to “automatic Settings”
Another function method of developing iOS App” Rate my App” by link App Store review page:
itms-apps://itunes.apple.com/app/idXXXXXX
XXXXXX==> Your own appID

The following errors may be reported when testing this feature in an emulator:
LaunchServices: ERROR: There is no registered handler for URL scheme itms-apps
Solution: Just test with a real machine

Xcode Error: Embedded binary’s bundle identifier is not prefixed with the parent app’s bundle identifier

This error usually occurs because the Bundle Identifier is not set correctly.
1. If it is a project directly downloaded from the Internet, first check whether the Bundle Identifier on Project TARGETS has been set. If it is a demo project from the SDK, the Bundle Identifier is usually blank and needs to be filled in manually. Then select the developer account in the Signing team below. The same setting is also done in the TARGETS project accordingly in the Test project.
2. Xcode + iwatch debugging error
under the three Targets of the project (the project name is my) : my, my Watchkit app, my Watchkit extention
General -> The Bundle Identifier under Identity is written in a fixed way, so don’t change it.
for example:
com. XXX. My
com. XXX. My. Watchkitapp
com. XXX. My. Watchkitapp. Watchkitextension

Xcode: error: linker command failed with exit code 1(use -v to see invocation) or libstdc++.6.0 is missing

Note: Refer to the first link
The reason for the error is that iOS10 deleted the libstdc++.6.0.9 library file after the upgrade, so you just need to download it and put it in.
1. Download libstdc++. 6.0.9. TBD
Download Address:
https://pan.baidu.com/s/10gZrtGtspgpKT7qSY-bBDg
2. Download and note that the file name may not be this change file named libstdc++.6.0.9. TBD
3. Place the download file in the specified location
(1) Real machine runtime location
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib
(2) Location of the simulator runtime library
/ Applications/Xcode. App/Contents/Developer/Platforms/iPhoneSimulator platform/Developer/SDKs/iPhoneSimulator SDK/usr/lib
(access – to – & gt; Go to folder -& GT; Copy the above location go to find the location and then paste the downloaded file into the lib file and restart Xcode.)

Reference link:
https://blog.csdn.net/w1035524412/article/details/82863840
https://www.jianshu.com/p/a3f3c8361cf1

iOS clang: error: linker command failed with exit code 1 (use -v to see invocation)

Clang: error: Linker Command failed with exit code 1 (use-v to see Invocation) will occur if the project is not built properly due to errors in XCode.

This error is usually caused by referring to duplicate files, but a project refers to so many files, how do you find it?If you click on the error message, XCode will not display the details of the error. Is this a bug in XCode?

To see what caused the error, click error – right – and select Reveal in Log

At this point, I finally saw the reason for the error.

Duplicate symbol XXX, the truth is out, the project refers to two ASIClient, re-modify the project, successfully passed!

Solution to (ERROR: Failed to build gem native extension.) encountered when updating pod

A normal update of the POD command

sudo gem install -n /usr/local/bin cocoapods

Normally, if you execute the command above, you can upgrade directly. If you upgrade successfully, everything will be fine.
On the contrary, encounter the following upgrade failed!

โžœ  Ruby: sudo gem install -n /usr/local/bin cocoapods
Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200313-24412-3logr3.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out

This upgrade problem has been plaguing for several days. It may be that the ruby version is incompatible with the latest POD version. Therefore, Ruby must be upgraded before pod can be successfully upgraded.
The method is found on StackOverflow, but of course there are some other exception issues that need to be resolved during installation (by default you have xcode-select installed)
1. Install RVM

curl -L https://get.rvm.io | bash -s stable

If the installation is successful and the following prompts appear, you can proceed directly to step 2

Upgrade of RVM in /Users/mengshun/.rvm/ is complete.

Thanks for installing RVM ๐Ÿ™
Please consider donating to our open collective to help us maintain RVM.

๐Ÿ‘‰  Donate: https://opencollective.com/rvm/donate

If it fails, appeared at the bottom of the error (error content curl: (7) Failed to connect to port 443 raw.githubusercontent.com: Operation timed out)

โžœ  Ruby: curl -L https://get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   194  100   194    0     0    166      0  0:00:01  0:00:01 --:--:--   166
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

Execute the following instructions

sudo gem install redis

Then proceed with the RVM installation command (curl -L https://get.rvm.io | basket-s stable)
If you still report 443 errors, wait for a while and try again (I tried 3 times myself).
2. Install Ruby 2.6

โžœ  Ruby: rvm install ruby-2.6
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.6.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Homebrew libs 'coreutils libyaml [email protected] readline' require update - skipping.
Skipping update of certificates bundle '/usr/local/etc/[email protected]/cert.pem', to force update run:
    rvm osx-ssl-certs update /usr/local/etc/[email protected]/cert.pem

Requirements installation successful.
Installing Ruby from source to: /Users/mengshun/.rvm/rubies/ruby-2.6.3, this may take a while depending on your cpu(s)...
ruby-2.6.3 - #downloading ruby-2.6.3, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.8M  100 13.8M    0     0   9172      0  0:26:21  0:26:21 --:--:-- 11855
ruby-2.6.3 - #extracting ruby-2.6.3 to /Users/mengshun/.rvm/src/ruby-2.6.3 - please wait
ruby-2.6.3 - #configuring - please wait
ruby-2.6.3 - #post-configuration - please wait
ruby-2.6.3 - #compiling - please wait
ruby-2.6.3 - #installing - please wait
ruby-2.6.3 - #making binaries executable - please wait
ruby-2.6.3 - #downloading rubygems-3.0.8
ruby-2.6.3 - #extracting rubygems-3.0.8 - please wait
ruby-2.6.3 - #removing old rubygems - please wait
ruby-2.6.3 - #installing rubygems-3.0.8 - please wait
ruby-2.6.3 - #gemset created /Users/mengshun/.rvm/gems/ruby-2.6.3@global
ruby-2.6.3 - #importing gemset /Users/mengshun/.rvm/gemsets/global.gems - please wait
ruby-2.6.3 - #generating global wrappers - please wait
ruby-2.6.3 - #gemset created /Users/mengshun/.rvm/gems/ruby-2.6.3
ruby-2.6.3 - #importing gemsetfile /Users/mengshun/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.3 - #generating default wrappers - please wait
ruby-2.6.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.3 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri


โžœ  Ruby: ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]


โžœ  Ruby: rvm use ruby-2.6.3
Using /Users/mengshun/.rvm/gems/ruby-2.6.3


โžœ  Ruby: rvm --default use 2.6.3
Using /Users/mengshun/.rvm/gems/ruby-2.6.3


3. Complete and then directly execute the POD installation command

โžœ  Ruby: sudo gem install -n /usr/local/bin cocoapods
Password:
Fetching concurrent-ruby-1.1.6.gem
Fetching thread_safe-0.3.6.gem
Fetching activesupport-4.2.11.1.gem
Fetching nap-1.1.0.gem
Fetching tzinfo-1.2.6.gem
Fetching i18n-0.9.5.gem
Fetching fuzzy_match-2.0.4.gem
Fetching httpclient-2.8.3.gem
Fetching ffi-1.12.2.gem
Fetching algoliasearch-1.27.1.gem
Fetching ethon-0.12.0.gem
Fetching typhoeus-1.3.1.gem
Fetching netrc-0.11.0.gem
Fetching cocoapods-core-1.9.1.gem
Fetching claide-1.0.3.gem
Fetching cocoapods-deintegrate-1.0.4.gem
Fetching cocoapods-downloader-1.3.0.gem
Fetching cocoapods-plugins-1.0.0.gem
Fetching cocoapods-search-1.0.0.gem
Fetching cocoapods-stats-1.1.0.gem
Fetching cocoapods-trunk-1.4.1.gem
Fetching cocoapods-try-1.1.0.gem
Fetching molinillo-0.6.6.gem
Fetching atomos-0.1.3.gem
Fetching CFPropertyList-3.0.2.gem
Fetching escape-0.0.4.gem
Fetching gh_inspector-1.1.3.gem
Fetching colored2-3.1.2.gem
Fetching cocoapods-1.9.1.gem
Fetching nanaimo-0.2.6.gem
Fetching xcodeproj-1.15.0.gem
Fetching fourflusher-2.3.1.gem
Fetching ruby-macho-1.4.0.gem
Successfully installed thread_safe-0.3.6
Successfully installed tzinfo-1.2.6
Successfully installed concurrent-ruby-1.1.6
Successfully installed i18n-0.9.5
Successfully installed activesupport-4.2.11.1
Successfully installed nap-1.1.0
Successfully installed fuzzy_match-2.0.4
Successfully installed httpclient-2.8.3
Successfully installed algoliasearch-1.27.1
Building native extensions. This could take a while...
Successfully installed ffi-1.12.2
Successfully installed ethon-0.12.0
Successfully installed typhoeus-1.3.1
Successfully installed netrc-0.11.0
Successfully installed cocoapods-core-1.9.1
Successfully installed claide-1.0.3
Successfully installed cocoapods-deintegrate-1.0.4
Successfully installed cocoapods-downloader-1.3.0
Successfully installed cocoapods-plugins-1.0.0
Successfully installed cocoapods-search-1.0.0
Successfully installed cocoapods-stats-1.1.0
Successfully installed cocoapods-trunk-1.4.1
Successfully installed cocoapods-try-1.1.0
Successfully installed molinillo-0.6.6
Successfully installed atomos-0.1.3
Successfully installed CFPropertyList-3.0.2
Successfully installed colored2-3.1.2
Successfully installed nanaimo-0.2.6
Successfully installed xcodeproj-1.15.0
Successfully installed escape-0.0.4
Successfully installed fourflusher-2.3.1
Successfully installed gh_inspector-1.1.3
Successfully installed ruby-macho-1.4.0
Successfully installed cocoapods-1.9.1
Parsing documentation for thread_safe-0.3.6
Installing ri documentation for thread_safe-0.3.6
Parsing documentation for tzinfo-1.2.6
Installing ri documentation for tzinfo-1.2.6
Parsing documentation for concurrent-ruby-1.1.6
Installing ri documentation for concurrent-ruby-1.1.6
Parsing documentation for i18n-0.9.5
Installing ri documentation for i18n-0.9.5
Parsing documentation for activesupport-4.2.11.1
Installing ri documentation for activesupport-4.2.11.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for httpclient-2.8.3
Installing ri documentation for httpclient-2.8.3
Parsing documentation for algoliasearch-1.27.1
Installing ri documentation for algoliasearch-1.27.1
Parsing documentation for ffi-1.12.2
Installing ri documentation for ffi-1.12.2
Parsing documentation for ethon-0.12.0
Installing ri documentation for ethon-0.12.0
Parsing documentation for typhoeus-1.3.1
Installing ri documentation for typhoeus-1.3.1
Parsing documentation for netrc-0.11.0
Installing ri documentation for netrc-0.11.0
Parsing documentation for cocoapods-core-1.9.1
Installing ri documentation for cocoapods-core-1.9.1
Parsing documentation for claide-1.0.3
Installing ri documentation for claide-1.0.3
Parsing documentation for cocoapods-deintegrate-1.0.4
Installing ri documentation for cocoapods-deintegrate-1.0.4
Parsing documentation for cocoapods-downloader-1.3.0
Installing ri documentation for cocoapods-downloader-1.3.0
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-search-1.0.0
Installing ri documentation for cocoapods-search-1.0.0
Parsing documentation for cocoapods-stats-1.1.0
Installing ri documentation for cocoapods-stats-1.1.0
Parsing documentation for cocoapods-trunk-1.4.1
Installing ri documentation for cocoapods-trunk-1.4.1
Parsing documentation for cocoapods-try-1.1.0
Installing ri documentation for cocoapods-try-1.1.0
Parsing documentation for molinillo-0.6.6
Installing ri documentation for molinillo-0.6.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for CFPropertyList-3.0.2
Installing ri documentation for CFPropertyList-3.0.2
Parsing documentation for colored2-3.1.2
Installing ri documentation for colored2-3.1.2
Parsing documentation for nanaimo-0.2.6
Installing ri documentation for nanaimo-0.2.6
Parsing documentation for xcodeproj-1.15.0
Installing ri documentation for xcodeproj-1.15.0
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for fourflusher-2.3.1
Installing ri documentation for fourflusher-2.3.1
Parsing documentation for gh_inspector-1.1.3
Installing ri documentation for gh_inspector-1.1.3
Parsing documentation for ruby-macho-1.4.0
Installing ri documentation for ruby-macho-1.4.0
Parsing documentation for cocoapods-1.9.1
Installing ri documentation for cocoapods-1.9.1
Done installing documentation for thread_safe, tzinfo, concurrent-ruby, i18n, activesupport, nap, fuzzy_match, httpclient, algoliasearch, ffi, ethon, typhoeus, netrc, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 145 seconds
33 gems installed


โžœ  Ruby: pod --version
1.9.1

Upgrade successful!

IOS development NSURLSession/NSURLConnection HTTP load failed solution

Recently, I have been busy for the launch of the new storage app. I have been busy for nearly a month. After a period of 996, I can finally take a breath today and continue to update my blog. This paper records the problems and solutions encountered when sending a HTTPS request in iOS 9. It is hoped that through this paper, we can have a deeper understanding of the configuration of ATS.
Problem description
When developing app, I encountered the problem of sending HTTPS request in iOS 9 :

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9801)

As we know, after , iOS 9, all network requests use HTTPS by default. If you send HTTP request, the following error will be reported. But we can allow HTTP request by setting the value of nsapptransportsecuritynsallowsarbitraryloads to be YES :

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

info.plist

This solves the HTTP request problem, but when I send a HTTPS request, the HTTP laod failed problem still occurs. Although the above method can also be used to solve this problem, it is not the fundamental solution.
The solution
Through the analysis, doubt is TLS problem, because the 9 default need TLS1.2 iOS version to encrypt data, if the server does not support the TLS1.2 , the URLSession: task: didCompleteWithError: returns the nil error , However, the back-end development colleagues said that the server supports TLS1.0, TLS1.1 and TLS1.2, it seems that this is not the problem of TLS. Therefore, I was not assured. I used nscurl to test the test server. As expected, TLS1.2 was not supported.

# ๅŠ  --verbose ๆ˜ฏไธบไบ†ๆ˜พ็คบ่ฏฆ็ป†็š„่ฐƒ่ฏ•ไฟกๆฏ
/usr/bin/nscurl --ats-diagnostics --verbose https://testresource.chaoaicai.com

It can be seen from the output that the server only supports TLS1.0. Therefore, the colleagues in the background development were asked to test and modify, and then tested again. It was found that the server supports TLS1.2, and the network request of HTTPS is normal.

ATS exception configuration
In fact, for the server does not support TLS1.2, but the client to send HTTPS request there is another solution, is to configure ATS, set the lowest TLS version, as shown in infos.plist :

<key>NSAppTransportSecurity</key>
ใ€€ใ€€<dict>
ใ€€ใ€€<key>NSExceptionDomains</key>
ใ€€ใ€€<dict>
ใ€€ใ€€ใ€€ใ€€<!--ไฝ ็š„httpsๅŸŸๅ-->
ใ€€ใ€€ใ€€ใ€€<key>testresource.chaoaicai.com</key>
ใ€€ใ€€ใ€€ใ€€<dict>
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€<!--ๅ…่ฎธๅญๅŸŸ-->
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€<key>NSIncludesSubdomains</key>
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€<true/>
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€<!--TLSๅ…่ฎธ็š„ๆœ€ไฝŽ็‰ˆๆœฌๅท-->
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€<key>NSExceptionMinimumTLSVersion</key>
ใ€€ใ€€ใ€€ใ€€ใ€€ใ€€<string>TLSv1.0</string>
ใ€€ใ€€ใ€€ใ€€</dict>
ใ€€ใ€€</dict>
</dict>

Where, the specific Settings of NSExceptionDomains are described below, where ATS can be understood in more detail
NSIncludesSubdomains: is applied to the domain name, the default is NONSExceptionAllowsInsecureHTTPLoads: whether to allow HTTP requests, YES (allow), the default is NONSExceptionMinimumTLSVersion: TLS version of the lowest NSExceptionRequiresForwardSecrecy: whether to pre encryption, NO (encryption is allowed, but does not support PFS: Perfect forward secrecy), default is YESNSRequiresCertificateTransparency: the need for effective signing certificate, YES (need), the default is NO


This paper just briefly introduces how to configure ATS, and solves the problem that HTTPS cannot be accessed because the server does not support TLS1.2. It is necessary to understand the specific workflow of HTTPS and TLS, please refer to relevant materials.
The resources
# # iOS issue record about NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, - 9801)
IOS 9 comes with a series of tutorials
IOS 9.0
Clean up the pits in iOS9 adaptation (graphic)
Cocoa Keys
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) on a subdomain?