After updated Xcode 13, react-native run-ios command is not working successfully in my project.
When I run that command, Successfully launched the app on the simulator is shown in the terminal. no error message. The application is not built well and can't open.
But I can run successfully with Xcode.
My react-native version is "0.61.5". Anyone facing issues like me?
I had a similar problem. Though I had react-native version 59.10.
Solution was to use patch-package to alter react-native fishhook.c file:
`diff --git a/node_modules/react-native/Libraries/fishhook/fishhook.c
b/node_modules/react-native/Libraries/fishhook/fishhook.c
index 205ee82..d580178 100755
--- a/node_modules/react-native/Libraries/fishhook/fishhook.c
+++ b/node_modules/react-native/Libraries/fishhook/fishhook.c
## -21,15 +21,20 ##
-#import "fishhook.h"
+#include "fishhook.h"
-#import <dlfcn.h>
-#import <stdlib.h>
-#import <string.h>
-#import <sys/types.h>
-#import <mach-o/dyld.h>
-#import <mach-o/loader.h>
-#import <mach-o/nlist.h>
+#include <dlfcn.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <mach/mach.h>
+#include <mach/vm_map.h>
+#include <mach/vm_region.h>
+#include <mach-o/dyld.h>
+#include <mach-o/loader.h>
+#include <mach-o/nlist.h>
#ifdef __LP64__
typedef struct mach_header_64 mach_header_t;
## -76,6 +81,36 ## static int prepend_rebindings(struct rebindings_entry **rebindings_head,
return 0;
}
+#if 0
+static int get_protection(void *addr, vm_prot_t *prot, vm_prot_t
*max_prot) {
+ mach_port_t task = mach_task_self();
+ vm_size_t size = 0;
+ vm_address_t address = (vm_address_t)addr;
+ memory_object_name_t object;
+#ifdef __LP64__
+ mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64;
+ vm_region_basic_info_data_64_t info;
+ kern_return_t info_ret = vm_region_64(
+ task, &address, &size, VM_REGION_BASIC_INFO_64,(vm_region_info_64_t)&info, &count, &object);
+#else
+ mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT;
+ vm_region_basic_info_data_t info;
+ kern_return_t info_ret = vm_region(task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)&info, &count, &object);
+#endif
+ if (info_ret == KERN_SUCCESS) {
+ if (prot != NULL)
+ *prot = info.protection;
+
+ if (max_prot != NULL)
+ *max_prot = info.max_protection;
+
+ return 0;
+ }
+
+ return -1;
+}
+#endif
+
## -84,6 +119,7 ## static void perform_rebinding_with_section(struct rebindings_entry *rebindings,
uint32_t *indirect_symtab) {
uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1;
void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr);
+
for (uint i = 0; i < section->size / sizeof(void *); i++) {
uint32_t symtab_index = indirect_symbol_indices[i];
if (symtab_index == INDIRECT_SYMBOL_ABS || symtab_index == INDIRECT_SYMBOL_LOCAL ||
## -92,18 +128,33 ## static void perform_rebinding_with_section(struct rebindings_entry *rebindings,
}
uint32_t strtab_offset = symtab[symtab_index].n_un.n_strx;
char *symbol_name = strtab + strtab_offset;
- if (strnlen(symbol_name, 2) < 2) {
- continue;
- }
+ bool symbol_name_longer_than_1 = symbol_name[0] && symbol_name[1];
struct rebindings_entry *cur = rebindings;
while (cur) {
for (uint j = 0; j < cur->rebindings_nel; j++) {
- if (strcmp(&symbol_name[1], cur->rebindings[j].name) == 0) {
- if (cur->rebindings[j].replaced != NULL &&
- indirect_symbol_bindings[i] != cur->rebindings[j].replacement) {
+ if (symbol_name_longer_than_1 && strcmp(&symbol_name[1], cur->rebindings[j].name) == 0) {
+ kern_return_t err;
+
+ if (cur->rebindings[j].replaced != NULL && indirect_symbol_bindings[i] != cur->rebindings[j].replacement)
*(cur->rebindings[j].replaced) = indirect_symbol_bindings[i];
+
+ /**
+ * 1. Moved the vm protection modifying codes to here to reduce the
+ * changing scope.
+ * 2. Adding VM_PROT_WRITE mode unconditionally because vm_region
+ * API on some iOS/Mac reports mismatch vm protection attributes.
+ * -- Lianfu Hao Jun 16th, 2021
+ **/
+ err = vm_protect (mach_task_self (),(uintptr_t)indirect_symbol_bindings, section->size, 0, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY);
+ if (err == KERN_SUCCESS) {
+ /**
+ * Once we failed to change the vm protection, we
+ * MUST NOT continue the following write actions!
+ * iOS 15 has corrected the const segments prot.
+ * -- Lionfore Hao Jun 11th, 2021
+ **/
+ indirect_symbol_bindings[i] = cur->rebindings[j].replacement;
}
- indirect_symbol_bindings[i] = cur->rebindings[j].replacement;
goto symbol_loop;
}
}
## -187,6 +238,9 ## int rebind_symbols_image(void *header,
struct rebindings_entry *rebindings_head = NULL;
int retval = prepend_rebindings(&rebindings_head, rebindings, rebindings_nel);
rebind_symbols_for_image(rebindings_head, (const struct mach_header *) header, slide);
+ if (rebindings_head) {
+ free(rebindings_head->rebindings);
+ }
free(rebindings_head);
return retval;
}
`
Source: https://github.com/facebook/fishhook/pull/87/files
I receive about 5,000 reported issue for reason "Received a notification with no notification name" everyday.
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException' reason: 'Received a notification with no notification name'
Last Exception Backtrace:
0 CoreFoundation 0x000000018206e950 __exceptionPreprocess + 132
1 libobjc.A.dylib 0x000000018e5741fc objc_exception_throw + 60
2 CoreFoundation 0x000000018206e810 +[NSException raise:format:arguments:] + 116
3 Foundation 0x0000000182ba6db4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112
4 CoreTelephony 0x00000001827ca39c -[CTTelephonyNetworkInfo handleNotificationFromConnection:ofType:withInfo:] + 272
5 CoreTelephony 0x00000001827c9784 _ServerConnectionCallback(__CTServerConnection*, __CFString const*, __CFDictionary const*, void*) + 152
6 CoreTelephony 0x00000001827de958 ___ZNK13CTServerState21sendNotification_syncE7CTEventPK10__CFStringPK14__CFDictionary_block_invoke15 + 32
7 libdispatch.dylib 0x000000018eb4c014 _dispatch_call_block_and_release + 24
8 libdispatch.dylib 0x000000018eb4bfd4 _dispatch_client_callout + 16
9 libdispatch.dylib 0x000000018eb524a8 _dispatch_queue_drain + 640
10 libdispatch.dylib 0x000000018eb4e4c0 _dispatch_queue_invoke + 68
11 libdispatch.dylib 0x000000018eb530f4 _dispatch_root_queue_drain + 104
12 libdispatch.dylib 0x000000018eb534fc _dispatch_worker_thread2 + 76
13 libsystem_pthread.dylib 0x000000018ece16bc _pthread_wqthread + 356
14 libsystem_pthread.dylib 0x000000018ece154c start_wqthread + 4
I found all CoreTelephony notification and tried to reproduce the issue but failed.
/* For use with the CoreTelephony notification system. */
extern CFStringRef kCTRegistrationStatusChangedNotification;
extern CFStringRef kCTRegistrationStateDurationReportNotification;
extern CFStringRef kCTRegistrationServiceProviderNameChangedNotification;
extern CFStringRef kCTRegistrationOperatorNameChangedNotification;
extern CFStringRef kCTRegistrationNewServingNetworkNotification;
extern CFStringRef kCTRegistrationDataStatusChangedNotification;
extern CFStringRef kCTRegistrationDataActivateFailedNotification;
extern CFStringRef kCTRegistrationCellularDataPlanHideIndicatorNotification;
extern CFStringRef kCTRegistrationCellularDataPlanActivateFailedNotification;
extern CFStringRef kCTRegistrationCustomerServiceProfileUpdateNotification;
extern CFStringRef kCTRegistrationCellChangedNotification;
extern CFStringRef kCTRegistrationCauseCodeNotification;
Why do I get this crash?
And how can I change my code so that I do not get this issue anymore?
Any help is highly appreciated.
EDIT:
I am using Reachability class (https://github.com/tonymillion/Reachability) to detect network type.
+ (NSString *)networkName
{
Reachability *reach = [Reachability reachabilityForInternetConnection];
[reach startNotifier];
NetworkStatus networkStatus = [reach currentReachabilityStatus];
CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
if (networkStatus == ReachableViaWiFi) {
return #"WIFI";
} else if (networkStatus == ReachableViaWWAN) {
if ([telephonyInfo respondsToSelector:#selector(currentRadioAccessTechnology)]) {
if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyGPRS]) {
return #"GPRS";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyEdge]) {
return #"EDGE";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyWCDMA]) {
return #"WCDMA";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyHSDPA]) {
return #"HSDPA";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyHSUPA]) {
return #"HSUPA";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
return #"CDMA1X";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
return #"CDMAEVDOREV0";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
return #"CDMAEVDOREVA";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
return #"CDMAEVDOREVB";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyeHRPD]) {
return #"HRPD";
} else if ([[telephonyInfo currentRadioAccessTechnology] isEqualToString:CTRadioAccessTechnologyLTE]) {
return #"LTE";
}
return #"UNKNOWN";
} else {
return #"WWAN";
}
} else {
return #"NotReachable";
}
}
I wonder if this is related to this similar issue with the old version of TestFlight:
There is an iOS bug that causes instances of the CTTelephonyNetworkInfo class to sometimes get notifications after they have been deallocated. Instead of instantiating, using, and releasing instances you must instead retain and never release them to work around the bug.
This smells like a zombie from the looks of your backtrace. Why not try using a static instance of CTTelephonyNetworkInfo that is never released as suggested in the linked question?
#import CoreTelephony;
// ...
static CTTelephonyNetworkInfo *netInfo;
static dispatch_once_t dispatchToken;
if (!netInfo) {
dispatch_once(&dispatchToken, ^{
netInfo = [[CTTelephonyNetworkInfo alloc] init];
});
}
To fix this issue, I use method swizzling to re-routing all calls that were originally sent to -[CTTelephonyNetworkInfo handleNotificationFromConnection:ofType:withInfo:] .
It works fine.
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
struct __CTServerConnection {
int a;
int b;
CFMachPortRef myport;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
};
typedef struct __CTServerConnection CTServerConnection;
typedef CTServerConnection* CTServerConnectionRef;
#implementation CTTelephonyNetworkInfo (Fixed)
- (void)fixed_handleNotificationFromConnection:(CTServerConnectionRef)connection
ofType:(NSString *)notificationName
withInfo:(NSDictionary *)info
{
if ([notificationName length]) {
return [self fixed_handleNotificationFromConnection:connection
ofType:notificationName
withInfo:info];
}
}
enter code here
#include "Pitches.h"
// notes in the melody:
int melody[] = {
NOTE_FS4, NOTE_FS4, NOTE_D4, NOTE_B3,0, NOTE_B3,0, NOTE_E4,0, NOTE_E4,0,NOTE_E4, NOTE_GS4, NOTE_GS4 NOTE_A4, NOTE_B4,
NOTE_A4, NOTE_A4, NOTE_A4, NOTE_E4,0, NOTE_CS4,0, NOTE_FS4,0, NOTE_FS4,0, NOTE_FS4, NOTE_E4, NOTE_E4, NOTE_FS4, NOTE_E4,
NOTE_D4, NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3,0, NOTE_B3, NOTE_B3,0, NOTE_CS4, NOTE_CS4,0, NOTE_CS4,0, NOTE_A3,0, NOTE_A3,0, NOTE_F4,0, NOTE_F4,
NOTE_F4, NOTE_E4, NOTE_D4, NOTE_D4, NOTE_D4, NOTE_CS4,0, NOTE_B3,0, NOTE_B3,0, NOTE_B3, NOTE_B3,0,0, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4,
NOTE_A4, NOTE_G4,0, NOTE_FS4,0, NOTE_E4,0, NOTE_A4, NOTE_A4, NOTE_G4, NOTE_G4, NOTE_A4, NOTE_A4,
NOTE_E5, NOTE_FS5, NOTE_FS5, NOTE_E5, NOTE_A4, NOTE_A4, NOTE_E5, NOTE_E5, NOTE_FS5, NOTE_FS5, NOTE_E4, NOTE_F4
};
//note durations: 2 = half note, 4 = quarter note, 8 = eighth note, 12 = twelveth note, :
int noteDurations[] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
12, 8, 8, 8, 4, 8, 8, 8, 8, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 4, 2, 2, 2, 2, 2, 2,
12, 8, 4, 4, 2, 2, 2, 2, 2, 2, 12, 8,
};
void setup() {
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 12; thisNote++) {
// calculate the note duration as 1 second divided by note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / noteDurations[thisNote];
tone(12, melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(12);
}
}
void loop() {
// no need to repeat the melody.
}
This is the file included for pitches
/*************************************************
* Public Constants
*************************************************/
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978
As part of an engineering project for school we were asked to make a program that could play a simple song. We have created the code based on the example ToneMelody for the arduino program. we get an error after all of are notes are listed that highlights red on both are music_code file and our pitches.h file. However, on our pitches.h file the error stops at #define Note_AS3 233 it says exit status 1 expected declaration before '}' token. What does this error mean and how exactly can we fix it because the example tonemelody program works fine?
So, there's a number of errors in your posted sketch which would stop it from compiling.
NOTE_A3 is referenced but not defined
On the very first line of the definition of int melody[], there is no comma between NOTE_GS4 and NOTE_A4
On the third line of the definition of int noteDurations[], you are missing a comma between 8 at the end of the line, and the next element
If you correct all three of these, the code should compile just fine. You should, however, receive more than just one error like you describe from the Arduino IDE. I received notably more, which allowed me to at least figure out where each problem was. If you don't see it in the Arduino error box, you should at least see it through the command line output, which will allow you to track these down in the future.
I have a IS_TESTING boolean flag indicating whether the current build is testing
I want to hide NSLog if IS_TESTING is NO. And it should also support a single string parameter.
This is CCLog from cocos2d:
#define __CCLOGWITHFUNCTION(s, ...) \
NSLog(#"%s : %#",__FUNCTION__,[NSString stringWithFormat:(s), ##__VA_ARGS__])
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0)
#define CCLOGWARN(...) do {} while (0)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG > 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) __CCLOG(__VA_ARGS__)
#endif // COCOS2D_DEBUG
This is what I write:
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if IS_TESTING == 0
#define CCLOG(...) do {} while (0)
#elif IS_TESTING == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#endif
use:
CCLOG(#"single string parameter");
CCLOG(#"string format %#", #"parameter");
It runs without crash, but nothing gets printed out.
EDIT:
#define IS_TESTING YES
I have tried
#if IS_TESTING == YES/NO, but still the same as 0/1, nothing gets printed out
Your code works perfectly. But IS_TESTING must be defined before you start the __CCLOG definition stuff.
So, in the .pch file, I wrote:
#define IS_TESTING 1
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if IS_TESTING == 0
#define CCLOG(...) do {} while (0)
#elif IS_TESTING == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#endif
And later:
CCLOG(#"%#", #"YES");
Since I have defined IS_TESTING to 1, we log. If I change it to 0, we don't.
As a bonus, I'll show you what I do. It's much simpler. Here it is:
#define MyLog if(0); else NSLog
This makes MyLog equivalent to NSLog. To turn off logging, change 0 to 1.