Why can <net / route.h> be enabled and compiled into the IOS6.1 simulator until it can be compiled into a real iphone?

I tried to enable gateway selection to complete the problem. While compiling the xcode IOS simulator, it can be turned on, however, it cannot on the real IOS machine. I can only put a copy of route.h in the project and it really works on a real machine. But this is another problem in the simulator. It says that structures such as rt_metrics, rtstat are redefined, with information: "The definition of" struct rt_metricx "must be imported from the module" Darwin.net.route "before it is needed." How can I solve this problem? These are the header files that I have included in my file.

#include "route.h"
//#include <net/route.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <sys/sysctl.h>
#include <string.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <net/if_dl.h>
#include "resolv.h"
+2
3

- SDK iOS Simulator SDK, IOS SDK.

iOS.

- EDIT -

#if TARGET_IPHONE_SIMULATOR
#include <net/route.h>
#else
#include "route.h"
#endif
+3

, , #import , #if guard.

#import <net/route.h>
#import "route.h"
+3

The route.h file can be found in the / usr / include / net folder on your Mac. Just copy it to your xcode project. it works;)

+2
source

Source: https://habr.com/ru/post/1684075/


All Articles