MacOS 10.15, Xcode11, OC code and Swift code projects are all required.

After MacOS 10.15, Xcode11 will be able to transform iOS apps into Mac apps in seconds, which will be another wave of trend for iOS developers, and the MacOS ecosystem will become more prosperous. There are many differences between Mac OS and iOS. There are different framework libraries, but most third-party libraries are not fully compatible, although apple has officially made them compatible. There may be a problem with calling deprecated methods, calling iOS unique classes without terminal restrictions, etc. Powerful gestures on iOS devices are available through the Macbook’s trackpad section.

Tried it out with a small project, iOS can run for Mac. For the small project, ONLY AFNetWorking, NAVIGATION, MJExtension and DGActivityIndicatorView libraries will be used. Please refer to the solutions for any problems encountered.

1. The AFNetWorking library calls the deprecation method

Latest AFNetworking 3.2.1

- (instancetype)initWithMemoryCapacity:(NSUInteger)memoryCapacity diskCapacity:(NSUInteger)diskCapacity diskPath:(nullable NSString *)path API_DEPRECATED_WITH_REPLACEMENT("initWithMemoryCapacity:diskCapacity:directoryURL:", macos (10.2, API_TO_BE_DEPRECATED), ios (2.0, API_TO_BE_DEPRECATED), watchos (2.0, API_TO_BE_DEPRECATED), Tvos (9.0, API_TO_BE_DEPRECATED)) API_UNAVAILABLE (uikitformac); => API_UNAVAILABLE(uikitformac);Copy the code

Perhaps you should use a new API:

- (instancetype)initWithMemoryCapacity:(NSUInteger)memoryCapacity diskCapacity:(NSUInteger)diskCapacity DirectoryURL :(nullable NSURL *)directoryURL API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0));Copy the code

The problem has been submitted to Github, but AFNetworking has not been updated yet. You can manually change unlock to save. If there is pod install, you need to modify it.

UIWebView + AFNetworking failed to compile

UIWebView is not being used on MacOS, so UIWebView+AFNetworking does not compile. If you are not using UIWebView+AFNetworking, you can temporarily remove this class and its associated references.

3. WCDBOptimizedSQLCipher has a gethostuuid() problem

The WCDB library is a good SQLite management library. But when forMac is compiled, you can define it as follows

#if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
                           (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
#  if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \&& (! defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0))# define HAVE_GETHOSTUUID 1
# else
# warning "gethostuuid() is disabled."
# endif
#endif
Copy the code

Modified to

#if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
                           (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
#  if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \&& (! defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0)) \ && ! defined(TARGET_OS_UIKITFORMAC)# define HAVE_GETHOSTUUID 1
# else
# warning "gethostuuid() is disabled."
# endif
#endif
Copy the code

Added! Defined (TARGET_OS_UIKITFORMAC) judgment.

Note: If pod install is included, you need to modify it again.

4. SocketRocket library has many problems in for Mac, so I don’t need it for the time being, so I will remove this library and supplement methods later.

5. Contrast diagram of interface effect

The original link