Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promises in Application Extension #73

Closed
richardtop opened this issue Oct 12, 2018 · 2 comments
Closed

Promises in Application Extension #73

richardtop opened this issue Oct 12, 2018 · 2 comments

Comments

@richardtop
Copy link

richardtop commented Oct 12, 2018

Hi, is it possible to use Promises in Application Extensions (i.e. Siri Intents or Today Extension)?
I'm using Promises for my network layer which is shared using a framework.
The Promises library is used with the help of CocoaPods.

The app is organized in the following manner:
AppNameKit - Core framework with networking and logic
AppName - The application itelf
AppIntent - The Siri intent
AppIntentUI - The UI component of the Siri Intent.

While the framework is linked correctly and the app works fine, I got the error when I try to use the AppNameKit in AppIntent.

I can import Promises in the AppIntent, but whenever I use the code that actually uses Promise as its return value, I get the error:

ld: warning: linking against a dylib which is not safe for use in application extensions: /Users/richard/Library/Developer/Xcode/DerivedData/AppName-akvlogsasqbqhhgohvikypiqacwv/Build/Products/Debug-iphonesimulator/AppNameKit.framework/AppNameKit
ld: warning: Could not find auto-linked framework 'KeychainAccess'
ld: warning: Could not find auto-linked framework 'Kingfisher'
ld: warning: Could not find auto-linked framework 'Promises'
ld: warning: Could not find auto-linked framework 'FBLPromises'
ld: warning: Could not find auto-linked framework 'JWTDecode'
ld: warning: Could not find auto-linked framework 'Alamofire'
Undefined symbols for architecture x86_64:
  "static (extension in Promises):__C.OS_dispatch_queue.promises.getter : __C.OS_dispatch_queue", referenced from:
      default argument 0 of Promises.Promise.then(on: __C.OS_dispatch_queue, _: (A) throws -> ()) -> Promises.Promise<A> in PhoneBalanceIntentHandler.o
  "Promises.Promise.then(on: __C.OS_dispatch_queue, _: (A) throws -> ()) -> Promises.Promise<A>", referenced from:
      AppNameIntent.PhoneBalanceIntentHandler.handle(intent: AppNameKit.ViewBalanceIntent, completion: (AppNameKit.ViewBalanceIntentResponse) -> ()) -> () in PhoneBalanceIntentHandler.o
     (maybe you meant: _$S8Promises7PromiseC4then2on_ACyxGSo17OS_dispatch_queueC_yxKctFfA_)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

image

What could be the reason for such result? What is the best way to use Promises in such a configuration (shared networking & logic core, multiple targets - app, extension, intents...)?

Are Promises safe to be used in App Extensions?

@shoumikhin
Copy link
Contributor

Hi Richard,

Promises are used in Google's app extensions. We don't use any app-specific APIs and have APPLICATION_EXTENSION_API_ONLY flags set in xcodeproj.

Your error looks like the lib is being missing during the linkage stage. Hope you were able to setup the project in such a way that Promises lib gets linked against your target.

Thanks.

@richardtop
Copy link
Author

Hi Anthony,
you were right - the library has ben linked against the common core, but hasn't been linked with the extension target.

After I've added the framework to the intent as a CocoaPod, I was able to successfully run the app. Hence, the issue was closed.

Btw, congratulations with the new role at Facebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants