This profile

  • Topic: talk to RunsCode about programming and hobbies, and how to solve the rubik’s cube in 1min 😏.

  • Tips: iOS recognition virtual location research; Fix Fastlane double authentication with App Store Connect API Key.

  • Interview module: how the KVC value and assignment process work.

  • Excellent blog: Recommended articles about Combine.

  • Learning materials: Ruan Yifeng’s latest C language introduction tutorial, GitHub Hitchhiker’s Guide.

  • Development tools: XcodeProject management tool XcodeProjects.

This topic

@Zhangferry: This interview is with another editor of Fish Weekly: RunsCode. RunsCode is a very cool guy in my opinion. This cool comes from his strong learning ability and personal requirements, programming and hobbies can be played out by him. Let’s get to know him through a few questions.

Zhangferry: Tell me a little about yourself.

Hello, everyone! I’m RunsCode, currently working in Hello Travel, hangzhou.

I was addicted to computer games when I was young. After graduation, I entered the pit to make mobile games. Later, I got to know iOS by chance.

Zhangferry: You have learned a wide range of languages, including Android, Ruby and Applescript. When did you learn a new language? What should you focus on first when learning a new language?

I was forced to learn Android and iOS, but I was still attracted by the purity of iOS. And then when I was working on iOS in 2015, CSDN, who was one of the top ten at that time, was our leader and opened up our eyes to learn Swift and Ruby, because he said Swift borrowed a lot of Ruby features, plus CocoaPods was written in Ruby, Just a little bit of study. AppleScript was also the CSDN god’s cue to automate the Mac, and it has since spiralled out of control.

For me, the common feature of these languages is that they make me happy to write, just like the feeling of children seeing delicious food (Mainly Swift and Ruby). In fact, learning languages is targeted learning, and different languages have their own areas of expertise. For example, I want to write an iOS App in Ruby, which is a bit too much. It’s not as good as OC/Swift, it’s a bit out of line, but someone does it. RubyMotion, geeky.

In my opinion, in addition to mastering the basic morphology and grammar at the beginning, you will gradually find out whether the language resonates with you and whether your thinking fits well with its processing logic. For example, while everyone likes script Python, I prefer Ruby, which is mainly because the processing logic of Ruby fits well with me. Is the same show you used to de Ma, BUT I used lv Bu more accustomed.

Zhangferry: I heard that you are good at table tennis and rubik’s cube. Is there any commonness between learning these things and programming? I used to be obsessed with rubik’s Cube (third order) for some time, but the fastest time is more than 2min. I heard that your record is 15s. It is a relatively simple process from not knowing how to do it to proficiency, and most people can do it, but it is very difficult to break through again. As for the Rubik’s cube, 1min is a big breakthrough for me. What do I need to do to achieve this step?

Table tennis will be a little, please coach specialized training of basic skills, can not say that play very good, with the village uncle play sometimes often overturned, especially hit long plastic overturned many, ah……

Rubik’s cube this bar, is slightly faster than the normal recovery, three steps stop CFOP.

With programming common: interest first, and then is to adhere to, with the right way deliberately practice is (master are lonely).

For solving the third-order Rubik’s cube in one minute, learn the seven-step method, and then practice hard for a week, two hours a day should be about enough. Of course, a gifted player with the right technique may only need two or three days.

Then the most important thing to say three times, buy a good Rubik’s cube, buy a good Rubik’s cube, buy a good Rubik’s cube!! Do not buy the kind of street stall 10 dollars, the kind of easy to jam or POP (is the explosion opened), and blow confidence, experienced lessons.

You got to start at 30 bucks, guo-jia, guo-hong, holy hand.

Tom ferry: Studying is not fun at all. How do you keep your enthusiasm for learning?

I don’t know how to answer this, maybe it’s curiosity, maybe it’s anxiety, maybe it’s hobby. All I know is that these three things get to me. Another is that I only do what I like, I never follow the trend, follow the trend easy to lose yourself, suitable for others may not be suitable for yourself.

The main thing is to insist, insist on can make people more determined. After a while you get used to studying. If all of a sudden you don’t study, you’ll feel empty, anxious and guilty.

Zhangferry: Tell me a recent thought.

Increasing happiness in life is about lifelong learning, not just job skills, but everything else.

The development of Tips

FBY Zhanfei, Zhangferry

IOS recognition virtual location research

preface

In recent business development, we have encountered the situation that our project App positioning has been tampered with, especially in Android terminal. In order to prevent this kind of black production using virtual positioning wool pulling, iOS also had to carry out virtual positioning evasive.

One: use a jailbroken phone

General App users use the jailbreak iphone case, general can infer that the user’s behavior while suspected of wool by competing goods company (or App can do reverse analysis), because buy a new cell phone prison break than buy a normal mobile phone is difficult, and in the use of system upgrade and Appstore, all not as good as normal cell phone, I have touched the superficial knowledge of the iPhone5s through jailbreaking App reverse.

Code implementation

/// check whether it is jailbroken device
/// - Returns: true Indicates device jailbreak
func isBrokenDevice(a) -> Bool {

    var isBroken = false

    let cydiaPath = "/Applications/Cydia.app"

    let aptPath = "/private/var/lib/apt"

    if FileManager.default.fileExists(atPath: cydiaPath) {
        isBroken = true
    }

    if FileManager.default.fileExists(atPath: aptPath) {
        isBroken = true
    }

    return isBroken
}
Copy the code

Second: use ace assistant

For scenarios where virtual location is used, most drivers or docking personnel should punch in. In this case, it is possible that a new crop of black sheep is being harvested using virtual location-based methods. For apple phones, at present, can be a good implementation, when the ace assistant virtual location function.

Usage steps: Download ace Assistant Mac client, connect to iPhone, click virtual location in toolbox, select location on the map, and then click Modify virtual location to modify the location information of the map.

Principle: USB connection is made between computer and mobile phone on unjailbroken device. Computer sends simulated coordinate data to DTSimulateLocation service on mobile phone through special protocol to achieve false location. At present, built-in location simulation in Xcode is achieved with the help of this technology.

Identify ways

I. Through recording the virtual positioning data of Ace’s assistant for many times, it is found that the height of longitude and latitude of its virtual positioning information is 0, and the data bits of longitude and latitude are also worth studying.

Second, the longitude and latitude of the data after positioning is sent up to the background, and then the background obtains detailed longitude and latitude information according to the received longitude and latitude, and makes a depth comparison of the geographical information of the driver except the longitude and latitude. Priority is given to the comparison of Altitude, horizontalAccuracy and verticalAccuracy. Determine according to whether the values are equal.

3. Specific identification process

  • Obtaining the Public Networkip, presumably through the interfaceipThe address gives you an approximate location, but the margin of error is a bit wide.
  • throughWi-FiHotspot to readApplocation
  • usingCLCircularRegionSet the specified latitude and longitude of the area center and the range of radius that can be set to monitor.
  • throughIBeaconTechnology, useCoreBluetoothUnder the framework ofCBPeripheralManagerSet up a Bluetooth base station. This positioning is directly end-to-end direct positioning, omittedGPSSatellite and cellular data base station communication.

Iv. IOS anti-hacking false positioning detection technology

At the end of the article, the solution I have tried, layer by layer through KVC read CLLocation _internal fLocation, can only read this.

Reference: iOS recognition virtual location survey

Fastlane uses the App Store Connect API Key to solve the two-factor authentication problem

Now the application of the AppleId is required to have double authentication, which is usually a problem when dealing with CI issues, Previous solutions used FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD and FASTLANE_SESSION, but FASTLANE_SESSION is time-sensitive, needs to be updated every month, and is not a long-term solution. Fastlane began supporting Apple’s App Store Connect API in version 2.160.0. The App Store Connect API is provided by Apple. You need to log in to App Store Connect to complete the authorization. The usage method is as follows:

1. Create a shared key here.

Request permission:

Create a secret key:

The.p8 key file can only be downloaded once.

2. Fastfile configuration.

You can directly configure the app_store_CONNECt_API_key object or write it as JSON for multiple Lanes to share. You are advised to use JSON for management. Create a JSON file and configure the following information:

{
  "key_id": "D383SF739"."issuer_id": "6053b7fe-68a8-4acb-89be-165aa6465141"."key": "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHknlhdlYdLu\n-----END PRIVATE KEY-----"."duration": 1200."in_house": false
}
Copy the code

The first three are descriptions of the secret key file, which can be modified according to your project. The original.p8 file was wrapped with a newline, which was converted to a string using \n. Note: the value is key_content, and the value is key_content.

Api_key_path specifies the path to the json file:

lane :release do
  pilot(api_key_path: "fastlane/D383SF739.json" )
end
Copy the code

Reference: Fastlane app-store-connect-API Documents

Parsing the interview

Edit: Xiao Haiteng of Normal University

This interview explains how the KVC value and assignment process work.

Getter

Here is the default implementation of the valueForKey: method, which, given a key as an input parameter, operates in the message receiver class and performs the following procedure.

  • (1) according to theget<Key>,<key>,is<Key>,_<key>Sequential lookup method.

    If found, call the value and execute ⑤, otherwise execute ②;
  • (2) find thecountOf<Key>,objectIn<Key>AtIndex:,<key>AtIndexes:Naming methods.

    If at least one of the first and the next two is found, one is created that responds to allNSArrayIs a collection of methods (of typeNSKeyValueArrayTo inherit fromNSArray) and returns the object. Otherwise, execute ③.
    • Any that the proxy object then receivesNSArrayMessage conversion tocountOf<Key>,objectIn<Key>AtIndex:,<Key>AtIndexes:A combination of messages and sends it toKVCThe caller. If the original object also implements an object namedget<Key>:range:The proxy object also uses this method when appropriate.
  • (3) to findcountOf<Key>,enumeratorOf<Key>,memberOf<Key>:Naming methods.

    If all three methods are found, one is created that responds to allNSSetIs a collection of methods (of typeNSKeyValueSetTo inherit fromNSSet) and returns the object. Otherwise, perform ④.
    • Any that the proxy object then receivesNSSetMessage conversion tocountOf<Key>,enumeratorOf<Key>,memberOf<Key>:A combination of messages and sends it toKVCThe caller.
  • ④ Check the message receiver class+accessInstanceVariablesDirectlyMethod return value (default returnYES). If the returnYES, in accordance with the_<key>,_is<Key>,<key>,is<Key>Find member variables sequentially. If it finds the value, run ⑤; otherwise, run ⑥. if+accessInstanceVariablesDirectlyMethod returnsNOAlso execute ⑥.
  • ⑤ If the value obtained is an object pointer, that is, the object is directly returned.
    • If I get a value of oneNSNumberSupported data types are stored inNSNumberInstance and return.
    • If I don’t get a single valueNSNumberThe supported data type is converted toNSValueObject, and return.
  • 6. CallvalueForUndefinedKey:Method that throws an exceptionNSUnknownKeyException, the programCrash. This is the default implementation and we can override the method for specifickeyDo something special.

Setter

The following is the default implementation of the setValue:forKey: method. Given key and value as input parameters, try to set the value of the KVC caller key to value by performing the following procedure.

  • (1) according to theset<Key>:,_set<Key>:Sequential lookup method.

    If found, it is called and willvaluePass in (convert data type as required), otherwise go to ②.
  • ② View the message receiver class+accessInstanceVariablesDirectlyMethod return value (default returnYES). If the returnYES, in accordance with the_<key>,_is<Key>,<key>,is<Key>Find member variables sequentially (same as getters). If you find it, you willvalueAssign to it (cast as needed), otherwise perform ③. if+accessInstanceVariablesDirectlyMethod returnsNOAlso go to ③.
  • (3) callsetValue:forUndefinedKey:Method that throws an exceptionNSUnknownKeyException, the programCrash. This is the default implementation and we can override the method for specifickeyDo something special.

Good blog

King Pilaf is here. I am Xiong Da

1. Apple’s responsive framework Combine — From InfoQ: Blue and white porcelain square

This is a Chinese version of a tutorial written by Joseph Heck for beginners to read and learn Combine.

2, Combine debugging using operators in Swift — from blog: Avanderlee

@I am big: Using RxSwift creates a massive unreadable stack, which is one of the reasons developers abandoned RxSwift, and still does in Combine. Fortunately, there are some tips and tricks you can use to improve your game, and this article describes several of them.

Combine: Getting Started — from raywenderlich

Swift Combine hardcore tutorial, the author uses UnsplashAPI to take you through a simple App that lets you learn how to use Combine’s publishers and subscribers to handle event flows, merge multiple publishers, etc.

4. Combine – Introduction, core concept — from Zhihu: Talaxy

King Pilaf: Combine when it comes to responsive programming. This article introduces the related concepts and uses of Combine. Including the publisher-subscriber lifecycle, the concept of publisher subscriber operators, and so on.

5. Apple’s official asynchronous programming framework: Swift Combine application — from: Nemocdz’s Blog

King Pirav: This article introduces the use of Combine through examples and codes. It is suitable for students who understand related concepts and basics of Combine.

6. RxSwift to Combine Cheatsheet — from GitHub: CombineCommunity

RxSwift vs. Combine, if you want to transition from RxSwift to Combine, please refer to this article.

Learning materials

Mimosa

Ruan Yifeng’s introduction to C Language

Address: wangdoc.com/clang

Ruan yifeng recently wrote “C Language Primer”, and his introduction to the tutorial can be seen here, which must be a great help to readers who want to pick up the CRAFT of C. In the meantime, if you find any errors or omissions, you are welcome to submit patches to the warehouse.

Github’s Hitchhiker’s Guide

Address: github.phodal.com/

If you’re new to Github, this Hitchhiker’s Guide will take you through the world of Github, showing you what it is, what it does, and how to use it. If you’re a veteran, it can also take you into details you might not normally notice and help you understand more about a tool we use every day.

Tools recommended

Brave723

XcodeProjects

Address: github.com/DKalachniuk…

Software status: Free, open source

The software is introduced

During daily development, operations such as POD Install, POD Update, or Clear Derived Data are often performed on the terminal in two clicks by the XcodeProjects tool, We can also customize commands for our own projects, greatly simplifying our operation steps and saving development time.

About us

IOS Fish weekly, mainly share the experience and lessons encountered in the development process, high-quality blog, high-quality learning materials, practical development tools, etc. The weekly warehouse is here: github.com/zhangferry/… If you have a good content recommendation, you can submit it through the way of issue. You can also apply to be our resident editor to maintain the weekly. Also can pay attention to the public number: iOS growth road, backstage click into the group communication, contact us, get more content.

Phase to recommend

IOS Fishing Weekly Issue 26

IOS Fishing Weekly 25th issue

IOS Fishing Weekly 24th issue

IOS Fishing Weekly 23rd issue