Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios, macos]Remove iOS/macOS codes from native codes #16031

Merged
merged 31 commits into from
Dec 14, 2019

Conversation

m-stephen
Copy link
Contributor

Refactor of http_file_source.mm, using a delegate & interface to separate platform codes(macOS, iOS) from native codes, to reach our goal of modular SDK.

@m-stephen m-stephen requested a review from 1ec5 as a code owner December 9, 2019 16:47
@m-stephen m-stephen requested a review from a team December 9, 2019 16:47
@m-stephen m-stephen self-assigned this Dec 9, 2019
@m-stephen m-stephen added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor labels Dec 9, 2019
@m-stephen m-stephen removed request for 1ec5 and a team December 9, 2019 16:56
Copy link
Contributor

@fabian-guerra fabian-guerra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to summarize our hangout conversation into the following changes:

  • @tmpsantos could you please advice how can we use the new build system to build this library?
  • Move MGLNativeInterfaceReceiver.h/m from ios/macos to platform/darwin and import this file into each project.
  • Rename MGLNativeInterfaceReceiver to: MGLNetworkIntegrationManager
  • Rename MGLNativeAppleInterfaceTransmitter to: MGLNativeNetworkDelegate
  • Once this PR lands CP the changes related to the platform code to gl-native-ios

@tmpsantos
Copy link
Contributor

  • @tmpsantos could you please advice how can we use the new build system to build this library?

Just update the list of files here:

next/platform/macos/macos.cmake
next/platform/ios/ios.cmake

@@ -88,29 +83,29 @@ void cancel() {
public:
Impl() {
@autoreleasepool {
NSURLSessionConfiguration *sessionConfig = [MGLNetworkConfiguration sharedManager].sessionConfiguration;
NSURLSessionConfiguration *sessionConfig = MGLNativeAppleInterfaceTransmitter.shared.sessionConfiguration;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Longer-term, I would prefer to avoid having & going via a singleton here. @tmpsantos is there an existing core object that we could set a property on?

Perhaps using a notification (& object) to request the client sets a weak delegate here?

This comment is general, and shouldn't block the PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at the moment. But if we move at some point this abstraction to not be at the "request" level and rather at the "network manager" level it will probably solve the problem, because session becomes a property of the "network manager".

@m-stephen
Copy link
Contributor Author

Just update the list of files here:

next/platform/macos/macos.cmake
next/platform/ios/ios.cmake

@tmpsantos Could help to show how can I use this new build system to avoid generating sdk-files.json? It seems ios.cmake only configure files in mbgl-core.
cc: @fabian-guerra

Copy link
Contributor

@fabian-guerra fabian-guerra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. Please address the comments I left. The test is not passing because the test target is not setting the delegate and returns a nil NSURLSessionConfiguration.

@@ -88,6 +88,8 @@ target_sources(
${MBGL_ROOT}/platform/darwin/src/run_loop.cpp
${MBGL_ROOT}/platform/darwin/src/string_nsstring.mm
${MBGL_ROOT}/platform/darwin/src/timer.cpp
${MBGL_ROOT}/platform/darwin/src/native_apple_interface.m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this files to next/platform/ios/ios.cmake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are using two building systems on iOS & mac OS, it shouldn't be added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm..it looks like this was needed after all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, looks like that. We need add all *.m files into ios.cmake, should we make another PR for this?

platform/darwin/src/MGLNetworkIntegrationManager.m Outdated Show resolved Hide resolved
platform/darwin/src/http_file_source.mm Outdated Show resolved Hide resolved
platform/darwin/src/http_file_source.mm Outdated Show resolved Hide resolved
platform/darwin/src/http_file_source.mm Outdated Show resolved Hide resolved
platform/ios/CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@fabian-guerra fabian-guerra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making these changes. The next step is bring the darwing changes into gl-native-ios.
/cc @julianrex

@m-stephen m-stephen merged commit f9b7284 into master Dec 14, 2019
@m-stephen m-stephen deleted the stephen-remove-ios-codes branch December 14, 2019 05:38
julianrex pushed a commit that referenced this pull request Dec 18, 2019
* add source/header

* add ios files

* add configs

* modify name

* http_file_source

* add interface delegate when map init

* fix name

* fix delegate name

* support mac os

* add mac os support

* make optional delegate when mac os

* mac/ios difference

* add ios change log

* cancel iOS/mac OS judgement

* cancel iOS/mac OS judgement

* cancel judgement in .m

* update

* update

* update http_file_source

* update ios

* update mac os

* add mac os file

* add mac os file to `.cmake`

* change names

* add log & fix format

* reset changelog commit

* update changelog

* rename iOS network manager

* Add a test configuration(same as default configuration) when mac os run tests

* re-add account type into `http_file_source`

* refactor
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants