tomkowz / Swifternalization

Localize iOS apps in a smarter way using JSON files. Swift framework.
MIT License
579 stars 47 forks source link

watchOS support #10

Open lexrus opened 9 years ago

lexrus commented 9 years ago

Hi, this project is great. I'd like to use it in my WATCH App. Do you have any plan to support watchOS?

tomkowz commented 9 years ago

Hey @lexrus, it should work as is now. Just configure framework with correct NSBundle instance and you should be able to do this. If this not still work for you could you share how files are located in the project and how you're configuring it and getting localized values? If this should work but don't it means that something is broken in Swifternalization. Unfortunately I'll take a look on this probably during the weekend.

lexrus commented 9 years ago

Hi @tomkowz Thank you for the rapid reply. I tried to import this lib as a framework with CocoaPods. My Podfile:

use_frameworks!
inhibit_all_warnings!

...other targets...

target 'VPNOnWatchKitExtension' do
  platform :watchos
  pod 'Swifternalization',
    :git    => 'git@github.com:tomkowz/Swifternalization.git',
    :branch => 'swift2'
  pod 'KeychainAccess',
    :git    => 'git@github.com:kishikawakatsumi/KeychainAccess.git',
    :branch => 'swift-2.0'
end

target 'VPNOnWatchKitApp' do
  platform :watchos
  pod 'Swifternalization',
    :git    => 'git@github.com:tomkowz/Swifternalization.git',
    :branch => 'swift2'
  pod 'KeychainAccess',
    :git    => 'git@github.com:kishikawakatsumi/KeychainAccess.git',
    :branch => 'swift-2.0'
end

But failed while pod install:

[!] The platform of the target `VPNOnWatchKitApp` (watchOS 2.0) is not compatible with `Swifternalization (1.2)`, which does not support `watchos`.
[!] The platform of the target `VPNOnWatchKitExtension` (watchOS 2.0) is not compatible with `Swifternalization (1.2)`, which does not support `watchOS`.

If I comment out Swifternalization, the KeychainAccess can be installed without problems. I don't know what the difference between them.

tomkowz commented 9 years ago

What is plaform version that you specified in Podfile? I don't see it here.

Here is my configuration that I used for example:

platform :ios, '8.0'
use_frameworks!
pod 'Swifternalization', :git => 'https://github.com/tomkowz/Swifternalization.git', :branch => 'swift2'

I don't think so you need Swifternalization for Apple Watch App target. You need it in extension because the translation files will be used by extension.

lexrus commented 9 years ago

The default platform for the whole project was set to iOS 9.

platform :ios, '9.0'

But I did mention above platform :watchos in targets of both WatchKitApp and WatchKitExtension.

lexrus commented 9 years ago

https://github.com/lexrus/VPNOn/blob/feature/ios9/Podfile Here is my podfile which works fine. But failed after import Swifternalization in the 2 watchOS targets.

tomkowz commented 9 years ago

Ahh, right, I see. I'll fix it in the weekend.