ios development issue record in 2023

The Internet winter has arrived, and many people will be stuck in the situation of jumping from one company that is going out of business to joining another that may also be going out of business soon.

1. Under Release, calling python crashes through Python-Apple-support and PythonKit. This problem comes from the Dianya community. The cause has been identified, and there are less than perfect solutions. (other people)

In my iOS project, I use Python-Apple-support and PythonKit to call python.
After completing the integration according to Python-Apple-support's USAGE on git, it can currently be called normally under debug.
However, in testfliight or release mode,
there is no crash when setting pythonPath and Py_Initialize():

guard let stdLibPath = Bundle.main.path(forResource: "python-stdlib", ofType: nil) else { return }
guard let stdDynloadPath = Bundle.main.path(forResource: "python-stdlib/lib-dynload", ofType: nil) else { return }
setenv("PYTHONHOME", stdLibPath, 1)
setenv("PYTHONPATH", "(stdLibPath):(stdDynloadPath)", 1)
Py_Initialize()
//以上内容会被执行不会导致崩溃,并且debug下后续可以正常调用,路径应该是有效的

Then calling Python crashes:

//调用自定义的python文件
let py = Python          //这里会闪退
let a = py.import("diffTool")
let test = a.diff_modelTest("123123123","123123123")

After checking, the crash occurred here in PythonKit:
PythonKit-> PythonLibrary+Symbols: Py_IncRef(pointer)
seems to be a pointer error. I saw a lot of 0x0000000000000000 in Xcode,
such as:
sharedMethodDefinition UnsafeMutablePointer<PythonKit.PyMethodDef> 0x0000000000000000

2. I modified the source code in the pod and am worried that it will be overwritten next time. How to solve it? (other people)

In the JavaScript world, when the NPM third-party library is modified, the patch-package library can be used to generate and apply code patches. So what measures can we take against cocoapod?

If you rely on a code repository that has a complete project and can be independently debugged, you can fork a copy, then modify and submit it, and in the podfile, point the three parties that originally pointed to the git public repository to us using the following configuration. Own warehouse:

pod 'Alamofire', :git => 'https://github.com/XXX/Alamofire.git', :commit => '0f506b1c45'

If the main warehouse is updated next time, we can pull and merge the latest code, specify the latest commit or not specify it.

But sometimes third-party libraries may only provide compressed files. For example, Tencent IM's TUI library has many zip files, and each file has many subspecs. At this time, it will be more troublesome to build a warehouse yourself. A simple solution is to drag each library starting with TUI to the same file level as the podfile, and then download the corresponding version of the podspec file to its directory. Finally specify in Podfile

pod 'TUICore', :path => 'TUICore'

In this way, the pod will import the code from the local file system into the pod target without having to worry about downloading the network version, causing local modifications to be overwritten. The technology is called Development Pods .

3. Pinduoduo MonkeyDev reverse error: code: -402620415 and -402653103. After installation, there is no full screen, no icon, and it will crash. Currently, MonkeyDev's scripts have some timing issues in the new version of the Xcode compilation system, causing problems with the generated plist files, leading to problems with full screen, icons, and bundle ids. When compiling for the first time, set MONKEYDEV_DEFAUTL_BUNDLEID=YES, and the following error will be reported on the iOS16 phone: An unknown error has occurred. Domain: com.apple.dt.MobileDeviceErrorDomain Code: -402620415. At this time, the bundle id is the original one, but an error will be reported. When compiling again, the bundle id becomes the one set in our project. At this time, code: -402653103 will be reported. The APP can be installed on the mobile phone, but it cannot be started automatically. It will crash after manual startup. Pinduoduo should have done some protection. To solve the above problems, you need to pay attention to the compilation timing of Xcode. In particular, one step will generate empty-appname.plist, which will be interspersed before and after MonkeyDev's pack activity, causing problems. The guess is that the new version of Xcode supports parallel execution of scripts. (other people)

Guess you like

Origin blog.csdn.net/Mamong/article/details/132112967
Recommended