sindresorhus / LaunchAtLogin-Legacy

Add “Launch at Login” functionality to your macOS app in seconds
MIT License
1.56k stars 123 forks source link

Specify Usage Instruction is only for Carthage #13

Closed deadcoder0904 closed 6 years ago

deadcoder0904 commented 6 years ago

I was getting error #7 when I pasted the script path in Build Phase & I was using Podfile so as a Swift noob I installed the pod but also did this as shown in the README👇

Add a new "Run Script Phase" below "Embed Frameworks" in "Build Phases" with the following: ./Carthage/Build/Mac/LaunchAtLogin.framework/Resources/copy-helper.sh

It works fine without it so I think it should be specified it is only required for Carthage & not needed for CocoaPods as it may confuse beginners like me.

sindresorhus commented 6 years ago

It won't work without that step even with CocoaPods.

deadcoder0904 commented 6 years ago

Ohh I thought it returned false so it worked.

Got that part but then how do I go about the next step then? Do I need to install it through Carthage too?

Or I just need to do carthage build because I got #7 after pasting the above file path & I think this is because I've changed the default directory structure & made it look like this

xcode

I am not clear with the instructions to be honest

deadcoder0904 commented 6 years ago

Just checked README again & now I know the difference. It turns out https://cocoapods.org/pods/LaunchAtLogin README is different than Github README. CocoaPods step is missing there. I'll try & post the results.

deadcoder0904 commented 6 years ago

@sindresorhus I get another error

cp: path/to/myApp.app/Contents/Frameworks/LaunchAtLogin.framework/Resources/LaunchAtLoginHelper.app: No such file or directory
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

Its not able to find LaunchAtLoginHelper.app I guess. Also, I can't find it anywhere in the Pods directory.

Anyways I tried the following as you told here

LaunchAtLogin.isEnabled = true
print(LaunchAtLogin.isEnabled)
//=> false

And it works properly. But I get 2 errors & 1 warning. 2 errors are of the above thing & 1 warning is #12 which I think is Okay.

deadcoder0904 commented 6 years ago

Hi @sindresorhus so my app is completed now & I put my .app into Applications folder & enabled Launch At Login & restarted my Mac to see if it works. But it didn't.

Also, my application is now code signed as I checked it with

codesign -dvv /Applications/myApp.app

I did follow all the instructions in the README as follows -

  1. Made a Podfile & installed with pod install
platform :osx, '10.12'

target 'myApp' do
  use_frameworks!
  pod 'LaunchAtLogin'
end
  1. Added a new "Run Script Phase" below "Embed Frameworks" in "Build Phases" with the following:
./Pods/LaunchAtLogin/LaunchAtLogin/copy-helper.sh

But I still get the error

cp: /Users/deadcoder0904/Library/Developer/Xcode/DerivedData/myApp-bcrytpktfvzflmexubmyosnhzksq/Build/Products/Debug/myApp.app/Contents/Frameworks/LaunchAtLogin.framework/Resources/LaunchAtLoginHelper.app: No such file or directory
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

Anything I should do to solve this?

deadcoder0904 commented 6 years ago

Made a simplest demo app to see if it works but it doesn't

Here's the link - https://github.com/deadcoder0904/LaunchAtLoginPod

deadcoder0904 commented 6 years ago

Made a simplest demo app to see if it works with Carthage & it does 🎉

Here's the link - https://github.com/deadcoder0904/LaunchAtLoginCart

@sindresorhus I asked someone else who used this library with CocoaPods & he's able to run it perfectly fine. Most important point, he cloned my project in the above comment & he didn't get any error. But not working for me at least.

Anyways thank you for this awesome project. Its so much easier to use. Close this if you want and also let me know if you want me to open another issue about the error I have with CocoaPods stated above.

deadcoder0904 commented 6 years ago

Okay so I found the solution with the help of someone. The complete answer is posted on Stack Overflow here & I think @sindresorhus this can be put up on README as well. Also, for simplicity purposes I'll copy the answer here too just in case.

Add a new "Run Script" below "[CP] Embed Pods Frameworks" in "Build Phases" with the absolute path to copy-helper.sh.

For simplicity, you can just drag & drop copy-helper.sh. Drag it inside label Shell. Then change Location to Absolute Path

xcode

Thank you for making my life easy with your countless modules 🙌

dgazzoni commented 5 years ago

Okay so I found the solution with the help of someone. The complete answer is posted on Stack Overflow here & I think @sindresorhus this can be put up on README as well. Also, for simplicity purposes I'll copy the answer here too just in case.

Add a new "Run Script" below "[CP] Embed Pods Frameworks" in "Build Phases" with the absolute path to copy-helper.sh.

For simplicity, you can just drag & drop copy-helper.sh. Drag it inside label Shell. Then change Location to Absolute Path

xcode

Thank you for making my life easy with your countless modules 🙌

Sorry, but this isn't a solution at all. What you did was nonsensical and merely made Xcode ignore the error due to the way the script was called, but the error still exists nevertheless: for some reason, LaunchAtLoginHelper.app is not being created, which is why the cp command is failing.

I'm commenting because the error is also happening to me and I would like to get to the bottom of this. To be clear, I'm using CocoaPods not Carthage.

deadcoder0904 commented 5 years ago

Maybe nonsensical but hey it works for me & my app so Idc 🤷‍♂️