meismyles / SwiftWebVC

A drop-in inline browser for your Swift iOS app.
MIT License
329 stars 117 forks source link

Image assets for buttons aren't loaded #7

Closed srstanic closed 7 years ago

srstanic commented 7 years ago

Hi, I've tried adding SwiftWebVC to an empty project via CocoaPods but there is an issue with image assets in the bundle. It looks like once the pod is installed, image assets are not a part of the bundle anymore (although if you look on the filesystem, they are). The result is that the images aren't loaded when the browser view is displayed. Attached screenshot shows the issue.

If you need more information, please let me know.

swiftwebvc-issue

ed-mejia commented 7 years ago

Same problem here

meismyles commented 7 years ago

Will try and get this sorted tomorrow evening when I'm back home.

yeisonvargasf commented 7 years ago

@meismyles There is the same problem in SVWebViewController Repository, look this: TransitApp/SVWebViewController#156

srstanic commented 7 years ago

@meismyles just wanted to check if you are going to be able to review the pull request by @bchrobot sometime soon? It seems to contain a fix for this issue.

meismyles commented 7 years ago

@bchrobot @srstanic Sorry about the delay in reviewing this. Thanks for the PR @bchrobot 👍

bchrobot commented 7 years ago

Thanks for the Swift port!

srstanic commented 7 years ago

@meismyles sorry to bug you about it, but wanted to ask if you could release the fix and I guess the tag needs to be pushed to the cocoapods repo so that everyone can get the update?

I'm aware we can use this form to link master directly:

pod 'SwiftWebVC', :git => 'https://github.com/meismyles/SwiftWebVC.git'

Thanks!

bchrobot commented 7 years ago

My PR did not actually fix this. I tested it in my own project using :path as well as :git referencing the feature branch on my fork of this. Apparently some cache was not cleared completely and images are still not being referenced correctly.

meismyles commented 7 years ago

That's weird, I pulled your feature branch as well and it seemed to be working using it :/

srstanic commented 7 years ago

@bchrobot, @meismyles I've changed my Podfile to include the SwiftWebVC module like this:

pod 'SwiftWebVC', :git => 'https://github.com/meismyles/SwiftWebVC.git'

which should pull the master branch from Github, and after running

pod install

it works as expected on my machine. I can see the missing buttons now.

Here is a screenshot:

swiftwebvc

bchrobot commented 7 years ago

Herm, maybe the caching problem was actually the other direction. Glad that it is working for @srstanic - I will try again

bchrobot commented 7 years ago

EDIT: This was the resource bundle - I just didn't realize it at first...

I'm still having problems with it and cannot figure out why. I'm seeing this Pods target, which is unexpected:

screen shot 2016-12-05 at 3 31 42 pm



It is listed as a dependency for the SwiftWebVC pod:

screen shot 2016-12-05 at 3 30 36 pm
bchrobot commented 7 years ago

My problem appears to have been due to confusion about which bundle the resources were accessible from. This SO post details how the resource bundle must sourced from within the pod bundle.

My PR was looking for the resources in the pod bundle rather than the resource bundle (within the pod bundle). Not very well documented by Cocoapods

meismyles commented 7 years ago

Thanks for this @bchrobot. Will review and pull it asap.

bchrobot commented 7 years ago

Sweet 👍

Images still don't work in the example app and I'm not sure why. There are a few stale SO posts about Cocoapods not compiling assets outside of the Podfile's directory correctly, but again they were a year or so old supposedly fixed in Cocoapods 1.x

meismyles commented 7 years ago

This PR seems to be working for me. I can't find a way to make it break (but then again, the last one seemed to work for me as well), except for the images not showing in the example project currently which I will try and look at next chance I get. Not got much time to play with this at the moment unfortunately. Let me know if there are issues arising with this build. Thanks 👍

meismyles commented 7 years ago

Infact, I'm not going to make a new release for CocoaPods just yet. I'm going to review the WKWebView PR in the morning and bring that in, then will make a new release.

bchrobot commented 7 years ago

You're able to run the example app without problems? I wish I knew what was so special about my setup... 😢

meismyles commented 7 years ago

No I'm not 😭 I'm gunna try and straighten this whole thing out first thing tomorrow morning. Had a major lack of time to look at it recently and I need to figure out why they aren't working in the example app, swap everything over to WKWebView and then make a new release. I'm going to try and get this all boxed off tomorrow morning as it's frustrating me it not working correctly.

Any ideas as to why the example project isn't loading images? Especially now loading them from the bundle

meismyles commented 7 years ago

@bchrobot @srstanic Hey guys, I have made a new release that hopefully resolves the image issue. I've also refactored the example project to remove the unused Pods framework and replaced UIWebView with WKWebView to bring this more up to date. I've also pushed a new build to CocoaPods so that should all be working correctly again now. Apologies for not sorting this sooner, just not had the time.

As far as I can tell it seems to be working correctly now, but I wondered if you could take a quick look and see if the issues are resolved you. Thanks very much for all your help and contributions. It is much appreciated.

Cheers 👍 ❤️

bchrobot commented 7 years ago
pod 'SwiftWebVC', '~> 0.2.0'

Gets me the following:

screen shot 2016-12-20 at 7 18 09 pm
meismyles commented 7 years ago

What in the? Did you run definitely run pod update after updating your Podfile? I've just re-tried pod 'SwiftWebVC', '~> 0.2.0' and it's working fine:

simulator screen shot 21 dec 2016 00 22 16

bchrobot commented 7 years ago

I just tried creating a completely new iOS project, adding SwiftWebVC, and both presenting a SwiftModalWebVC modally as well as pushing a SwiftWebVC to the navigation stack. Both were missing the icons.

I thought that maybe it was a setting in the original I was working on. I haven't tried on another computer but might be able to over the holidays. Really hoping it isn't a system config problem on my dev machine...

meismyles commented 7 years ago

@bchrobot This is bizarre. I've tested it on 2 different machines and it's working successfully on both. Will have to give this a test on a few other machines in work tomorrow and see if they work.

Out of interest, if you try pod try 'SwiftWebVC' and open the example project that way does it work?

bchrobot commented 7 years ago

wtf - That does work...

I will compare project settings more thoroughly

bchrobot commented 7 years ago

At least we know this is a problem between the keyboard and the chair and not a problem with the pod. Probably okay to close the issue.

meismyles commented 7 years ago

Weird, ok I'll close this for now and will test myself again tomorrow. Let me know if you figure out why.

srstanic commented 7 years ago

Hey guys, sorry for not responding earlier. This still doesn't work for me either.

When I try pod try SwiftWebVC, the issue is not present. But when I update the pod in the test project I've created, the issue is still present. I've also noticed that the structure of the pod is different in those two contexts, although I've double checked that the version 0.3.0 is installed in my test project.

swiftwebvc-issue-still-present-in-030

Even looking at the code of SwiftWebVC.swift itself, I can see the changes from the latest commit where the SwiftWebVCDelegate protocol was added. So it looks like the code is up to date, but the pod structure is not.

cc @meismyles

srstanic commented 7 years ago

I just wanted to add that version 0.1.2 is working for me. I'm referencing it like this:

pod 'SwiftWebVC', :git => 'https://github.com/meismyles/SwiftWebVC.git', :commit => 'b8c1a51f7915f8d8fe9e0cc6137dcb737f10dd37'

I think that's pretty much the same code that I've referenced before directly from the master branch. It worked for me before and it still works.

meismyles commented 7 years ago

Hey @srstanic. Thanks for getting back. This is really confusing haha. The pod is definitely up to date and this shows on the CocoaPods website.

I can't seem to make this not display the images with the current version. I'm not sure how else to try and reproduce this - got any ideas?

srstanic commented 7 years ago

@meismyles here is what I did:

  1. Created a new XCode project
  2. Opened the project dir in terminal, executed pod init
  3. Opened the Podfile and added pod 'SwiftWebVC' to it
  4. Went back to the terminal and executed pod install

Result:

  1. SwiftWebVC version 0.3.0 was installed
  2. When I opened the xcworkspace file with XCode an examined the installed SwiftWebVC pod structure, it looked different (older) than the pod that is used in the workspace opened by pod try SwiftWebVC. The difference is visible in the screenshot I've attached to the previous comment

If you follow the same steps, what are your results? How does your pod structure look like? Is it up to date with the latest commit?

meismyles commented 7 years ago

Ok now I'm getting the issue again. This is so confusing. 😭

meismyles commented 7 years ago

Must be to do with the structure as you suggest. The resources location is specified as SwiftWebVC/Assets/Media.xcassets in the Podspec. Doing pod try seems to retain this structure, but installing it normally as just a plain old pod moves the files around and puts the Media.xcassets group in a folder called Resources. 😕

meismyles commented 7 years ago

Just pushed a new release but this didn't fix it. Difficult to test solutions without actually pushing new releases to CocoaPods.

meismyles commented 7 years ago

Hey @srstanic and @bchrobot, the latest fix in version 0.3.3 seems to have fixed this for me (again haha 😂 ). If you guys could check with this version and let me know I would be eternally grateful. Thanks very much.

bchrobot commented 7 years ago

It is indeed very strange, not to mention frustrating. It would be nice if CocoaPods provided documentation about best practices around asset management as I'm sure this is not an uncommon feature.

Thank you for working on the new version! I will try it out tonight or tomorrow and let you know

srstanic commented 7 years ago

@meismyles I've tested 0.3.3 by referencing the master branch from the Podfile and it is working for me! 👏 🎉 Thanks for fixing this!

meismyles commented 7 years ago

@srstanic Wooo 😄 0.3.3 should be the live version in CocoaPods, was there a specific reason why you needed to reference the master branch?

bchrobot commented 7 years ago

Confirmed that 0.3.3 works when referencing CocoaPods!

srstanic commented 7 years ago

@meismyles I forgot to run pod repo update so referencing 0.3.3 didn't work. My bad. :)