ProxymanApp / atlantis

Capture HTTP/HTTPS, and Websocket from iOS app without proxy.
https://proxyman.io
Apache License 2.0
1.24k stars 92 forks source link

Objective-C error 'Atlantis-Swift.h' file not found. #56

Open apostopher opened 3 years ago

apostopher commented 3 years ago

Hello, first of all, thanks to proxyman, it's super easy to debug network traffic.

I'm trying to integrate Atlantis in my objective-C AppDelegate.m. but the Xcode build fails with the error 'Atlantis-Swift.h' file not found.

I followed the README.md documentation and added #import "Atlantis-Swift.h". I'm using the Atlantis version 1.7.1 (installed using cocoapods)

Thanks in advance.

NghiaTranUIT commented 3 years ago

Thanks for the bug. Let me investigate it with the Objc Project

NghiaTranUIT commented 3 years ago

Hey @apostopher

I've just created a new Objective-C Project and integrate Atlantis by Cocoapod. I didn't get any problem.

Screen Shot 2021-02-10 at 09 00 12
#import "AppDelegate.h"
#import "Atlantis-Swift.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [Atlantis startWithHostName:nil];
    return YES;
}

Can you download and run this objc example: https://www.dropbox.com/s/k9cbdqhmyil5lo6/Objective-C-Example.zip?dl=0

apostopher commented 3 years ago

@NghiaTranUIT thanks for a quick reply. sure. I'll try it on my end.

NghiaTranUIT commented 3 years ago

You're welcome @apostopher Please let me know the result 😄

apostopher commented 3 years ago

@NghiaTranUIT it worked in your project. I'm using react-native. and it's still failing. I'll investigate the issue and update this thread.

NghiaTranUIT commented 3 years ago

I'm not sure if Atlantis could work with React-Native if the Network library in your project doesn't use URLSession to make a Request.

Do you know a React-native example that I can test out? 🤔

apostopher commented 3 years ago

I think react-native's fetch API internally uses NSURLSession. I'll try a sample app tomorrow. I'll share my findings with you.

apostopher commented 3 years ago

@NghiaTranUIT i investigated the issue and here are my 2 cents: This error happens if the Podfile does not have use_frameworks! line.

Unfortunately in my case if i add use_frameworks! my other deps fail to build. :-(

NghiaTranUIT commented 3 years ago

@apostopher can you fork the project, remove the use_frameworks! and see if it works for you 🤔

apostopher commented 3 years ago

@NghiaTranUIT I cloned this project https://www.dropbox.com/s/k9cbdqhmyil5lo6/Objective-C-Example.zip?dl=0 and tried without use_frameworks! and I can reproduce the same error.

NghiaTranUIT commented 3 years ago

Thanks. Let me check it out 👍

archcorsair commented 2 years ago

Solution

🎉 I found a working solution using a plugin called cocoapods-user-defined-build-types

  1. Install the gem: $ gem install cocoapods-user-defined-build-types
  2. Add these above your target in Podfile
    plugin 'cocoapods-user-defined-build-types'
    enable_user_defined_build_types!
  3. Add atlantis pod:
    pod 'atlantis-proxyman', :build_type => :dynamic_framework

This fixed my issue and Atlantis works perfectly.

Original Comment

I'm running into this exact issue. I've confirmed the pod was installed, it shows up in Podfile.lock. atlantis-proxyman (1.12.0) Tried cleaning before building and it did not help.

React Native project - Running on M1 (arm64) Xcode 13.1 (13A1030d) MacOS 12.0.1

image

archcorsair commented 2 years ago

Solution

🎉 I found a working solution using a plugin called cocoapods-user-defined-build-types

  1. Install the gem: $ gem install cocoapods-user-defined-build-types
  2. Add these two lines above your target in Podfile:
    plugin 'cocoapods-user-defined-build-types'
    enable_user_defined_build_types!
  3. Add atlantis pod:
    pod 'atlantis-proxyman', :build_type => :dynamic_framework

This fixed my issue and Atlantis works perfectly.

NghiaTranUIT commented 2 years ago

Awesome 👍 I might add a public header to in SPM, so you can use SPM on Objective-C project 👍

apostopher commented 2 years ago

that's great news! thanks, @archcorsair for the solution. and a million thanks to @NghiaTranUIT for the awesome proxyman and atlantis!

do you have plans to support android too?

NghiaTranUIT commented 2 years ago

Unfortunately, I don't have any plan to bring Atlantis to Android because I have no experience on Android and Atlantis is heavily depends on Method Swizzling and URLSession, which are not available on Android world.

NghiaTranUIT commented 2 years ago

It seems that adding the public header to use SPM on the Objective-C project is not possible in terms of technical limitations. Thread: https://forums.swift.org/t/how-to-import-swift-package-into-objective-c-using-xcode/43978/15

StanislavMayorov commented 2 years ago

Http proxy works fine in RN project using cocoapods-user-defined-build-types solution, but websocket doesn't work. Is it possible to extend RN implementation to support atlantis?

rolfen commented 5 months ago

@archcorsair , followed your instructions, to no avail

[!] Invalid `Podfile` file: undefined method `enable_user_defined_build_types!' for an instance of Pod::Podfile
NghiaTranUIT commented 5 months ago

@rolfen do you use React Native or native iOS app 🤔

I've created a Objective-C iOS project again, and Cocoapod works fine with Atlantis. No need to use enable_user_defined_build_types

NghiaTranUIT commented 5 months ago

Http proxy works fine in RN project using cocoapods-user-defined-build-types solution, but websocket doesn't work. Is it possible to extend RN implementation to support atlantis?

It's a known issue because React Native doesn't use native URLWebsocketSession to make a WS/WSS. They use their own WS socket. Thus, Atlantis doesn't work.

rolfen commented 5 months ago

@rolfen do you use React Native or native iOS app 🤔

I've created a Objective-C iOS project again, and Cocoapod works fine with Atlantis. No need to use enable_user_defined_build_types

I use react-native trying to build ios.

I tried the workaround suggested by @archcorsair and after many additional steps to be able to install the plugin (install rbenv, update ruby, update this update that, etc.) I finally hit this error on pod install so gave up on atlantis.

Flipper or proxyman(+helper) seem to work for my needs.

Changing the use_frameworks! setting will break the build somewhere else.

NghiaTranUIT commented 5 months ago

Can you use SPM on your react-native app? @rolfen

I will checkout the react-native + Atlantis today

NghiaTranUIT commented 5 months ago

@rolfen I follow this solution and it works fine: https://github.com/ProxymanApp/atlantis/issues/56#issuecomment-958427958

Screenshot 2024-03-16 at 4 12 59 PM


Note: I don't use use_frameworks! in the Podfile