atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

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

Open apostopher opened this issue 3 years ago • 24 comments

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.

apostopher avatar Feb 10 '21 01:02 apostopher

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

NghiaTranUIT avatar Feb 10 '21 01:02 NghiaTranUIT

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

NghiaTranUIT avatar Feb 10 '21 02:02 NghiaTranUIT

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

apostopher avatar Feb 10 '21 03:02 apostopher

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

NghiaTranUIT avatar Feb 10 '21 04:02 NghiaTranUIT

@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.

apostopher avatar Feb 10 '21 06:02 apostopher

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? 🤔

NghiaTranUIT avatar Feb 10 '21 07:02 NghiaTranUIT

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 avatar Feb 10 '21 15:02 apostopher

@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. :-(

apostopher avatar Mar 12 '21 14:03 apostopher

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

NghiaTranUIT avatar Mar 13 '21 04:03 NghiaTranUIT

@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.

apostopher avatar Mar 23 '21 11:03 apostopher

Thanks. Let me check it out 👍

NghiaTranUIT avatar Mar 23 '21 14:03 NghiaTranUIT

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!
  1. 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 avatar Nov 02 '21 21:11 archcorsair

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!
  1. Add atlantis pod:
pod 'atlantis-proxyman', :build_type => :dynamic_framework

This fixed my issue and Atlantis works perfectly.

archcorsair avatar Nov 02 '21 23:11 archcorsair

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

NghiaTranUIT avatar Nov 03 '21 00:11 NghiaTranUIT

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?

apostopher avatar Nov 03 '21 01:11 apostopher

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 avatar Nov 03 '21 01:11 NghiaTranUIT

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

NghiaTranUIT avatar Nov 03 '21 01:11 NghiaTranUIT

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?

StanislavMayorov avatar Aug 11 '22 15:08 StanislavMayorov

@archcorsair , followed your instructions, to no avail

[!] Invalid `Podfile` file: undefined method `enable_user_defined_build_types!' for an instance of Pod::Podfile

rolfen avatar Mar 14 '24 15:03 rolfen

@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 avatar Mar 15 '24 02:03 NghiaTranUIT

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.

NghiaTranUIT avatar Mar 15 '24 02:03 NghiaTranUIT

@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.

rolfen avatar Mar 16 '24 07:03 rolfen

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

I will checkout the react-native + Atlantis today

NghiaTranUIT avatar Mar 16 '24 07:03 NghiaTranUIT

@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

NghiaTranUIT avatar Mar 16 '24 09:03 NghiaTranUIT