iosxcodeswift3xcode8subproject

Module from sub-project (framework) can't be found


I am using XCode 8 + Swift 3.

I created a fresh iOS project named "MyApp". Then, I create a Cocoa touch framework project, named "MySubProject". (The idea is to have MyApp project accessing MySubProject code.)

They are on the same level folder:

- MyApp/
- MySubProject/

In MySubProject, I have a MyService.swift file (it is MyService class) under service group/folder:

enter image description here

The code is very simple:

import Foundation
public class MyService {
    public func greeting() -> String {
        return "Hello my service!"
    }
}

In MyApp, I added MySubProject.xcproject into MyApp project as a sub-project under MyApp:

enter image description here

Then, I drag and dropped the MySubProject.framework under MySubProject/Products/ into MyApp project's General --> Embedded Binaries and Linked Framework and Libraries:

enter image description here

Now, under MyApp/ViewController.swift, I import the MyService class from MySubProject: enter image description here

But when I build MyApp project, I always get compiler error "No such module 'MyService'" as you see in above picture.

Why? How to make MyApp being able to access MySubProject code?


Solution

  • import MySubProject ! not myService...after that copy framework to the app, see the snapshot, please. I can't post image. snapshot