runtime/cgo: could not obtain pthread_keys Simulator Error - ios

I ran into this issue with Xcode 12.1 simulators running iOS 14.1. My code does compiles then I get the runtime error of
runtime/cgo: could not obtain pthread_keys
tried 0x118 0x119 0x11a 0x11b 0x11c 0x11d 0x11e 0x11f 0x120 0x121 0x122 0x123 0x124 0x125 0x126 0x127 0x128 0x129 0x12a 0x12b 0x12c 0x12d 0x12e 0x12f 0x130 0x131 0x132 0x133 0x134 0x135 0x136 0x137 0x138 0x139 0x13a 0x13b 0x13c 0x13d 0x13e 0x13f 0x140 0x141 0x142 0x143 0x144 0x145 0x146 0x147 0x148 0x149 0x14a 0x14b 0x14c 0x14d 0x14e 0x14f 0x150 0x151 0x152 0x153 0x154 0x155 0x156 0x157 0x158 0x159 0x15a 0x15b 0x15c 0x15d 0x15e 0x15f 0x160 0x161 0x162 0x163 0x164 0x165 0x166 0x167 0x168 0x169 0x16a 0x16b 0x16c 0x16d 0x16e 0x16f 0x170 0x171 0x172 0x173 0x174 0x175 0x176 0x177 0x178 0x179 0x17a 0x17b 0x17c 0x17d 0x17e 0x17f 0x180 0x181 0x182 0x183 0x184 0x185 0x186 0x187 0x188 0x189 0x18a 0x18b 0x18c 0x18d 0x18e 0x18f 0x190 0x191 0x192 0x193 0x194 0x195 0x196 0x197
The code runs fine on the iOS 13.5 simulators as well as on a physical device running iOS 14. I would like to have the simulators running and working. Does anyone have a solution for this issue to work on iOS 14 simulators? And if anyone might know if this issue would affect Apple Store submissions

I am assuming you are using a go library framework file with your iOS Project. We had a similar issue with our codebase. To answer your questions:
It won't affect Apple Store submissions/releases on the App Store - we have made few releases in the last few months and there have been no issues.
Regarding the issue itself, I assume this is because of the go version - you have not stated what go version you are using but this was prevalent if you were using an older version (1.10.x or previous).
Updating your go lib version to a newer release and building your framework file with that version should solve your problem
I haven't understood much on why the issue occurs but here's an answer that tries to explain something similar

Related

What is the purpose of libParallelCompression in iOS?

I do data compresssion with libcompression.tbd, which was introduced
in iOS 9.0. There appeared libParallelCompression.tbd in iOS 11.0. But I can't find any information about it, and library header looks like that:
symbols: [ _BXDiff5, _BXPatch5, _BXPatch5InPlace, _BXPatchFile, _CachePatch,
_DirectoryDiff, _DirectoryPatch, _ISparseArchiveStreamCreate,
_ISparseArchiveStreamDestroy, _ISparseArchiveStreamRead, _PCompressFilter,
_PackagePatch, _ParallelArchiveExtract, _ParallelArchiveGenerateBOM,
_ParallelArchiveGenerateMSUBOM
...
I have strong suspicion that libParallelCompression is for audio processing.
How to detect the purpose of libParallelCompression.tbd?
Do you know compression libs for iOS, faster that libcompression.tbd?

hittest does not detect geometries hidden behind others in ios11 - swift

I couldn't get hitTest (with no options) to detect geometries that are hidden behind some other geometry in iOS 11. My code worked fine on iOS 10. Anyone know how to fix?
Example:
let hitResults = scnView.hitTest(location, options: nil)
Should return several nodes - but does only return one node.
You should use the symbolic constant SCNHitTestSearchMode.all instead of 1, it's more descriptive.
if #available(iOS 11.0, *) {
hitResults = scnView.hitTest(location, options: [.searchMode: SCNHitTestSearchMode.all.rawValue]) }
}
The other options are .closest and .any.
Adding some additional details - in my experience, there has been a major change from iOS 10 to iOS 11 in the way SceneKit handles touches. Specifically, the DEFAULT operation in SceneKit, as Bernd notes above, is now that only the first node touched in the "ray" is returned in the [SCNHitTestResult].
The additional comment is that if you were hoping for backward compatibility to iOS 10 or before, I couldn't seem to get it to work, because the solution noted above requires iOS 11 Deployment Target. So Apple seems to have changed the default way touches are handled, and if you want it to work the original way, you must change the default of [SCNHitTestOption.searchMode : 1], which is only available if/when you change your Deployment Target to iOS 11 or higher. ( thanks, Apple)
Here are some futher oddities I found as I searched for a way to make an iOS 10 deployment work with Xcode 9 / iOS 11 updates. (note: I had upgraded my phone to iOS 11 when testing these scenarios with an iOS 10.3 Deployment Target build)
the [SCNHitTestOption.firstFoundOnly : 0], while available with iOS 10 deployment, seems to be ignored if .searchMode isn't also set to 1, which requires iOS 11
similarly [SCNHitTestOption.categoryBitMask : ], while avail with iOS 10 deployment, seems to be ignored if .searchMode isn't also set to 1...
Bottom line, from what I can tell, is that Apple does everything in its power to force devs to upgrade to the latest OS (either wittingly or unwittingly), which then "encourages" end users to have to upgrade to get the latest app updates.
I was able to find a fix - and will share it here, maybe its useful for somebody else:
Apple introduced this new searchMode - which is by default "closest" - you can get the old behavior by setting searchMode to ALL = 1
if #available(iOS 11.0, *) {
hitResults = scnView.hitTest(location, options: [SCNHitTestOption.searchMode: 1])
}
Or in Objective C...
options:#{SCNHitTestOptionSearchMode : [NSNumber numberWithInt:1]}

How to disable font smoothing in Xcode 9?

I've got a great programming font Deccy that only looks good with font smoothing (anti aliasing) disabled in Xcode. With Xcode 8 the following would do the trick:
defaults write com.apple.dt.Xcode NSFontDefaultScreenFontSubstitutionEnabled -bool YES
defaults write com.apple.dt.Xcode AppleAntiAliasingThreshold 24
But this no longer works with Xcode 9.
Would it be possible to disable font smoothing in Xcode 9?
Mischief managed?
Here's a screenshot of my Xcode 9 with Deccy at 13pt:
I believe the above is what you want. Here's stock Xcode displaying the same file:
But how?
I probed deep for a noninvasive way to accomplish this, and failed. As far as I can tell, the text rendering path in Xcode 9 very deliberately turns on font smoothing.
Before going any further, please file a feature request with Apple. It only takes a few minutes, and it's your best hope for an answer that that can be discussed in front of those with sound security instincts and strained cardiovasculature:
https://bugreport.apple.com/
I wrote an Xcode plugin. You might have heard that Xcode 9 uses code signing restrictions to forbid the loading of plugins. This is true, but a few mavericks press on, and tonight we ride with them.
Step one
There is a tool, update_xcode_plugins. You can use it to strip the code signature from your copy of Xcode, and with it the bundle-loading restriction:
$ gem install update_xcode_plugins
$ update_xcode_plugins --unsign
If you change your mind, you can do this to revert to (a backup copy, I think?) of signed Xcode:
$ update_xcode_plugins --restore
Step two
There is another tool, Alcatraz. It's a plugin manager for Xcode. I chose to install it because it provides a plugin which provides a project template for plugins. I followed these instructions to install Alcatraz, which boil down to this:
$ git clone https://github.com/alcatraz/Alcatraz.git
$ cd Alcatraz
$ xcodebuild
I launched Xcode, clicked through the dialog warning me about the new plugin, and then used the newly-added Window > Package Manager to install the "Xcode Plugin" template.
Step three
I made a project with this template.
As I write this, the "Xcode Plugin" template hasn't been updated to support Xcode 9. No worries. I ran this command to grab Xcode 9's compatibility UUID:
$ defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
I visited my new project's Info.plist and added that UUID to the DVTPlugInCompatibilityUUIDs array.
Then, I linked SourceEditor.framework into my project. That was a two-step process:
Visit the target's Build Settings. Add this to Framework Search Paths:
/Applications/Xcode.app/Contents/SharedFrameworks/
Visit the target's Build Phases. Add a new "Link Binary With Libraries" phase. Hit the plus. Navigate to the directory above (you can just press the / key and then paste the path in) and choose SourceEditor.framework. It should appear in the list. The project should still build.
Then, I made my plugin's .mm file look like this (I deleted the .h file, it's unneeded for this PoC):
#import <AppKit/AppKit.h>
#include <dlfcn.h>
extern void CGContextSetAllowsFontAntialiasing(CGContextRef, BOOL);
static void hooked_sourceEditorSetFontSmoothingStyle(CGContextRef ctx) {
CGContextSetAllowsFontAntialiasing(ctx, NO);
}
#interface NoAA : NSObject
#end
#implementation NoAA
+ (void)pluginDidLoad:(NSBundle *)plugin
{
NSArray *allowedLoaders = [plugin objectForInfoDictionaryKey:#"me.delisa.XcodePluginBase.AllowedLoaders"];
if (![allowedLoaders containsObject:[[NSBundle mainBundle] bundleIdentifier]])
return;
Class cls = NSClassFromString(#"SourceEditorScrollView");
NSBundle* bundle = [NSBundle bundleForClass:cls];
void *handle = dlopen(bundle.executablePath.fileSystemRepresentation, RTLD_NOW);
if (!handle)
return;
uint8_t* set_font_smoothing_fn = dlsym(handle, "sourceEditorSetFontSmoothingStyle");
if (!set_font_smoothing_fn)
goto fin;
void* set_font_smoothing_fn_page = (void*)((long)set_font_smoothing_fn & -PAGE_SIZE);
if (mprotect(set_font_smoothing_fn_page, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC))
goto fin;
set_font_smoothing_fn[0] = 0xe9; // jmp
uint32_t* jmp_arg = (uint32_t*)(set_font_smoothing_fn + 1);
*jmp_arg = (uint32_t)((long)hooked_sourceEditorSetFontSmoothingStyle - (long)(jmp_arg + 1));
mprotect(set_font_smoothing_fn_page, PAGE_SIZE, PROT_READ | PROT_EXEC);
fin:
dlclose(handle);
}
#end
…I think the gotos add character. Basically, it just defines a function that takes a CGContextRef and turns off text antialiasing for it. Then, it overwrites the beginning of a function inside the SourceEditor framework which ordinarily configures antialiasing settings — don't need that anymore — to jump to our function instead. It does all of this in an incredibly unsafe way, so if something goes wrong, Xcode may politely crash.
Build and run the project, which automatically installs the plugin. Accept the addition of your plugin, and that's that.
What now?
If anything here doesn't work because I messed up, let me know. I'm not planning to roll this into an Alcatraz plugin myself, but you or anyone else should free to do so with credit (after filing a feature request with Apple).
Happy hacking!
If you 'live' in XCode and need a crisp rendering of this TrueType font, then editing XCode application defaults with PrefEdit.app, or defaults write com.apple.dt.Xcode.* has no effect.
Thinking outside the box you might be interested in the following to achieve crispyness all-over your Mac.
Since the Deccy font is best viewed at 12pt, it makes sense to raise the AppleAntiAliasingThreshold in the global domain to 13, the default for this setting is 4.
You can also suggest no AppleFontSmoothing.
defaults write -g AppleFontSmoothing -int 0
defaults write -g AppleAntiAliasingThreshold -int 13
In addition to these tweaks a bit more can be achieved in the Accessibility Preference pane in System Preferences: The Display has 2 checkmarks that you should try: 'Differentiate without color', and 'Increase contrast'.
"Beauty is in the eye of the beholder", I hope this helps.
Here are alternative steps that might work for you.
Try to find the com.apple.dt.Xcode.plist file under Macintosh HD/Library/Preferences.
Copy the file to desktop
Open file and add NSFontDefaultScreenFontSubstitutionEnabled to (Boolean)YES
add AppleAntiAliasingThreshold to (Number)24
Replace this file with preference file
Restart the system and Xcode
Note: For safer side keep backup of the original file.

Xcode 8 - Swift 3 - Break my app

On the previous version of xcode ( Xcode 8 beta 6 ) , my app running fine without errors. I updated xcode this morning, I run my app and now, I have 400 errors !
Pods installed not working and on my code all is on red !
I'm a bit frustrated to have made an update and this has resulted to demolish my application.
How can I resolve my situation ?
Example of code not working now :
if UserDefaults.standard.string(forKey: "token") != nil => Use of unresolved identifier
if( CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedWhenInUse => Type CLAuthorizationStatus has no member authorizedWhenInUse
No luck, I had to quickly add an update that corrects a version of the app store that crash at startup ...
The newest version of Xcode, Xcode 8 beta or Xcode 8 GM seed, runs on an updated and swifter version of Swift. Likely your errors are because your command strings are now too long. If you cannot convert the files, you may need to go in and edit each command line. Refer to the release notes for the newest version of Xcode you have to find these new statements.
Example:
// old code (Swift 2.2)
let content = text.stringByTrimmingCharactersInSet(NSCharacterSet.newlineCharacterSet())
// new code (Swift 3.0)
let content2 = text.trimmingCharacters(in: .newlines)
resource:
https://developer.apple.com/swift/

Javascript / Native code out of sync (differing number of arguments) error

I have recently updated to ReactNativeControllers 2.03 from 1.24. I have also updated RN to 0.25. I am using a fork which only adds a Podspec file. After sorting out all the import changes in RN I am now stumped on this error:
(See also https://github.com/wix/react-native-controllers/issues/59)
RCCManager.setRootController was called with 3 arguments, but expects
2.
If you haven't changed this method yourself, this usually means that
your versions of the native code and JavaScript code are out of sync.
Updating both should make this error go away.
The code in question:
In RCCManagerModule.m:
setRootController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps)
and in index.js:
ControllerRegistry: {
registerController: function (appKey, getControllerFunc) {
_controllerRegistry[appKey] = getControllerFunc();
},
setRootController: function (appKey, animationType = 'none', passProps = {}) {
var controller = _controllerRegistry[appKey];
if (controller === undefined) return;
var layout = controller.render();
_validateDrawerProps(layout);
RCCManager.setRootController(layout, animationType, passProps);
}
},
As is evident, both have 3 parameters.
I've killed and restarted the packager. I've cleaned the Xcode project including derived data, and deleted watchman cache with watchman watch-del-all. I've deleted my node_modules folder, done npm install and pod install.
I've rebuilt the Xcode project. Still no luck. I don't know how to debug this further.
EDIT: I also tried to clean the pod cache, updated to Cocoapods 1.01...
I have a feeling there may be a red herring here somewhere. For reference my full trace looks like this:
2016-06-10 14:15:18.179 [warn][tid:com.facebook.React.JavaScript] Warning: ReactNative.Component is deprecated. Use React.Component from the "react" package instead.
2016-06-10 14:15:18.239 JustTuner[7523:185768] Launching Couchbase Lite...
2016-06-10 14:15:19.048 JustTuner[7523:185768] Couchbase Lite url = http://adamwilsonsMBP.lan:5984/
2016-06-10 14:15:19.050 JustTuner[7523:185768] Launching Couchbase Lite...
2016-06-10 14:15:19.058 JustTuner[7523:185768] Couchbase Lite url = http://adamwilsonsMBP.lan:5984/
2016-06-10 14:15:19.538 [error][tid:main][RCTModuleMethod.m:456] RCCManager.setRootController was called with 3 arguments, but expects 2. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
After spending many hours trying to work this out, I found that there was an out of date static library libReactNativeControllers.a in build/Products/Debug-iphonesimulator.
Deleting libReactNativeControllers.a and rebuilding the project solved the issue.
It seems that the Pod static libraries are now being saved in their respective folders e.g. build/Products/Debug-iphonesimulator/ReactNativeControllers/libReactNativeControllers.a
My guess is that the recent builds were saving the static lib in the subfolder, but the linker was picking up the out-of-date one. Anyone know why this might have changed recently?
Restarting metro with resetting cache worked for me:
react-native start --reset-cache
or
npm start -- --reset-cache
Try to Clean and Rebuild the solution in XCode if it happened in react-native iOS.

Resources