At the WWDC2015 conference, Apple announced that iOS9 will support pure IPv6 network services. Starting June 1, 2016, all applications submitted to the App Store must support IPv6, or they will not pass the review. In order to ensure that our app is submitted to Apple for review without delay and not to hinder the progress of the project, we must conduct IPv6 compatibility testing on the app before submitting it to the App Store.
The number of IP addresses has expanded from 2^32 in IPv4 to 2^128 in IPv6, which is where IPv6 significantly outperforms IPv4, providing enough IP addresses for every grain of sand on Earth to have one or more. Of course, in addition to the inherent reasons for IPv4 (address exhaustion), the following points also show that IPv6 is more efficient than IPv4, such as:
1. Avoiding the need for Network Address Translation (NAT)
2. Providing faster routing through the network using simplified headers
3. Preventing network fragmentation
4. Avoiding broadcast neighbor address resolution
However, the most fundamental reason is the pressure from Apple's review process, making it necessary to adapt the app to IPv6.
1. Ensure that higher-level network APIs are used in the project code, avoiding the use of socket APIs
On Apple's official website, there is a diagram that explains which frameworks support IPv6 and which do not, as shown below:
The blue part in the image indicates default support for IPv6. If the project code uses network frameworks such as WebKit or AFNetworking, then there won't be many code changes required.
2. Check if IP addresses are used in the code.
For example, examine the code to see if it contains addresses like 192.168.0.1. If so, replace them with their corresponding domain names.
3. Review the code for IPv4-specific APIs.
Ensure that the project's code does not include the following APIs.
If you find these APIs in your code, don't worry. You just need to replace the corresponding APIs with those supported by IPv6. The following table shows the relationship between IPv4 and IPv6 APIs:
4. Set up a local IPv6 environment and test all network request modules in the app
Currently, the networks we connect to, whether it's Wi-Fi or various types of networks from mobile carriers like China Mobile, China Unicom, or China Telecom, are all IPv4-based. This means that in our daily lives, we mainly interact with IPv4 environments. However, to test the compatibility of IPv6 in iOS apps, we cannot rely on existing network environments. Testers need to build their own testing environment.
Fortunately, Apple has included a feature to enable an IPv6 environment in macOS X 10.11 and later. All we need to do is follow the official documentation to set up a local testing environment. This can be done by creating a hotspot on a Mac and then connecting an iPhone to that hotspot to test the modules in question. A simple schematic diagram is shown below:
a) Required equipment:
You'll need a Mac running OS X 10.11 or later (this Mac should be connected to the internet using a non-Wi-Fi method and support dual network cards) and an iPhone. Some users might wonder what to do if their MacBook only has a wireless network card and no Ethernet port. In this case, you'll need an Apple Thunderbolt Gigabit Ethernet adapter.
b) Enable NAT64 network
Open "System Preferences", hold down the Option key, and click on "Sharing", as shown in the image below:
After that, on the Sharing page, you will see the option to "Create NAT64 Network."
At this point, we have successfully created the NAT64 network. The next step is to set up the hotspot.
c) Create a Wi-Fi hotspot on your Mac
Creating a Wi-Fi hotspot on a Mac is quite simple, so I won't go into detail here.
I'd like to point out a critical issue here: after clicking the "Start" button, some networks may encounter a sharing failure as shown in the image below. If this happens, it means that the network you are currently using is restricted by the 802.1x protocol and cannot be shared. You can either remove the 802.1x protection or switch to another shareable network.
If you are on a company network, you can ask the IT department to switch networks or use a network environment set up by the developers for testing (PS: If the developers don't have an IPv6 network environment and the release deadline is tight, you can request to work from home or go to a coffee shop).
If the hotspot is set up successfully, you can see the following icon in the upper right corner of the Mac's network status:
d) Connect your iPhone to the created hotspot.
After connecting successfully, you can check the IP address of your iPhone.
In my case, I see an IP address of 169.254.*.*. This type of address is a reserved address. For more information about reserved addresses, please search online.
e) Test the app in question and ensure that all network requests work normally in the locally built IPv6 network environment.
By "normal," I mean that the performance should be consistent with that in an IPv4 network environment.
After testing, I found that QQ works fine in the IPv6 network environment, while WeChat fails to connect (the latest WeChat SDK already supports IPv6).
Finally, if you're interested, you can use a packet capture tool to see what an IPv6 address looks like. I've only seen IPv6 addresses in textbooks before, so this test was the first time I've seen a real IPv6 address, as shown in the image below:
Here, we'll use a map SDK as an example to briefly explain the specific testing steps. A map SDK is a collection of development tools used by map software development engineers to build application software for specific software packages, frameworks, hardware platforms, operating systems, etc. It includes interface APIs, sample code, supportive technical annotations, or other supporting documentation. With these tools, third-party developers can conveniently use these APIs to develop the features they need. Here's the link to the Tencent Maps Open Platform: http://lbs.qq.com/ios_v1/index.html.
At present, partners working with Tencent Maps SDK include JD.com, 58.com, Ctrip, and DiDi.
1. First, you need to analyze which libraries the SDK uses
For each library used in the map SDK, confirm one by one whether they support IPv6, such as the WebKit.framework, which is explicitly stated to support IPv6 in Apple's official documentation.
2. Check if IP addresses are used in the SDK source code
This mainly involves going through all modules with network requests to see if IP addresses have been replaced with domain names. This is usually defined in a configuration file in the code. For example, the server address is shown in the image below:
3. Check if the code contains APIs that only support IPv4
Since the SDK uses the WebKit.framework, there are no underlying socket APIs, and thus no risk in this area.
4. Set up a local test environment and regression test the SDK's network-related modules
Here, you need to ensure that the functionality under the IPv6 environment is consistent with that under the IPv4 environment, which would indicate that the test has passed.
5. Packet capture confirmation
Finally, you can use packet capture to see if the test environment is indeed running on the IPv6 setup you've built. Of course, you can also see firsthand what an IPv6 IP address looks like.
Ensuring that your app is compatible with IPv6 is crucial for passing Apple's review process and providing a seamless user experience. To make this process easier and more efficient, consider utilizing WeTest's App Compatibility Testing services. WeTest boasts an experienced testing team and access to over 300 real devices, allowing for quick identification and resolution of application issues while reducing project costs. With WeTest's expertise, you can have confidence that your app will be fully compatible with IPv6 and ready for submission to the App Store. For more information on how WeTest can assist with your app's IPv6 compatibility testing, visit WeTest's website.